Skip to content

Commit

Permalink
feat(scripts): add git commit child process to publish script #2346
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-erim committed Dec 10, 2019
1 parent f2d19b2 commit 55b23b2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
5 changes: 1 addition & 4 deletions npm/lerna.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"version": "1.1.0",
"packages": [
"ng-packs/dist/*",
"packs/*"
],
"packages": ["packs/*"],
"npmClient": "yarn",
"lerna": "3.18.4"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion npm/ng-packs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"commit": "git-cz",
"lint": "ng lint",
"scripts:build": "cd scripts && npm install && yarn build",
"prepare:workspace": "yarn scripts:build --noCommit",
"prepare:workspace": "yarn scripts:build",
"ci": "yarn prepare:workspace && yarn ci:test && yarn ng lint",
"ci:test": "ng test --coverage=false",
"lerna": "lerna"
Expand Down
6 changes: 0 additions & 6 deletions npm/ng-packs/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import fse from 'fs-extra';
import program from 'commander';

(async () => {
program.option('-c, --noCommit', 'skip commit process', false);
program.option('-i, --noInstall', 'skip updating package.json and installation', false);

program.parse(process.argv);
Expand Down Expand Up @@ -59,10 +58,5 @@ import program from 'commander';
process.exit(1);
}

if (!program.noCommit) {
await execa('git', ['add', '../dist/*', '../package.json'], { stdout: 'inherit' });
await execa('git', ['commit', '-m', 'Build ng packages', '--no-verify'], { stdout: 'inherit' });
}

process.exit(0);
})();
2 changes: 1 addition & 1 deletion npm/ng-packs/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"modules": "[build.js, sync.js]",
"scripts": {
"build": "node -r esm build.js",
"publish": "node -r esm publish.js",
"publish-packages": "node -r esm publish.js",
"install-new-dependencies": "node -r esm install-new-dependencies.js",
"sync": "node -r esm sync.js",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
13 changes: 10 additions & 3 deletions npm/ng-packs/scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ if (versions.indexOf(nextSemanticVersion) < 0) {

await execa('yarn', ['build', '--noInstall'], { stdout: 'inherit' });

await fse.rename('../lerna.exec.json', '../lerna.json');
await fse.rename('../lerna.publish.json', '../lerna.json');

await execa('yarn', ['lerna', 'exec', '--', 'npm', 'publish'], {
await execa('yarn', ['lerna', 'exec', '--', '"npm publish"'], {
stdout: 'inherit',
cwd: '../',
});

await fse.rename('../lerna.json', '../lerna.exec.json');
await fse.rename('../lerna.json', '../lerna.publish.json');

await execa('git', ['add', '../packages/*', '../package.json', '../lerna.version.json'], {
stdout: 'inherit',
});
await execa('git', ['commit', '-m', 'Upgrade ng package versions', '--no-verify'], {
stdout: 'inherit',
});
} catch (error) {
console.error(error.stderr);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion npm/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
& npm run build
& cd ../../
& yarn
& yarn lerna publish patch --no-push --yes --no-git-reset --no-commit-hooks --no-git-tag-version
& yarn lerna publish patch --no-push --yes --no-git-reset --no-commit-hooks --no-git-tag-version --force-publish
& cd ng-packs\scripts
& npm run sync
& cd ../../
Expand Down

0 comments on commit 55b23b2

Please sign in to comment.