Skip to content

Commit

Permalink
Cleanup publish script and deploy message (#88)
Browse files Browse the repository at this point in the history
* Build docs

* Update deploy message and publish script

* update publish file

* add done
  • Loading branch information
ashinzekene authored Mar 2, 2024
1 parent a245c44 commit ca08349
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
11 changes: 6 additions & 5 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## Deployment steps

1. Get latest master
2. Run `npm run p -- [major|minor|patch] {message}`.
3. Checkout to a new branch `release/{new-version-name}` eg `release/4.0.1`
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" `
5. Commit with message `v{version-no}` eg `v4.0.1`
6. Push and create PR
2. Checkout to a new branch `release/{new-version-name}` eg `release/4.0.1`
3. Update `CHANGELOG.md` in root with all the latest changes
4. Run `npm run p -- [major|minor|patch] {message}`.
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" `
6. Commit with message `v{version-no}` e.g. `v4.0.1`
7. Push and create PR
1 change: 1 addition & 0 deletions docs/main.28d998312ca8da0c.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/polyfills.9b1da08871d804f0.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/runtime.a6644970e2bce4c8.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 36 additions & 13 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const readline = require('readline').createInterface({
const args = process.argv.slice(2)

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

const hasChangelog = await validateChangeLog()
if (!hasChangelog) {
console.log("Please update the changelog")
try {
await validateChangeLog(useForce)
console.log("CHANGELOG update validated")
} catch (error) {
console.log(error)
process.exit(1);
}

runNpmVersionPatch(version, args)
console.log(execSync(`npm run build`).toString())
console.log(execSync(`cd dist/angular4-paystack && npm publish`).toString())
console.log(execSync(`cd ../..`).toString())
process.exit(0);
})()


function validateChangeLog() {
return new Promise((resolve) => {
readline.question('HAS CHANGELOG BEEN UPDATED?\n', response => {
if (response.toLocaleLowerCase() === "yes" || response.toLocaleLowerCase() === "y") {
readline.close()
resolve(true)
} else {
readline.close()
resolve(false)
function validateChangeLog(force = false) {
const modifiedFiles = execSync("git ls-files --modified");
const filesList = modifiedFiles.toString().split("\n");
return new Promise((resolve, reject) => {
if (force) {
readline.question('HAS CHANGELOG BEEN UPDATED?\n', response => {
if (response.toLocaleLowerCase() === "yes" || response.toLocaleLowerCase() === "y") {
readline.close()
resolve(true)
} else {
readline.close()
reject("Please update the changelog")
}
});
} else {
if (filesList?.includes("projects/angular4-paystack/CHANGELOG.md")) {
reject("Only CHANGELOG.md in root should be modified.")
}
});
if (filesList?.includes("CHANGELOG.md")) {
resolve(true);
return;
}
reject("CHANGELOG.md not modified. Please update the changelog before publishing.");
}
})
}

Expand All @@ -58,3 +76,8 @@ function runNpmVersionPatch(version, args) {
`cd projects/angular4-paystack && npm version ${version}${message ? ` -m "${message}"` : ""}`);
console.log(returnMessage.toString())
}

function shouldUseForce(args) {
return args.includes("-f") || args.includes("--force")
}

0 comments on commit ca08349

Please sign in to comment.