Skip to content

Commit ca08349

Browse files
authored
Cleanup publish script and deploy message (#88)
* Build docs * Update deploy message and publish script * update publish file * add done
1 parent a245c44 commit ca08349

File tree

5 files changed

+45
-18
lines changed

5 files changed

+45
-18
lines changed

DEPLOY.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
## Deployment steps
22

33
1. Get latest master
4-
2. Run `npm run p -- [major|minor|patch] {message}`.
5-
3. Checkout to a new branch `release/{new-version-name}` eg `release/4.0.1`
6-
4. Create a tag `git tag -a v {version-no} -m "{message}"` eg `git tag -a v4.0.1 -m "Added peer dep for ng 16" `
7-
5. Commit with message `v{version-no}` eg `v4.0.1`
8-
6. Push and create PR
4+
2. Checkout to a new branch `release/{new-version-name}` eg `release/4.0.1`
5+
3. Update `CHANGELOG.md` in root with all the latest changes
6+
4. Run `npm run p -- [major|minor|patch] {message}`.
7+
5. Create a tag `git tag -a v {version-no} -m "{message}"` eg `git tag -a v4.0.1 -m "Added peer dep for ng 16" `
8+
6. Commit with message `v{version-no}` e.g. `v4.0.1`
9+
7. Push and create PR

docs/main.28d998312ca8da0c.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/polyfills.9b1da08871d804f0.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/runtime.a6644970e2bce4c8.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/publish.js

+36-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const readline = require('readline').createInterface({
99
const args = process.argv.slice(2)
1010

1111
const version = validateVersion(args)
12+
const useForce = shouldUseForce(args)
1213
if (!version) {
1314
console.log(`Please specify a valid version
1415
Usage: npm run p -- [major|minor|patch] {message?}
@@ -17,29 +18,46 @@ const readline = require('readline').createInterface({
1718
}
1819
console.log(`Publishing version: ${version.toUpperCase()}`)
1920

20-
const hasChangelog = await validateChangeLog()
21-
if (!hasChangelog) {
22-
console.log("Please update the changelog")
21+
try {
22+
await validateChangeLog(useForce)
23+
console.log("CHANGELOG update validated")
24+
} catch (error) {
25+
console.log(error)
2326
process.exit(1);
2427
}
2528

2629
runNpmVersionPatch(version, args)
2730
console.log(execSync(`npm run build`).toString())
2831
console.log(execSync(`cd dist/angular4-paystack && npm publish`).toString())
32+
console.log(execSync(`cd ../..`).toString())
33+
process.exit(0);
2934
})()
3035

3136

32-
function validateChangeLog() {
33-
return new Promise((resolve) => {
34-
readline.question('HAS CHANGELOG BEEN UPDATED?\n', response => {
35-
if (response.toLocaleLowerCase() === "yes" || response.toLocaleLowerCase() === "y") {
36-
readline.close()
37-
resolve(true)
38-
} else {
39-
readline.close()
40-
resolve(false)
37+
function validateChangeLog(force = false) {
38+
const modifiedFiles = execSync("git ls-files --modified");
39+
const filesList = modifiedFiles.toString().split("\n");
40+
return new Promise((resolve, reject) => {
41+
if (force) {
42+
readline.question('HAS CHANGELOG BEEN UPDATED?\n', response => {
43+
if (response.toLocaleLowerCase() === "yes" || response.toLocaleLowerCase() === "y") {
44+
readline.close()
45+
resolve(true)
46+
} else {
47+
readline.close()
48+
reject("Please update the changelog")
49+
}
50+
});
51+
} else {
52+
if (filesList?.includes("projects/angular4-paystack/CHANGELOG.md")) {
53+
reject("Only CHANGELOG.md in root should be modified.")
4154
}
42-
});
55+
if (filesList?.includes("CHANGELOG.md")) {
56+
resolve(true);
57+
return;
58+
}
59+
reject("CHANGELOG.md not modified. Please update the changelog before publishing.");
60+
}
4361
})
4462
}
4563

@@ -58,3 +76,8 @@ function runNpmVersionPatch(version, args) {
5876
`cd projects/angular4-paystack && npm version ${version}${message ? ` -m "${message}"` : ""}`);
5977
console.log(returnMessage.toString())
6078
}
79+
80+
function shouldUseForce(args) {
81+
return args.includes("-f") || args.includes("--force")
82+
}
83+

0 commit comments

Comments
 (0)