@docupace/pipeline 1.1.5 → 1.1.6

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,7 @@
1
+ ---
2
+ '@docupace/pipeline': patch
3
+ ---
4
+
5
+ Run the changeset binary installed by the CLI directly instead of via `pnpm changeset`, so pnpm cannot re-sync node_modules to the repo lockfile and swap the changelog hook to an older pinned @docupace/pipeline.
6
+
7
+ Log the @docupace/pipeline version (to stderr) before every command of every dp-*-cli, and log the CLI and changelog hook versions during changeset versioning.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/auth0/cli.js CHANGED
@@ -19,10 +19,12 @@ import dotenv from 'dotenv';
19
19
  import { configureAlias } from './alias.js';
20
20
  import { exportConf } from './export.js';
21
21
  import { getAuth0Metadata } from './metadata.js';
22
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
22
23
 
23
24
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
24
25
 
25
26
  const program = new Command();
27
+ logVersionBeforeCommands(program);
26
28
 
27
29
  program
28
30
  .command(
@@ -13,10 +13,12 @@ import {
13
13
  import { createChangeset } from './create.js';
14
14
  import { updateWikiWithVersion } from './changelog-wiki.js';
15
15
  import { convertPrepare, convertComplete } from './convert.js';
16
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
16
17
 
17
18
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
18
19
 
19
20
  const program = new Command();
21
+ logVersionBeforeCommands(program);
20
22
 
21
23
  const args = process.argv;
22
24
 
@@ -5,14 +5,37 @@ import { updateComponentVersion } from '../next/jira.js';
5
5
  import { findJiraTicketId } from './util.js';
6
6
  import { revertBaseBranch, updateBaseBranch } from './changeset-config.js';
7
7
  import semver from 'semver';
8
- import { dirname, join } from 'path';
9
- import { fileURLToPath } from 'url';
10
-
11
- const getPackageVersion = () => {
12
- const __dirname = dirname(fileURLToPath(import.meta.url));
13
- const packageJsonPath = join(__dirname, '../../package.json');
14
- const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
15
- return packageJson.version;
8
+ import { join } from 'path';
9
+ import { getPipelineVersion as getPackageVersion } from '../lib/pipeline-version.js';
10
+
11
+ // Run the changeset binary installed by the temporary install below rather than
12
+ // `pnpm changeset`. Going through pnpm lets it re-sync node_modules with the
13
+ // repo's own lockfile before the command runs, which swaps the pinned
14
+ // @docupace/pipeline (used by the changelog hook) for whatever version the repo
15
+ // lockfile holds instead of the version of this CLI.
16
+ const CHANGESET_BIN = './node_modules/.bin/changeset';
17
+
18
+ // Version of @docupace/pipeline the changelog hook will be loaded from (the
19
+ // copy in the current directory's node_modules, not the one running this CLI).
20
+ const getInstalledPipelineVersion = () => {
21
+ try {
22
+ const pkgPath = join(
23
+ process.cwd(),
24
+ 'node_modules',
25
+ '@docupace',
26
+ 'pipeline',
27
+ 'package.json',
28
+ );
29
+ return JSON.parse(readFileSync(pkgPath, 'utf8')).version;
30
+ } catch (error) {
31
+ return `unknown (${error.message})`;
32
+ }
33
+ };
34
+
35
+ const logPipelineVersions = (stage) => {
36
+ console.log(
37
+ `🔎 @docupace/pipeline ${stage}: running CLI ${getPackageVersion()}, changelog hook ${getInstalledPipelineVersion()}`,
38
+ );
16
39
  };
17
40
 
18
41
  const getChangeSetPackage = (installLatest = false) => `{
@@ -61,9 +84,9 @@ export async function versionStatus(sinceBranch) {
61
84
  const outputPath = './changeset-output.json';
62
85
 
63
86
  if (sinceBranch) {
64
- await $`pnpm changeset status --output=${outputPath} --since=${sinceBranch}`;
87
+ await $`${CHANGESET_BIN} status --output=${outputPath} --since=${sinceBranch}`;
65
88
  } else {
66
- await $`pnpm changeset status --output=${outputPath}`;
89
+ await $`${CHANGESET_BIN} status --output=${outputPath}`;
67
90
  }
68
91
 
69
92
  // Read the file and parse JSON
@@ -77,6 +100,7 @@ export async function versionCommand(
77
100
  installLatest = false,
78
101
  ) {
79
102
  console.log('📦 Running Changeset versioning...');
103
+ logPipelineVersions('at start');
80
104
  if (!process.env.IS_DEV) {
81
105
  await setGitInfo();
82
106
  await $`mv package.json package.json.bak`;
@@ -98,9 +122,10 @@ export async function versionCommand(
98
122
  }
99
123
  await $`mv package.json.bak package.json`;
100
124
  await $`mv pnpm-lock.yaml.bak pnpm-lock.yaml`;
125
+ logPipelineVersions('after install');
101
126
  }
102
127
  if (closeVersion) {
103
- await $`pnpm changeset pre exit`;
128
+ await $`${CHANGESET_BIN} pre exit`;
104
129
  }
105
130
 
106
131
  let originalBaseBranch;
@@ -117,7 +142,8 @@ export async function versionCommand(
117
142
 
118
143
  // Intentionally outside the try/catch above: a failure here (e.g. release
119
144
  // notes processing) must fail the build, not be swallowed as "no releases".
120
- await $`pnpm changeset version`;
145
+ logPipelineVersions('before changeset version');
146
+ await $`${CHANGESET_BIN} version`;
121
147
 
122
148
  await removeChangesetOutput();
123
149
 
@@ -0,0 +1,25 @@
1
+ import { readFileSync } from 'fs';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ /**
6
+ * Version of the @docupace/pipeline package this code is running from.
7
+ */
8
+ export function getPipelineVersion() {
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const packageJsonPath = join(__dirname, '../../package.json');
11
+ return JSON.parse(readFileSync(packageJsonPath, 'utf8')).version;
12
+ }
13
+
14
+ /**
15
+ * Registers a commander hook that logs the @docupace/pipeline version before
16
+ * any command of the given program runs. Written to stderr so it never mixes
17
+ * with output that callers parse from stdout.
18
+ */
19
+ export function logVersionBeforeCommands(program) {
20
+ program.hook('preAction', (_thisCommand, actionCommand) => {
21
+ console.error(
22
+ `🔎 @docupace/pipeline ${getPipelineVersion()} (${program.name() || 'cli'} ${actionCommand.name()})`,
23
+ );
24
+ });
25
+ }
package/src/merge/cli.js CHANGED
@@ -6,9 +6,11 @@ import { Command } from 'commander';
6
6
  import { setupMerge } from './cli-merge.js';
7
7
  import { setupResolve } from './cli-resolve.js';
8
8
  import { setupMergeAll } from './cli-merge-all.js';
9
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
9
10
 
10
11
  const args = process.argv;
11
12
  const program = new Command();
13
+ logVersionBeforeCommands(program);
12
14
 
13
15
  /**
14
16
  * Reusable auto-resolve function
package/src/micro/cli.js CHANGED
@@ -9,10 +9,12 @@ import {
9
9
  microserviceCopyImageToEnv,
10
10
  microserviceBuildPushImage,
11
11
  } from './ms-deploy.js';
12
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
12
13
 
13
14
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
14
15
 
15
16
  const program = new Command();
17
+ logVersionBeforeCommands(program);
16
18
 
17
19
  //const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
18
20
 
package/src/next/cli.js CHANGED
@@ -23,10 +23,12 @@ import { deployConnect, deployCore } from './jenkins.js';
23
23
  import { deployConnectAws, runPipelineChecked } from './connect-aws.js';
24
24
  import { registerConnectAwsCommands } from './connect-aws-cli.js';
25
25
  import { runPipeline } from './pipline.js';
26
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
26
27
 
27
28
  dotenv.config({ path: ['.env.pipeline.local', 'config/.env.pipeline.local'] });
28
29
 
29
30
  const program = new Command();
31
+ logVersionBeforeCommands(program);
30
32
 
31
33
  const GIT_SHA = (await $`git log --pretty=format:'%h' -n 1`).stdout.trim();
32
34
 
@@ -3,8 +3,10 @@
3
3
  import { Command } from 'commander';
4
4
  import { $ } from 'zx';
5
5
  import { runTenableScan } from './scan.js';
6
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
6
7
 
7
8
  const program = new Command();
9
+ logVersionBeforeCommands(program);
8
10
 
9
11
  program
10
12
  .command('scan')
@@ -2,8 +2,10 @@
2
2
 
3
3
  import { Command } from 'commander';
4
4
  import { runVeracodeScan } from './scan.js';
5
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
5
6
 
6
7
  const program = new Command();
8
+ logVersionBeforeCommands(program);
7
9
 
8
10
  program
9
11
  .command('scan')
package/src/xray/cli.js CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  import { Command } from 'commander';
4
4
  import { notify } from './notify.js';
5
+ import { logVersionBeforeCommands } from '../lib/pipeline-version.js';
5
6
 
6
7
  const program = new Command();
8
+ logVersionBeforeCommands(program);
7
9
 
8
10
  program
9
11
  .command('notify')