@docupace/pipeline 1.0.0-alpha.0 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/next/changeset.sh
CHANGED
|
@@ -8,6 +8,8 @@ DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
8
8
|
validate_changesets() {
|
|
9
9
|
if [ ! -z "$PR_ID" ]; then
|
|
10
10
|
echo "🔍 Validating changesets..."
|
|
11
|
+
echo "Current Dir $DIR"
|
|
12
|
+
echo "1=$1"
|
|
11
13
|
pnpm node $DIR/validateChangeset.cjs $1 || {
|
|
12
14
|
if [ $? -eq 1 ]; then
|
|
13
15
|
echo "❌ No changeset found. Please add a changeset to this PR. Please see more information at https://docupacellc.atlassian.net/wiki/spaces/PM/pages/1350893571/Creating+changesets+for+Docupace+Next"
|
package/package.json
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docupace/pipeline",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"
|
|
6
|
+
"bin": {
|
|
7
|
+
"dp-changeset-cli": "src/changeset/cli.jschmod +x cli.js\n"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"bash"
|
|
11
|
+
],
|
|
7
12
|
"author": "",
|
|
8
13
|
"license": "ISC",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"commander": "^12.1.0",
|
|
16
|
+
"zx": "^8.2.4"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"esbuild": "^0.24.0"
|
|
11
20
|
}
|
|
12
21
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { $ } from 'zx';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import {validateChangesets} from "./validate";
|
|
6
|
+
|
|
7
|
+
const program = new Command();
|
|
8
|
+
const DIR = path.resolve(process.cwd());
|
|
9
|
+
|
|
10
|
+
// Helper function to set Git info
|
|
11
|
+
async function setGitInfo() {
|
|
12
|
+
await $`git config --global user.email "gitops@docupace.com"`;
|
|
13
|
+
await $`git config --global user.name "Gitops"`;
|
|
14
|
+
await $`git remote set-url origin https://x-token-auth:${process.env.BITBUCKET_TOKEN}@bitbucket.org/dp-cloud/docupace-graphql-server.git`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Command: validate
|
|
18
|
+
program
|
|
19
|
+
.command('validate <path>')
|
|
20
|
+
.description('Validate changesets for the provided PR ID')
|
|
21
|
+
.action(async (path) => {
|
|
22
|
+
console.log('🔍 Validating changesets...');
|
|
23
|
+
try {
|
|
24
|
+
await validateChangesets(path);
|
|
25
|
+
console.log('✅ Changeset validation passed.');
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error(
|
|
28
|
+
'❌ No changeset found. Please add a changeset to this PR. Please see more information at https://docupacellc.atlassian.net/wiki/spaces/PM/pages/1350893571/Creating+changesets+for+Docupace+Next'
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Command: version
|
|
35
|
+
program
|
|
36
|
+
.command('version')
|
|
37
|
+
.description('Run Changeset versioning')
|
|
38
|
+
.action(async () => {
|
|
39
|
+
console.log('📦 Running Changeset versioning...');
|
|
40
|
+
await setGitInfo();
|
|
41
|
+
await $`pnpm changeset version`;
|
|
42
|
+
console.log('✅ Changeset versioning complete.');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Command: commit-and-tag
|
|
46
|
+
program
|
|
47
|
+
.command('commit-and-tag')
|
|
48
|
+
.description('Commit and tag the new version')
|
|
49
|
+
.action(async () => {
|
|
50
|
+
console.log('📌 Committing and tagging the new version...');
|
|
51
|
+
await setGitInfo();
|
|
52
|
+
await $`git add .`;
|
|
53
|
+
await $`git commit -m "chore: version bump and changelog"`;
|
|
54
|
+
await $`git push origin`;
|
|
55
|
+
const newVersion = (await $`node -p "require('./package.json').version"`).stdout.trim();
|
|
56
|
+
await $`git tag v${newVersion}`;
|
|
57
|
+
await $`git push origin --tags`;
|
|
58
|
+
console.log(`✅ Version ${newVersion} tagged and pushed.`);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Command: all
|
|
62
|
+
program
|
|
63
|
+
.command('all')
|
|
64
|
+
.description('Run versioning and commit-and-tag in sequence')
|
|
65
|
+
.action(async () => {
|
|
66
|
+
console.log('📦 Running all steps...');
|
|
67
|
+
await program.commands.find((cmd) => cmd.name() === 'version').action();
|
|
68
|
+
await program.commands.find((cmd) => cmd.name() === 'commit-and-tag').action();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Parse arguments
|
|
72
|
+
program.parse(process.argv);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
export async function validateChangesets(directoryPath) {
|
|
5
|
+
try {
|
|
6
|
+
// Step 1: Read the directory for md files excluding README.md
|
|
7
|
+
const allFiles = fs.readdirSync(directoryPath);
|
|
8
|
+
const mdFiles = allFiles.filter(file => file.endsWith('.md') && file !== 'README.md');
|
|
9
|
+
|
|
10
|
+
// Step 2: Check for pre.json and parse it
|
|
11
|
+
const preJsonPath = path.join(directoryPath, 'pre.json');
|
|
12
|
+
let preJson;
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(preJsonPath) && mdFiles.length === 0) {
|
|
15
|
+
console.error("Error: No pre.json and no md files found.");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (fs.existsSync(preJsonPath)) {
|
|
20
|
+
preJson = JSON.parse(fs.readFileSync(preJsonPath, 'utf-8'));
|
|
21
|
+
|
|
22
|
+
if(preJson.mode == 'pre') {
|
|
23
|
+
// Step 4a: Get list of changesets from pre.json
|
|
24
|
+
const changesets = preJson.changesets || [];
|
|
25
|
+
const changesetNames = changesets.map(change => change);
|
|
26
|
+
|
|
27
|
+
// Step 4b: Match files with the list of changesets
|
|
28
|
+
const mdFileNamesWithoutExt = mdFiles.map(file => path.basename(file, '.md'));
|
|
29
|
+
const unmatchedFiles = mdFileNamesWithoutExt.filter(fileName => !changesetNames.includes(fileName));
|
|
30
|
+
|
|
31
|
+
if (unmatchedFiles.length == 0) {
|
|
32
|
+
console.error("No new MD files found:", unmatchedFiles);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log("Validation successful.");
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("Error while processing:", error);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|