From 914bbb3db29d5ec885b3cd39ca2e2f6e77ba0c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bazyli=20Brzo=CC=81ska?= Date: Fri, 11 Nov 2016 17:29:13 +0100 Subject: [PATCH] chore(package): use the external aurelia-tools CLI to build - adds prepare release task: https://github.com/aurelia/validation/issues/357 - blocked on: https://github.com/aurelia/tools/pull/51 --- .gitignore | 1 + bower.json | 48 ++++++++++++++++++++--------------------- doc/shape-defs.js | 52 --------------------------------------------- doc/shape-doc.js | 24 --------------------- doc/tsconfig.json | 21 ------------------ package.json | 26 +++++++++++------------ tsconfig.build.json | 40 +++++++++++----------------------- tsconfig.json | 30 +++----------------------- 8 files changed, 52 insertions(+), 190 deletions(-) delete mode 100644 doc/shape-defs.js delete mode 100644 doc/shape-doc.js delete mode 100644 doc/tsconfig.json diff --git a/.gitignore b/.gitignore index 1c710195..186528d6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ npm-debug.log* .test dist/doc-temp dist/test +yarn.lock diff --git a/bower.json b/bower.json index f5977018..abc5f61f 100644 --- a/bower.json +++ b/bower.json @@ -1,24 +1,24 @@ -{ - "name": "aurelia-validation", - "version": "0.14.0", - "description": "Validation for Aurelia applications", - "keywords": [ - "aurelia", - "plugin", - "validation" - ], - "main": "dist/commonjs/aurelia-validation.js", - "moduleType": "node", - "homepage": "http://aurelia.io", - "license": "MIT", - "author": "Jeremy Danyow (https:/danyow.net/)", - "repository": { - "type": "git", - "url": "https://github.com/aurelia/validation" - }, - "dependencies": { - "aurelia-binding": "^1.0.1", - "aurelia-metadata": "^1.0.0", - "aurelia-templating": "^1.0.0" - } -} +{ + "name": "aurelia-validation", + "version": "0.14.0", + "description": "Validation for Aurelia applications", + "keywords": [ + "aurelia", + "plugin", + "validation" + ], + "main": "dist/commonjs/aurelia-validation.js", + "moduleType": "node", + "homepage": "http://aurelia.io", + "license": "MIT", + "author": "Jeremy Danyow (https:/danyow.net/)", + "repository": { + "type": "git", + "url": "https://github.com/aurelia/validation" + }, + "dependencies": { + "aurelia-binding": "^1.0.1", + "aurelia-metadata": "^1.0.0", + "aurelia-templating": "^1.0.0" + } +} diff --git a/doc/shape-defs.js b/doc/shape-defs.js deleted file mode 100644 index 7dc97bd9..00000000 --- a/doc/shape-defs.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -const path = require('path'); -const fs = require('fs'); -const packageJsonPath = path.resolve(__dirname, '../package.json'); - -try { - const packageName = require(packageJsonPath).name; - const dtsPath = path.resolve(__dirname, `../dist/doc-temp/${packageName}.d.ts`); - let defs = fs.readFileSync(dtsPath).toString(); - - // aggregate external imports - const packages = {}; - const importRegex = /^\s*import\s+\{([^}]+)\}\s*from\s*'([\w|-]+)'/gm; - let importMatch = importRegex.exec(defs); - while (importMatch) { - const packageName = importMatch[2]; - const imports = packages[packageName] || (packages[packageName] = []); - const bindings = importMatch[1].split(',').map(x => x.trim()); - for (let binding of bindings) { - if (imports.indexOf(binding) === -1) { - imports.push(binding); - } - } - importMatch = importRegex.exec(defs); - } - - // remove leading declare module - defs = defs.replace(/^declare module ".*" \{/, ''); - // remove "} declare module {" - defs = defs.replace(/\}\r?\ndeclare module ".*" \{/g, ''); - // remove closing "}" - defs = defs.replace(/\}\r?\n$/, ''); - // remove imports - defs = defs.replace(/^\s+import.*;$/gm, ''); - // remove "export *" - defs = defs.replace(/^\s+export \*.*;$/gm, ''); - - // write imports - for (let packageName in packages) { - if (packages.hasOwnProperty(packageName)) { - const imports = packages[packageName]; - defs = `import {${imports.sort()}} from '${packageName}';\n` + defs; - } - } - - fs.writeFileSync(dtsPath, defs); - console.log(`Shaped the dist/doc-temp/${packageName}.d.ts file.`); -} catch (e) { - console.error(`Unable to shape the .d.ts file.`); - console.error(e.message); -} diff --git a/doc/shape-doc.js b/doc/shape-doc.js deleted file mode 100644 index b210e2ba..00000000 --- a/doc/shape-doc.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; - -const path = require('path'); -const fs = require('fs'); -const packageJsonPath = path.resolve(__dirname, '../package.json'); -const apiJsonPath = path.resolve(__dirname, './api.json'); - -try { - const packageName = require(packageJsonPath).name; - let json = require(apiJsonPath).children[0]; - - json = { - name: packageName, - children: json.children, - groups: json.groups - }; - - const str = JSON.stringify(json) + '\n'; - fs.writeFileSync(apiJsonPath, str); - console.log('Shaped the doc/api.json file.'); -} catch (e) { - console.error('Unable to shape the api.json. The file probably has an incorrect format or doesn\'t exist.'); - console.error(e.message); -} diff --git a/doc/tsconfig.json b/doc/tsconfig.json deleted file mode 100644 index 21202da9..00000000 --- a/doc/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - // this file is here only because typedoc doesn't yet support TypeScript 2.0 - "compilerOptions": { - "module": "commonjs", - "moduleResolution": "node", - "target": "es6", - "outDir": "dist/native-modules", - "noImplicitAny": true, - "noImplicitReturns": true, - "declaration": true, - "forceConsistentCasingInFileNames": true, - "experimentalDecorators": true, - "noEmitHelpers": false - }, - "exclude": [ - "dist", - "build", - "node_modules", - "doc" - ] -} diff --git a/package.json b/package.json index baec13b5..b99a3fbe 100644 --- a/package.json +++ b/package.json @@ -20,17 +20,17 @@ "url": "https://github.com/aurelia/validation" }, "scripts": { - "lint": "cross-env ./node_modules/.bin/tslint --project tsconfig.json", - "pretest": "cross-env npm run lint", - "test": "cross-env ./node_modules/.bin/tsc && cross-env ./node_modules/karma/bin/karma start --single-run", - "test-watch": "concurrently \"./node_modules/.bin/tsc --watch\" \"./node_modules/karma/bin/karma start\"", - "prebuild:compile": "rimraf 'dist/**'", - "build:compile": "concurrently \"node_modules/.bin/tsc --project tsconfig.build.json --outDir dist/amd\" \"./node_modules/.bin/tsc --project tsconfig.build.json --outDir dist/commonjs --module commonjs\" \"./node_modules/.bin/tsc --project tsconfig.build.json --outDir dist/native-modules --module es2015\" \"./node_modules/.bin/tsc --project tsconfig.build.json --outDir dist/system --module system\" \"./node_modules/.bin/tsc --project tsconfig.build.json --outDir dist/es2015 --target es2015 --module es2015\" || true", + "lint": "tslint --project tsconfig.json", + "pretest": "npm run lint", + "test": "tsc && karma start --single-run", + "test-watch": "concurrently \"tsc --watch\" \"karma start\"", + "build:compile": "aurelia-tools ts-build-all --continue-when-failed --clean-before", "build": "npm run build:compile", "postbuild": "npm run build:doc", - "prebuild:doc": "rimraf 'doc/api.json' && rimraf 'dist/doc-temp/**' && cross-env ./node_modules/.bin/tsc --project tsconfig.build.json --outFile dist/doc-temp/aurelia-validation.js && node doc/shape-defs", - "build:doc": "cross-env ./node_modules/.bin/typedoc --json doc/api.json --excludeExternals --includeDeclarations --mode modules --target ES6 --name aurelia-validation-docs --ignoreCompilerErrors --tsconfig doc/tsconfig.json dist/doc-temp/", - "postbuild:doc": "concurrently \"node doc/shape-doc\" \"rimraf 'dist/doc-temp/**'\"" + "prebuild:doc": "aurelia-tools doc-build --continue-when-failed", + "build:doc": "aurelia-tools doc-shape-defs && aurelia-tools typedoc", + "postbuild:doc": "aurelia-tools doc-jsonshape", + "release": "aurelia-tools changelog" }, "jspm": { "registry": "npm", @@ -71,8 +71,8 @@ "aurelia-pal-browser": "^1.0.0", "aurelia-polyfills": "^1.1.0", "aurelia-testing": "^1.0.0-beta.2.0.0", - "concurrently": "^2.2.0", - "cross-env": "^2.0.1", + "aurelia-tools": "^1.0.0", + "concurrently": "^3.1.0", "jasmine-core": "^2.4.1", "karma": "^1.2.0", "karma-chrome-launcher": "^2.0.0", @@ -81,10 +81,8 @@ "karma-requirejs": "^1.0.0", "requirejs": "^2.2.0", "requirejs-text": "^2.0.12", - "rimraf": "^2.5.4", "tslint": "^3.15.1", - "typedoc": "^0.5.0", - "typescript": "^2.0.0" + "typescript": "^2.1.0" }, "aurelia": { "build": { diff --git a/tsconfig.build.json b/tsconfig.build.json index a61c76fa..44d14fa1 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,28 +1,12 @@ -{ - "compilerOptions": { - "module": "amd", - "moduleResolution": "node", - "target": "es5", - "lib": [ - "es2017", - "dom" - ], - "outDir": "dist/amd", - "noImplicitAny": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "declaration": true, - "forceConsistentCasingInFileNames": true, - "experimentalDecorators": true, - "noEmitHelpers": false - }, - "exclude": [ - ".vscode", - "dist", - "doc", - "node_modules", - "test" - ] -} +{ + "extends": "./tsconfig.json", + "exclude": [ + ".vscode", + "dist", + "doc", + "node_modules", + "test", + "build", + "karma.conf.js" + ] +} diff --git a/tsconfig.json b/tsconfig.json index 0948f5a4..33d054e4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,3 @@ -{ - "compilerOptions": { - "module": "amd", - "moduleResolution": "node", - "target": "es5", - "lib": [ - "es2017", - "dom" - ], - "outDir": "dist/test", - "noImplicitAny": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "strictNullChecks": true, - "declaration": true, - "forceConsistentCasingInFileNames": true, - "experimentalDecorators": true, - "noEmitHelpers": false - }, - "exclude": [ - ".vscode", - "dist", - "doc", - "node_modules" - ] -} +{ + "extends": "./node_modules/aurelia-tools/tsc/tsconfig" +}