@docupace/pipeline 1.0.0-alpha.28 → 1.0.0-alpha.3

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.
@@ -1,7 +1,5 @@
1
1
  #!/bin/bash
2
2
  # bin/next-changeset-validate
3
3
 
4
- DIR="$(cd "$(dirname "$0")" && pwd)/../@docupace/pipeline"
5
-
6
4
  # Pass all arguments to the actual script
7
- bash $DIR/next/changeset.sh validate $2
5
+ bash ./next/changeset.sh validate "$@"
package/next/changeset.sh CHANGED
@@ -8,8 +8,6 @@ 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"
13
11
  pnpm node $DIR/validateChangeset.cjs $1 || {
14
12
  if [ $? -eq 1 ]; then
15
13
  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"
@@ -1,7 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
-
5
4
  const directoryPath = process.argv[2];
6
5
 
7
6
  try {
package/package.json CHANGED
@@ -1,22 +1,17 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.0-alpha.28",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
- "type": "module",
7
6
  "bin": {
8
- "dp-changeset-cli": "src/changeset/cli.js"
7
+ "next-changeset-validate": "./bin/next-changeset-validate.sh"
9
8
  },
10
9
  "keywords": [
11
10
  "bash"
12
11
  ],
13
12
  "author": "",
14
13
  "license": "ISC",
15
- "dependencies": {
16
- "commander": "^12.1.0",
17
- "zx": "^8.2.4"
18
- },
19
- "devDependencies": {
20
- "esbuild": "^0.24.0"
14
+ "scripts": {
15
+ "next-changeset-validate": "bash next/changeset.sh validate"
21
16
  }
22
17
  }
@@ -1,121 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- import { $ } from 'zx';
4
- import path from 'path';
5
- import {validateChangesets} from "./validate.js";
6
- import fs from 'fs';
7
-
8
- const program = new Command();
9
- const args = process.argv.slice(1);
10
-
11
- const DIR = path.resolve(process.cwd());
12
-
13
- // Helper function to set Git info
14
- async function setGitInfo() {
15
- await $`git config --global user.email "gitops@docupace.com"`;
16
- await $`git config --global user.name "Gitops"`;
17
- console.log('token: ' + process.env.THIS_REP_TOKEN);
18
- await $`git remote set-url origin https://x-token-auth:${process.env.THIS_REP_TOKEN}@bitbucket.org/dp-cloud/docupace-graphql-server.git`;
19
- }
20
-
21
- const changeSetPackage = `{
22
- "name": "changeset-package",
23
- "version": "1.0.0",
24
- "description": "",
25
- "scripts": {
26
- },
27
- "type": "module",
28
- "keywords": [],
29
- "author": "",
30
- "license": "ISC",
31
- "dependencies": {},
32
- "devDependencies": {
33
- "@changesets/cli": "^2.27.10"
34
- }
35
- }
36
- `
37
-
38
- const nodeDocker = `
39
- # Use a Node.js base image
40
- FROM node:18
41
-
42
- # Set the working directory inside the container
43
- WORKDIR /app
44
-
45
- # Install pnpm globally
46
- RUN npm install -g pnpm
47
-
48
- # Default command (can be overridden in the docker run command)
49
- CMD ["node"]
50
- `
51
-
52
- async function versionCommand() {
53
- console.log('📦 Running Changeset versioning...');
54
- await setGitInfo();
55
- await $`mv package.json package.json.bak`
56
- await $`mv pnpm-lock.yaml pnpm-lock.yaml.bak`
57
- await fs.promises.writeFile('package.json', changeSetPackage);
58
- await $`pnpm install`;
59
- await $`rm package.json pnpm-lock.yaml`
60
- await $`mv package.json.bak package.json`
61
- await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`
62
- await $`pnpm changeset version`;
63
- console.log('✅ Changeset versioning complete.');
64
- }
65
-
66
- async function commitTagCommand() {
67
- console.log('📌 Committing and tagging the new version...');
68
- await setGitInfo();
69
- await $`git add .`;
70
- await $`git commit -m "chore: version bump and changelog"`;
71
- await $`git push origin`;
72
- const newVersion = (await $`node -p "require('./package.json').version"`).stdout.trim();
73
- await $`git tag v${newVersion}`;
74
- await $`git push origin --tags`;
75
- console.log(`✅ Version ${newVersion} tagged and pushed.`);
76
- }
77
-
78
- // Command: validate
79
- program
80
- .command('validate <path>')
81
- .description('Validate changesets for the provided PR ID')
82
- .action(async (path) => {
83
- console.log('🔍 Validating changesets...');
84
- try {
85
- await validateChangesets(path);
86
- console.log('✅ Changeset validation passed.');
87
- } catch (error) {
88
- console.error(
89
- '❌ 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'
90
- );
91
- process.exit(1);
92
- }
93
- });
94
- // Command: version
95
- program
96
- .command('version')
97
- .description('Run Changeset versioning')
98
- .action(async () => {
99
- await versionCommand();
100
- });
101
-
102
- // Command: commit-and-tag
103
- program
104
- .command('commit-tag')
105
- .description('Commit and tag the new version')
106
- .action(async () => {
107
- await commitTagCommand();
108
- });
109
-
110
- // Command: all
111
- program
112
- .command('version-commit-tag')
113
- .description('Run versioning and commit-and-tag in sequence')
114
- .action(async () => {
115
- console.log('📦 Running all steps...');
116
- await versionCommand();
117
- await commitTagCommand();
118
- });
119
-
120
- // Parse arguments
121
- program.parse(args);
@@ -1,46 +0,0 @@
1
- import fs from 'fs';
2
- import path from '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
-