Skip to content

Commit

Permalink
feat(build): use babel (renovatebot#3825)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored and rarkins committed May 28, 2019
1 parent 9d6d448 commit 0b063ae
Show file tree
Hide file tree
Showing 19 changed files with 1,011 additions and 129 deletions.
19 changes: 19 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"presets": [
[
"@babel/env",
{
"targets": {
"node": true
}
}
],
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
],
"sourceMaps": true,
"retainLines": true
}
8 changes: 2 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
"env": { "LOG_LEVEL": "debug" },
"console": "integratedTerminal",
"disableOptimisticBPs": true,
"runtimeArgs": [
"--nolazy",
"--preserve-symlinks",
"-r",
"ts-node/register"
],
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/babel-node",
"runtimeArgs": ["--nolazy", "--extensions", ".ts,.js"],
"protocol": "inspector",
"skipFiles": ["<node_internals>/**/*.js"]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/platform/azure/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const azureHelper = require('./azure-helper');
const azureApi = require('./azure-got-wrapper');
const hostRules = require('../../util/host-rules');
const { appSlug } = require('../../config/app-strings');
const GitStorage = require('../git/storage');
const GitStorage = require('../git/storage').Storage;

let config = {};

Expand Down
25 changes: 12 additions & 13 deletions lib/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ export async function setBaseBranch(branchName: string = config.defaultBranch) {
await config.storage.setBaseBranch(branchName);
}

// istanbul ignore next
export function setBranchPrefix(branchPrefix: string) {
export /* istanbul ignore next */ function setBranchPrefix(
branchPrefix: string
) {
return config.storage.setBranchPrefix(branchPrefix);
}

Expand Down Expand Up @@ -275,8 +276,7 @@ export function getBranchLastCommitTime(branchName: string) {
return config.storage.getBranchLastCommitTime(branchName);
}

// istanbul ignore next
export function getRepoStatus() {
export /* istanbul ignore next */ function getRepoStatus() {
return config.storage.getRepoStatus();
}

Expand Down Expand Up @@ -405,33 +405,32 @@ export async function setBranchStatus(
// return [];
// }

// istanbul ignore next
export function findIssue(title: string) {
export /* istanbul ignore next */ function findIssue(title: string) {
logger.debug(`findIssue(${title})`);
// TODO: Needs implementation
// This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "masterIssue"
// BB Server doesnt have issues
return null;
}

// istanbul ignore next
export function ensureIssue(title: string, body: string) {
export /* istanbul ignore next */ function ensureIssue(
title: string,
body: string
) {
logger.debug(`ensureIssue(${title}, body={${body}})`);
// TODO: Needs implementation
// This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "masterIssue"
// BB Server doesnt have issues
return null;
}

// istanbul ignore next
export function getIssueList() {
export /* istanbul ignore next */ function getIssueList() {
logger.debug(`getIssueList()`);
// TODO: Needs implementation
return [];
}

// istanbul ignore next
export function ensureIssueClosing(title: string) {
export /* istanbul ignore next */ function ensureIssueClosing(title: string) {
logger.debug(`ensureIssueClosing(${title})`);
// TODO: Needs implementation
// This is used by Renovate when creating its own issues, e.g. for deprecated package warnings, config error notifications, or "masterIssue"
Expand Down Expand Up @@ -622,10 +621,10 @@ export async function ensureCommentRemoval(prNo: number, topic: string) {
}

// TODO: coverage
// istanbul ignore next
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function getPrList(_args?: any) {
logger.debug(`getPrList()`);
// istanbul ignore next
if (!config.prList) {
const values = await utils.accumulateValues(
`./rest/api/1.0/projects/${config.projectKey}/repos/${
Expand Down
11 changes: 5 additions & 6 deletions lib/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ export async function setBaseBranch(branchName = config.baseBranch) {
await getFileList(branchName);
}

// istanbul ignore next
export function setBranchPrefix(branchPrefix: string) {
export /* istanbul ignore next */ function setBranchPrefix(
branchPrefix: string
) {
return config.storage.setBranchPrefix(branchPrefix);
}

Expand Down Expand Up @@ -381,8 +382,7 @@ export async function ensureIssue(title: string, body: string) {
return null;
}

// istanbul ignore next
export function getIssueList() {
export /* istanbul ignore next */ function getIssueList() {
logger.debug(`getIssueList()`);
// TODO: Needs implementation
return [];
Expand Down Expand Up @@ -416,8 +416,7 @@ export async function addReviewers(prId: number, reviewers: string[]) {
});
}

// istanbul ignore next
export function deleteLabel() {
export /* istanbul ignore next */ function deleteLabel() {
throw new Error('deleteLabel not implemented');
}

Expand Down
3 changes: 1 addition & 2 deletions lib/platform/bitbucket/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export async function accumulateValues(
return accumulator;
}

// istanbul ignore next
export function isConflicted(files: any) {
export /* istanbul ignore next */ function isConflicted(files: any) {
for (const file of files) {
for (const chunk of file.chunks) {
for (const change of chunk.changes) {
Expand Down
4 changes: 2 additions & 2 deletions lib/platform/git/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface ILocalConfig extends IStorageConfig {
branchPrefix: string;
}

class Storage {
export class Storage {
private _config: ILocalConfig = {} as any;

private _git: Git.SimpleGit | undefined;
Expand Down Expand Up @@ -445,4 +445,4 @@ function localName(branchName: string) {
return branchName.replace(/^origin\//, '');
}

export = Storage;
export default Storage;
2 changes: 1 addition & 1 deletion lib/platform/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const URL = require('url');

const get = require('./gh-got-wrapper');
const hostRules = require('../../util/host-rules');
const GitStorage = require('../git/storage');
const GitStorage = require('../git/storage').Storage;

const {
appName,
Expand Down
2 changes: 1 addition & 1 deletion lib/platform/gitlab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const is = require('@sindresorhus/is');

const get = require('./gl-got-wrapper');
const hostRules = require('../../util/host-rules');
const GitStorage = require('../git/storage');
const GitStorage = require('../git/storage').Storage;

let config = {};
const defaults = {
Expand Down
4 changes: 2 additions & 2 deletions lib/renovate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

require('./proxy');
const globalWorker = require('./workers/global');
import './proxy';
import * as globalWorker from './workers/global';

(async () => {
await globalWorker.start();
Expand Down
50 changes: 26 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"clean-cache": "node bin/clean-cache.js",
"copy-static-files": "copyfiles -u 1 lib/**/*.json lib/**/*.py dist/",
"create-json-schema": "node bin/create-json-schema.js && prettier --write \"renovate-schema.json\"",
"debug": "node -r ts-node/register/transpile-only --inspect-brk lib/renovate.ts",
"debug": "babel-node --inspect-brk --extensions \".ts,.js\" -- lib/renovate.ts",
"eslint": "run-s eslint:*",
"eslint:js": "eslint lib test --ext .js",
"eslint:ts": "eslint -c .tslintrc.js lib test --ext .ts",
Expand All @@ -26,7 +26,7 @@
"lint-fix": "yarn eslint-fix && yarn prettier-fix",
"prettier": "prettier --list-different \"**/*.{ts,js,json,md}\"",
"prettier-fix": "prettier --write \"**/*.{ts,js,json,md}\"",
"start": "node -r ts-node/register/transpile-only lib/renovate.ts",
"start": "babel-node --extensions \".ts,.js\" -- lib/renovate.ts",
"test-dirty": "git diff --exit-code",
"test-e2e": "npm pack && cd e2e && yarn install --no-lockfile && yarn test",
"test-schema": "bash test/json-schema.sh",
Expand Down Expand Up @@ -154,6 +154,13 @@
"yarn": "1.16.0"
},
"devDependencies": {
"@babel/cli": "7.4.4",
"@babel/core": "7.4.5",
"@babel/node": "7.4.5",
"@babel/plugin-proposal-class-properties": "7.4.4",
"@babel/plugin-proposal-object-rest-spread": "7.4.4",
"@babel/preset-env": "7.4.5",
"@babel/preset-typescript": "7.3.3",
"@types/bunyan": "1.8.6",
"@types/convert-hrtime": "2.0.0",
"@types/fs-extra": "7.0.0",
Expand All @@ -163,6 +170,7 @@
"@types/tmp": "0.1.0",
"@typescript-eslint/eslint-plugin": "1.9.0",
"@typescript-eslint/parser": "1.9.0",
"babel-jest": "24.8.0",
"chai": "4.2.0",
"copyfiles": "2.1.0",
"cross-env": "5.2.0",
Expand All @@ -183,8 +191,6 @@
"rimraf": "2.6.3",
"semantic-release": "15.13.12",
"tmp-promise": "2.0.1",
"ts-jest": "24.0.2",
"ts-node": "8.1.0",
"typescript": "3.4.5"
},
"resolutions": {
Expand All @@ -197,17 +203,11 @@
"dist"
],
"jest": {
"globals": {
"ts-jest": {
"isolatedModules": true
}
},
"cacheDirectory": ".cache/jest",
"coverageDirectory": "./coverage",
"collectCoverage": true,
"collectCoverageFrom": [
"lib/**/*.{js,ts}",
"!lib/platform/bitbucket-server/bb-got-wrapper.js",
"!lib/versioning/maven/index.js",
"!lib/proxy.js"
],
Expand All @@ -226,7 +226,9 @@
"snapshotSerializers": [
"./test/newline-snapshot-serializer.js"
],
"preset": "ts-jest/presets/js-with-ts"
"transform": {
"^.+\\.(j|t)s$": "babel-jest"
}
},
"publishConfig": {
"tag": "next"
Expand All @@ -238,19 +240,19 @@
},
"release": {
"branch": "master",
"analyzeCommits": {
"preset": "angular",
"releaseRules": [
{
"type": "docs",
"scope": "readme.md",
"release": "patch"
},
{
"type": "build",
"release": "patch"
}
]
"analyzeCommits": {
"preset": "angular",
"releaseRules": [
{
"type": "docs",
"scope": "readme.md",
"release": "patch"
},
{
"type": "build",
"release": "patch"
}
]
},
"tagFormat": "${version}"
}
Expand Down
2 changes: 1 addition & 1 deletion test/platform/azure/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('platform/azure', () => {
azure = require('../../../lib/platform/azure');
azureApi = require('../../../lib/platform/azure/azure-got-wrapper');
azureHelper = require('../../../lib/platform/azure/azure-helper');
GitStorage = require('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage').Storage;
GitStorage.mockImplementation(() => ({
initRepo: jest.fn(),
cleanRepo: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/platform/bitbucket-server/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('platform/bitbucket-server', () => {
jest.spyOn(api, 'put');
jest.spyOn(api, 'delete');
bitbucket = require('../../../lib/platform/bitbucket-server');
GitStorage = require('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage').Storage;
GitStorage.mockImplementation(
() =>
({
Expand Down
4 changes: 2 additions & 2 deletions test/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('platform/bitbucket', () => {
let api: jest.Mocked<IGotApi>;
let hostRules: jest.Mocked<typeof import('../../../lib/util/host-rules')>;
let GitStorage: jest.Mocked<
typeof import('../../../lib/platform/git/storage')
import('../../../lib/platform/git/storage').Storage
> &
jest.Mock;
beforeEach(() => {
Expand All @@ -19,7 +19,7 @@ describe('platform/bitbucket', () => {
hostRules = require('../../../lib/util/host-rules');
api = require('../../../lib/platform/bitbucket/bb-got-wrapper').api;
bitbucket = require('../../../lib/platform/bitbucket');
GitStorage = require('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage').Storage;
GitStorage.mockImplementation(() => ({
initRepo: jest.fn(),
cleanRepo: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/platform/github/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('platform/github', () => {
github = require('../../../lib/platform/github');
hostRules = require('../../../lib/util/host-rules');
jest.mock('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage').Storage;
GitStorage.mockImplementation(() => ({
initRepo: jest.fn(),
cleanRepo: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion test/platform/gitlab/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('platform/gitlab', () => {
jest.mock('../../../lib/util/host-rules');
hostRules = require('../../../lib/util/host-rules');
jest.mock('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage');
GitStorage = require('../../../lib/platform/git/storage').Storage;
GitStorage.mockImplementation(() => ({
initRepo: jest.fn(),
cleanRepo: jest.fn(),
Expand Down
1 change: 1 addition & 0 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig",
"compilerOptions": {
"resolveJsonModule": false,
"isolatedModules": false,
"sourceMap": false,
"types": ["node"]
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true,
"lib": ["es2018"],
"types": ["node", "jest"]
},
Expand Down
Loading

0 comments on commit 0b063ae

Please sign in to comment.