@docupace/pipeline 1.0.111 → 1.0.113-test

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@docupace/pipeline": patch
3
+ ---
4
+
5
+ feat: sync image tag to eks-migration branch after deploy
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @docupace/pipeline
2
2
 
3
+ ## 1.0.112
4
+
5
+ ### Patch Changes
6
+
7
+ - 30d5209: Added to install latest
8
+ - 664ac05: Fix to build
9
+ - e738539: Add deploy for specific version from pipeline
10
+
3
11
  ## 1.0.111
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -48,8 +48,15 @@ dp-next-cli [command] [options]
48
48
  - `-t, --to-env <toEnv>`: Target environment
49
49
  - `-F, --from-site <fromSite>`: Source site
50
50
  - `-T, --to-site <toSite>`: Target site
51
+ - `-j, --jira-ticket [jiraTicket]`: JIRA ticket (optional)
51
52
  - `-c, --deploy-core <deployCore>`: Deploy Core (default: "false")
52
53
  - `-C, --deploy-connect <deployConnect>`: Deploy Connect (default: "false")
54
+ - `update-site-version <env> <site>`: Update specific version components for a site
55
+ - `-u, --ui-version <uiVersion>`: UI image tag
56
+ - `-g, --graph-version <graphVersion>`: GraphQL-server image tag
57
+ - `-S, --standard-config <standardConfig>`: Standard config remote branch
58
+ - `-s, --site-config <siteConfig>`: Site config remote branch
59
+ - `-j, --jira-ticket [jiraTicket]`: JIRA ticket (required for prod)
53
60
  - `deploy-template`: Deploy an application for a specific site
54
61
  - `deploy-app <application>`: Deploy an application for a specific site
55
62
  - `deploy-core <env> <site>`: Deploy Core
@@ -16,7 +16,7 @@ definitions:
16
16
  - npm config set //registry.npmjs.org/:_authToken $DOCUPACE_NPM_TOKEN
17
17
  - pnpm install --frozen-lockfile
18
18
  - export HOME=/tmp
19
- - node src/changeset/cli.js version-commit-tag --ignore-install-error
19
+ - node src/changeset/cli.js version-commit-tag --install-latest
20
20
 
21
21
  pipelines:
22
22
  pull-requests:
package/package.json CHANGED
@@ -1,9 +1,18 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.111",
3
+ "version": "1.0.113-test",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "scripts": {
8
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --testPathIgnorePatterns='src/next/test\\.js'",
9
+ "test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
10
+ "test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true",
11
+ "test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
12
+ "test-validate": "dp-changset-cli validate",
13
+ "test-create": "dp-changset-cli create-changeset",
14
+ "lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\""
15
+ },
7
16
  "exports": {
8
17
  "./changelogCanny": "./src/changeset/changelog-module.cjs"
9
18
  },
@@ -49,14 +58,5 @@
49
58
  "globals": "^15.14.0",
50
59
  "jest": "^30.1.3",
51
60
  "prettier": "^3.4.2"
52
- },
53
- "scripts": {
54
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --testPathIgnorePatterns='src/next/test\\.js'",
55
- "test-deploy-core": "dp-next-cli deploy-core-pipeline dev template",
56
- "test-deploy-from-site": "dp-next-cli deploy-from-site --from-env dev --to-env dev --from-site financialdev --to-site template --deploy-core true",
57
- "test-run-pipline": "dp-next-cli run-pipeline -r docupace-next-e2e -b master -p run-tests-qa",
58
- "test-validate": "dp-changset-cli validate",
59
- "test-create": "dp-changset-cli create-changeset",
60
- "lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx}\""
61
61
  }
62
- }
62
+ }
package/src/auth0/cli.js CHANGED
File without changes
@@ -149,12 +149,12 @@ program
149
149
  .command('version-commit-tag')
150
150
  .description('Run versioning and commit-and-tag in sequence')
151
151
  .option(
152
- '--ignore-install-error',
153
- 'Ignore errors from pnpm install and return early',
152
+ '--install-latest',
153
+ 'Install the latest version of @docupace/pipeline instead of the current version',
154
154
  )
155
155
  .action(async (options) => {
156
156
  console.log('📦 Running all steps...');
157
- const releases = await versionCommand(false, options.ignoreInstallError);
157
+ const releases = await versionCommand(false, options.installLatest);
158
158
  await updateJiraWithVersion(releases);
159
159
  await updateWikiWithVersion(releases);
160
160
  await commitTagCommand(releases);
@@ -15,7 +15,7 @@ const getPackageVersion = () => {
15
15
  return packageJson.version;
16
16
  };
17
17
 
18
- const changeSetPackage = `{
18
+ const getChangeSetPackage = (installLatest = false) => `{
19
19
  "name": "changeset-package",
20
20
  "version": "1.0.0",
21
21
  "description": "",
@@ -28,7 +28,7 @@ const changeSetPackage = `{
28
28
  "dependencies": {},
29
29
  "devDependencies": {
30
30
  "@changesets/cli": "^2.27.10",
31
- "@docupace/pipeline": "${getPackageVersion()}"
31
+ "@docupace/pipeline": "${installLatest ? 'latest' : getPackageVersion()}"
32
32
  }
33
33
  }
34
34
  `;
@@ -67,29 +67,19 @@ export async function versionStatus(sinceBranch) {
67
67
 
68
68
  export async function versionCommand(
69
69
  closeVersion = false,
70
- ignoreInstallError = false,
70
+ installLatest = false,
71
71
  ) {
72
72
  console.log('📦 Running Changeset versioning...');
73
73
  if (!process.env.IS_DEV) {
74
74
  await setGitInfo();
75
75
  await $`mv package.json package.json.bak`;
76
76
  await $`mv pnpm-lock.yaml pnpm-lock.yaml.bak`;
77
- await fs.promises.writeFile('package.json', changeSetPackage);
77
+ await fs.promises.writeFile(
78
+ 'package.json',
79
+ getChangeSetPackage(installLatest),
80
+ );
78
81
  await $`npm config set //registry.npmjs.org/:_authToken ${process.env.DOCUPACE_NPM_TOKEN}`;
79
- try {
80
- await $`pnpm install`;
81
- } catch (error) {
82
- if (ignoreInstallError) {
83
- console.log(
84
- `⚠️ pnpm install failed: ${error.message}. Ignoring error and returning.`,
85
- );
86
- await $`rm -f package.json pnpm-lock.yaml`;
87
- await $`mv package.json.bak package.json`;
88
- await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`;
89
- return [];
90
- }
91
- throw error;
92
- }
82
+ await $`pnpm install`;
93
83
  await $`rm package.json pnpm-lock.yaml`;
94
84
  await $`mv package.json.bak package.json`;
95
85
  await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`;
package/src/merge/cli.js CHANGED
File without changes
package/src/micro/cli.js CHANGED
File without changes
package/src/next/cli.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  deployTemplate,
11
11
  getDefaultDeploySite,
12
12
  getDeployTag,
13
+ updateSiteVersion,
13
14
  } from './deploy.js';
14
15
  import { copy2 } from './copy.js';
15
16
  import { vaultAddSiteData } from './vault.js';
@@ -113,6 +114,31 @@ program
113
114
  );
114
115
  });
115
116
 
117
+ program
118
+ .command('update-site-version <env> <site>')
119
+ .description('Update specific version components for a site')
120
+ .option('-u, --ui-version <uiVersion>', 'UI image tag')
121
+ .option('-g, --graph-version <graphVersion>', 'Graphql-server image tag')
122
+ .option(
123
+ '-S, --standard-config <standardConfig>',
124
+ 'Standard config remote branch',
125
+ )
126
+ .option('-s, --site-config <siteConfig>', 'Site config remote branch')
127
+ .option('-j, --jira-ticket [jiraTicket]', 'JIRA ticket (required for prod)')
128
+ .action(async (env, site, options) => {
129
+ const { uiVersion, graphVersion, standardConfig, siteConfig, jiraTicket } =
130
+ options;
131
+ await updateSiteVersion(
132
+ env,
133
+ site,
134
+ uiVersion,
135
+ graphVersion,
136
+ standardConfig,
137
+ siteConfig,
138
+ jiraTicket,
139
+ );
140
+ });
141
+
116
142
  program
117
143
  .command('deploy-template [tagPrefix]')
118
144
  .description('Deploy an standard configuration for configured sites')
@@ -136,7 +136,7 @@ export async function cloneEnvRepository(env) {
136
136
  const repoUrl = getRepUrl(repoName);
137
137
  console.log(`Cloning repository: ${repoName}`);
138
138
  await cleanUpRepoPath(repoPath);
139
- await $`git clone --depth 1 ${repoUrl}`;
139
+ await $`git clone --no-single-branch --depth 10 ${repoUrl}`;
140
140
  console.log(`Repository cloned to: ${repoPath}`);
141
141
  return repoPath;
142
142
  }
@@ -239,7 +239,7 @@ export function setTag(deployConfig, tag) {
239
239
  * @param {object} deployConfig - The updated YAML data.
240
240
  */
241
241
 
242
- export async function pushDeployConfig(repoPath, commitMessage) {
242
+ export async function pushDeployConfig(repoPath, commitMessage, env) {
243
243
  console.log('📌 Checking for updates to commit...');
244
244
  // Check if there are any changes to commit
245
245
  const status = (
@@ -273,11 +273,63 @@ export async function pushDeployConfig(repoPath, commitMessage) {
273
273
  await $`cd ${repoPath} && git push`;
274
274
  console.log('Changes pushed to the remote repository.');
275
275
 
276
+ await syncTagToMigrationBranch(repoPath, commitMessage, env);
277
+
276
278
  console.log('🧹 Cleaning up...');
277
279
  await $`rm -rf ${repoPath}`;
278
280
  console.log('Cleanup complete.');
279
281
  }
280
282
 
283
+ async function syncTagToMigrationBranch(repoPath, commitMessage, env) {
284
+ const migrationBranch = `eks-migration-${env}`;
285
+ try {
286
+ const branchExists = (
287
+ await $`cd ${repoPath} && git branch -r --list origin/${migrationBranch}`
288
+ ).stdout.trim();
289
+ if (!branchExists) return;
290
+
291
+ const changedFiles = (
292
+ await $`cd ${repoPath} && git diff --name-only HEAD~1 HEAD`
293
+ ).stdout
294
+ .trim()
295
+ .split('\n')
296
+ .filter(Boolean);
297
+
298
+ await $`cd ${repoPath} && git checkout ${migrationBranch}`;
299
+
300
+ let updated = false;
301
+ for (const file of changedFiles) {
302
+ if (!file.endsWith('.values.yaml')) continue;
303
+ const filePath = path.join(repoPath, file);
304
+ if (!fs.existsSync(filePath)) continue;
305
+
306
+ const masterContent = (await $`cd ${repoPath} && git show master:${file}`)
307
+ .stdout;
308
+ const masterConfig = yaml.load(masterContent);
309
+ const masterTag = masterConfig?.image?.tag;
310
+ if (!masterTag) continue;
311
+
312
+ const migrationConfig = yaml.load(fs.readFileSync(filePath, 'utf8'));
313
+ if (!migrationConfig?.image?.tag) continue;
314
+ if (migrationConfig.image.tag === masterTag) continue;
315
+
316
+ console.log(`Syncing tag ${masterTag} to ${migrationBranch}:${file}`);
317
+ migrationConfig.image.tag = masterTag;
318
+ fs.writeFileSync(filePath, yaml.dump(migrationConfig, { lineWidth: -1 }));
319
+ updated = true;
320
+ }
321
+
322
+ if (updated) {
323
+ await $`cd ${repoPath} && git add .`;
324
+ await $`cd ${repoPath} && git commit -m ${commitMessage}`;
325
+ await $`cd ${repoPath} && git push origin ${migrationBranch}`;
326
+ console.log(`Tag synced to ${migrationBranch} branch.`);
327
+ }
328
+ } catch (error) {
329
+ console.warn(`Failed to sync to ${migrationBranch}: ${error.message}`);
330
+ }
331
+ }
332
+
281
333
  function writeDeployConfig(deployConfigFilePath, deployConfig) {
282
334
  try {
283
335
  fs.writeFileSync(deployConfigFilePath, yaml.dump(deployConfig), 'utf8');
@@ -293,9 +345,10 @@ export async function writeAndPushDeployConfig(
293
345
  deployConfigFilePath,
294
346
  deployConfig,
295
347
  commitMessage,
348
+ env,
296
349
  ) {
297
350
  writeDeployConfig(deployConfigFilePath, deployConfig);
298
- await pushDeployConfig(repoPath, commitMessage);
351
+ await pushDeployConfig(repoPath, commitMessage, env);
299
352
  }
300
353
 
301
354
  /**
@@ -777,6 +830,258 @@ async function validateDeployVersionConsistency(env, site, deployedApps) {
777
830
  `✅ Version consistency validated for ${env}/${site}: all ${appVersions.length} component(s) aligned on ${uniqueMajorMinors[0] ?? 'n/a'}`,
778
831
  );
779
832
  }
833
+ export async function updateSiteVersion(
834
+ env,
835
+ site,
836
+ uiVersion,
837
+ graphVersion,
838
+ standardConfig,
839
+ siteConfig,
840
+ jiraTicket,
841
+ ) {
842
+ if (!uiVersion && !graphVersion && !standardConfig && !siteConfig) {
843
+ console.error(
844
+ '❌ At least one of --ui-version, --graph-version, --standard-config, or --site-config must be provided',
845
+ );
846
+ process.exit(1);
847
+ }
848
+
849
+ console.log(
850
+ `Updating site versions for ${env}/${site}${jiraTicket ? ` approved by JIRA ticket ${jiraTicket}` : ''}`,
851
+ );
852
+
853
+ if (env === 'prod') {
854
+ if (!jiraTicket) {
855
+ console.error(
856
+ 'The deployment to prod environment requires a JIRA ticket to be provided',
857
+ );
858
+ process.exit(1);
859
+ }
860
+
861
+ try {
862
+ const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
863
+ const docupacecInstance = response.fields.customfield_10045.value;
864
+ const siteUrl = response.fields.customfield_10041;
865
+ const status = response.fields.status.name;
866
+ const jiraBaseUrl = response.self.split('/rest/api')[0];
867
+ const jiraTicketUrl = `${jiraBaseUrl}/browse/${response.key}`;
868
+
869
+ console.log(`Docupace Instance: ${docupacecInstance}`);
870
+ console.log(`Docupace Site URL: ${siteUrl}`);
871
+ console.log(`JIRA Ticket Status: ${status}`);
872
+ console.log(`JIRA Ticket URL: ${jiraTicketUrl}`);
873
+
874
+ const allowedStatuses = ['To Do', 'In Progress', 'In Deployment'];
875
+ if (!allowedStatuses.includes(status)) {
876
+ console.error(
877
+ `The JIRA ticket status must be "To Do" or "In Progress" or "In Deployment", but got "${status}"`,
878
+ );
879
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
880
+ process.exit(1);
881
+ }
882
+
883
+ if (!siteUrl.includes(site)) {
884
+ console.error(
885
+ `The site "${site}" must be present in the Docupace Site URL: "${siteUrl}"`,
886
+ );
887
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
888
+ process.exit(1);
889
+ }
890
+
891
+ if (docupacecInstance !== 'Production') {
892
+ console.error(
893
+ `The deployment to prod environment requires Docupace Instance to be "Production", but got "${docupacecInstance}"`,
894
+ );
895
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
896
+ process.exit(1);
897
+ }
898
+
899
+ console.log('Production deployment validations passed');
900
+ } catch (error) {
901
+ console.error(`Failed to make a Jira request: ${error.message}`);
902
+ process.exit(1);
903
+ }
904
+ } else if (jiraTicket) {
905
+ try {
906
+ const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
907
+ const siteUrl = response.fields.customfield_10041;
908
+ const status = response.fields.status.name;
909
+ const jiraBaseUrl = response.self.split('/rest/api')[0];
910
+ const jiraTicketUrl = `${jiraBaseUrl}/browse/${response.key}`;
911
+
912
+ console.log(`Docupace Site URL: ${siteUrl}`);
913
+ console.log(`JIRA Ticket Status: ${status}`);
914
+ console.log(`JIRA Ticket URL: ${jiraTicketUrl}`);
915
+
916
+ const allowedStatuses = ['To Do', 'In Progress', 'In Deployment'];
917
+ if (!allowedStatuses.includes(status)) {
918
+ console.error(
919
+ `The JIRA ticket status must be "To Do" or "In Progress" or "In Deployment", but got "${status}"`,
920
+ );
921
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
922
+ process.exit(1);
923
+ }
924
+
925
+ if (!siteUrl.includes(site)) {
926
+ console.error(
927
+ `The site "${site}" must be present in the Docupace Site URL: "${siteUrl}"`,
928
+ );
929
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
930
+ process.exit(1);
931
+ }
932
+ } catch (error) {
933
+ console.error(`Failed to make a Jira request: ${error.message}`);
934
+ process.exit(1);
935
+ }
936
+ }
937
+
938
+ const toRepoPath = await cloneEnvRepository(env);
939
+
940
+ if (env !== 'dev') {
941
+ await cloneEnvRepository('dev');
942
+ }
943
+
944
+ let changesMade = false;
945
+ let oldVersion = null;
946
+ let newVersion = null;
947
+
948
+ if (uiVersion) {
949
+ const uiAppDetails = appInfo['ui'];
950
+
951
+ if (env !== 'dev') {
952
+ await copy2(
953
+ uiAppDetails.repositoryName,
954
+ 'dev',
955
+ env,
956
+ uiVersion,
957
+ uiAppDetails.imageName,
958
+ );
959
+ }
960
+
961
+ const { deployConfig, deployConfigFilePath } = await readDeployConfig(
962
+ 'ui',
963
+ env,
964
+ site,
965
+ 'values',
966
+ );
967
+ if (deployConfig) {
968
+ if (!oldVersion) oldVersion = deployConfig.image?.tag;
969
+ newVersion = uiVersion;
970
+
971
+ deployConfig.image.tag = uiVersion;
972
+
973
+ if (uiAppDetails.updateConfigFunction) {
974
+ uiAppDetails.updateConfigFunction(deployConfig);
975
+ }
976
+
977
+ const { deployConfig: appConfig, deployConfigFilePath: appFilePath } =
978
+ await readDeployConfig('ui', env, site, 'app');
979
+ if (appConfig) {
980
+ appConfig.revision = uiAppDetails.getAppRevision
981
+ ? uiAppDetails.getAppRevision(deployConfig)
982
+ : deployConfig.image.tag;
983
+ writeDeployConfig(appFilePath, appConfig);
984
+ }
985
+
986
+ writeDeployConfig(deployConfigFilePath, deployConfig);
987
+ changesMade = true;
988
+ }
989
+ }
990
+
991
+ if (graphVersion || standardConfig || siteConfig) {
992
+ const { deployConfig, deployConfigFilePath } = await readDeployConfig(
993
+ 'graphql-server',
994
+ env,
995
+ site,
996
+ 'values',
997
+ );
998
+ if (deployConfig) {
999
+ if (graphVersion) {
1000
+ const gsAppDetails = appInfo['graphql-server'];
1001
+
1002
+ if (env !== 'dev') {
1003
+ await copy2(
1004
+ gsAppDetails.repositoryName,
1005
+ 'dev',
1006
+ env,
1007
+ graphVersion,
1008
+ gsAppDetails.imageName,
1009
+ );
1010
+ }
1011
+
1012
+ if (!oldVersion) oldVersion = deployConfig.image?.tag;
1013
+ if (!newVersion) newVersion = graphVersion;
1014
+
1015
+ deployConfig.image.tag = graphVersion;
1016
+
1017
+ const { deployConfig: appConfig, deployConfigFilePath: appFilePath } =
1018
+ await readDeployConfig('graphql-server', env, site, 'app');
1019
+ if (appConfig) {
1020
+ appConfig.revision = graphVersion;
1021
+ writeDeployConfig(appFilePath, appConfig);
1022
+ }
1023
+ }
1024
+
1025
+ if (standardConfig) {
1026
+ deployConfig.graphqlServer = deployConfig.graphqlServer ?? {};
1027
+ deployConfig.graphqlServer.standardConfigRemoteBranch = standardConfig;
1028
+ }
1029
+
1030
+ if (siteConfig) {
1031
+ deployConfig.graphqlServer = deployConfig.graphqlServer ?? {};
1032
+ deployConfig.graphqlServer.siteConfigRemoteBranch = siteConfig;
1033
+ }
1034
+
1035
+ writeDeployConfig(deployConfigFilePath, deployConfig);
1036
+ changesMade = true;
1037
+ }
1038
+ }
1039
+
1040
+ let autoDeployUpdated = false;
1041
+ if (oldVersion && newVersion && oldVersion !== newVersion) {
1042
+ autoDeployUpdated = await updateAutoDeployVersion(
1043
+ env,
1044
+ env,
1045
+ site,
1046
+ oldVersion,
1047
+ newVersion,
1048
+ );
1049
+ if (autoDeployUpdated) {
1050
+ console.log(
1051
+ `Info: auto-deploy.yaml updated for ${env}/${site}: ${oldVersion} → ${newVersion}`,
1052
+ );
1053
+ changesMade = true;
1054
+ }
1055
+ }
1056
+
1057
+ if (changesMade) {
1058
+ const { applications } = getAppTypesFromRepo(env, site);
1059
+ const deployedApps = Object.fromEntries(
1060
+ applications
1061
+ .filter((app) => Object.prototype.hasOwnProperty.call(appInfo, app))
1062
+ .map((app) => [app, appInfo[app]]),
1063
+ );
1064
+ await validateDeployVersionConsistency(env, site, deployedApps);
1065
+
1066
+ await pushDeployConfig(
1067
+ toRepoPath,
1068
+ `Update site versions for ${env}/${site}`,
1069
+ );
1070
+
1071
+ if (autoDeployUpdated && env !== 'dev') {
1072
+ const { repoPath: devRepoPath } = getRepoLocalPath('dev');
1073
+ await pushDeployConfig(
1074
+ devRepoPath,
1075
+ `Update auto-deploy version for ${env}/${site}`,
1076
+ );
1077
+ }
1078
+
1079
+ console.log('All configurations updated and pushed successfully.');
1080
+ } else {
1081
+ console.log('No changes detected. Nothing to push.');
1082
+ }
1083
+ }
1084
+
780
1085
  export async function deployFromSite(
781
1086
  fromEnv,
782
1087
  fromSite,
@@ -133,7 +133,9 @@ describe('cloneEnvRepository', () => {
133
133
  const result = await cloneEnvRepository(env);
134
134
 
135
135
  expect(getRepUrl).toHaveBeenCalledWith('gitops-dev');
136
- expect($.mock.calls[0][0][0]).toContain('git clone --depth 1');
136
+ expect($.mock.calls[0][0][0]).toContain(
137
+ 'git clone --no-single-branch --depth 10',
138
+ );
137
139
  expect(result).toContain('gitops-dev');
138
140
  });
139
141