chore(build): update build scripts

This commit is contained in:
Adam Bradley
2018-03-02 23:57:52 -06:00
parent 7c935e3d84
commit afd89e77e4
8 changed files with 203 additions and 1045 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@@ -20,11 +20,12 @@
},
"scripts": {
"build": "npm run clean && npm run compile && npm run clean-generated",
"clean": "rm -rf dist",
"clean-generated": "node ./scripts/clean.js",
"clean": "node scripts/clean.js",
"clean-generated": "node ./scripts/clean-generated.js",
"compile": "./node_modules/.bin/ngc",
"deploy": "npm run build && np --any-branch",
"deploy": "node scripts/deploy.js",
"lint": "tslint --project .",
"prepare.deploy": "node scripts/deploy.js --prepare",
"tsc": "tsc -p ."
},
"main": "./dist/index.js",
@@ -43,10 +44,15 @@
"@angular/platform-browser-dynamic": "latest",
"@angular/router": "latest",
"@ionic/core": "next",
"chalk": "^2.3.2",
"execa": "^0.9.0",
"fs-extra": "^5.0.0",
"glob": "7.1.2",
"np": "^2.20.1",
"inquirer": "^5.1.0",
"listr": "^0.13.0",
"rimraf": "^2.6.2",
"rxjs": "5.5.2",
"semver": "^5.5.0",
"tslint": "^5.8.0",
"tslint-ionic-rules": "0.0.13",
"typescript": "latest",

View File

@@ -1,9 +1,7 @@
# Deploy
## To Build
1. run `npm run build` to build a distro to `dist`
## Publishing
1. Run `npm run deploy`
2. Commit and push any outstanding changes
1. `npm run prepare.deploy`
2. Review/update changelog
3. Commit updates using the package name and version number as the commit message.
4. `npm run deploy`
5. :tada:

View File

@@ -0,0 +1,54 @@
const path = require('path');
const cwd = process.cwd();
const glob = require('glob');
const rimRaf = require('rimraf');
const distDir = path.join(cwd, 'dist');
const distGeneratedNodeModules = path.join(distDir, 'node_modules');
function rimRafAsync(dir) {
return new Promise((resolve, reject) => {
rimRaf(dir, {}, err => {
if (err) {
return reject(err);
}
resolve();
})
});
}
function doGlob(globString) {
return new Promise((resolve, reject) => {
glob(globString, (err, matches) => {
if (err) {
return reject(err);
}
resolve(matches);
})
});
}
function getCodegenedFilesToDelete() {
const ngFactoryGlob = path.join(distDir, '**', '*ngfactory*');
const ngSummaryGlob = path.join(distDir, '**', '*ngsummary*');
const promises = [];
promises.push(doGlob(ngFactoryGlob));
promises.push(doGlob(ngSummaryGlob));
return Promise.all(promises).then(listOfGlobResults => {
const deleteFilePromises = [];
listOfGlobResults.forEach(fileMatches => {
fileMatches.forEach(filePath => {
deleteFilePromises.push(rimRafAsync(filePath));
})
})
return Promise.all(deleteFilePromises);
});
}
const taskPromises = [];
taskPromises.push(getCodegenedFilesToDelete());
taskPromises.push(rimRafAsync(distGeneratedNodeModules));
return Promise.all(taskPromises);

View File

@@ -1,54 +1,12 @@
const fs = require('fs-extra');
const path = require('path');
const cwd = process.cwd();
const glob = require('glob');
const rimRaf = require('rimraf');
const distDir = path.join(cwd, 'dist');
const cleanDirs = [
'dist'
];
const distGeneratedNodeModules = path.join(distDir, 'node_modules');
function rimRafAsync(dir) {
return new Promise((resolve, reject) => {
rimRaf(dir, {}, err => {
if (err) {
return reject(err);
}
resolve();
})
});
}
function doGlob(globString) {
return new Promise((resolve, reject) => {
glob(globString, (err, matches) => {
if (err) {
return reject(err);
}
resolve(matches);
})
});
}
function getCodegenedFilesToDelete() {
const ngFactoryGlob = path.join(distDir, '**', '*ngfactory*');
const ngSummaryGlob = path.join(distDir, '**', '*ngsummary*');
const promises = [];
promises.push(doGlob(ngFactoryGlob));
promises.push(doGlob(ngSummaryGlob));
return Promise.all(promises).then(listOfGlobResults => {
const deleteFilePromises = [];
listOfGlobResults.forEach(fileMatches => {
fileMatches.forEach(filePath => {
deleteFilePromises.push(rimRafAsync(filePath));
})
})
return Promise.all(deleteFilePromises);
});
}
const taskPromises = [];
taskPromises.push(getCodegenedFilesToDelete());
taskPromises.push(rimRafAsync(distGeneratedNodeModules));
return Promise.all(taskPromises);
cleanDirs.forEach(dir => {
const cleanDir = path.join(__dirname, '../', dir);
fs.removeSync(cleanDir);
});

View File

@@ -41,7 +41,7 @@
"scripts": {
"build": "npm run clean && stencil build --docs",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"clean": "rm -rf dist",
"clean": "node scripts/clean.js",
"deploy": "node scripts/deploy.js",
"dev": "sd concurrent \"stencil build --dev --watch --docs\" \"stencil-dev-server\"",
"devapp": "sd concurrent \"stencil build --dev --watch --docs\" \"stencil-dev-server --broadcast\"",

View File

@@ -0,0 +1,12 @@
const fs = require('fs-extra');
const path = require('path');
const cleanDirs = [
'dist'
];
cleanDirs.forEach(dir => {
const cleanDir = path.join(__dirname, '../', dir);
fs.removeSync(cleanDir);
});

View File

@@ -2,6 +2,6 @@
1. `npm run prepare.deploy`
2. Review/update changelog
3. Commit updates using the version number as the commit message.
3. Commit updates using the package name and version number as the commit message.
4. `npm run deploy`
5. :tada: