pgpm 5.17.4 → 5.18.0

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.
@@ -25,11 +25,17 @@ Options:
25
25
  --metaExtensionName <name> Meta extension name (default: svc)
26
26
  --exclude-categories <list> Comma-separated sql_actions categories to omit
27
27
  (e.g. security,permissions,auth,memberships). Works in SQL and GraphQL modes.
28
+ --granularity <level> Restructure the exported database module through the
29
+ dials pipeline: atomic | object | consolidated.
30
+ Change paths are derived from the naming spec and
31
+ requires from the statement graph. When omitted,
32
+ sql_actions rows are exported unchanged.
28
33
  --cwd <directory> Working directory (default: current directory)
29
34
 
30
35
  Examples:
31
36
  pgpm export Export migrations from selected database (SQL mode)
32
37
  pgpm export --exclude-categories security,permissions,auth,memberships
38
+ pgpm export --granularity consolidated
33
39
  pgpm export --graphql-endpoint 'http://[::1]:3002/graphql' --migrate-endpoint 'http://[::1]:3000/graphql' --migrate-host db_migrate.localhost:3000
34
40
  `;
35
41
  exports.default = async (argv, prompter, _options) => {
@@ -54,6 +60,13 @@ exports.default = async (argv, prompter, _options) => {
54
60
  : Array.isArray(excludeCategoriesRaw)
55
61
  ? excludeCategoriesRaw
56
62
  : undefined;
63
+ const granularityRaw = argv.granularity;
64
+ if (granularityRaw !== undefined && !(0, export_1.isExportGranularity)(granularityRaw)) {
65
+ console.error(`Invalid --granularity "${granularityRaw}". Expected one of: ${export_1.EXPORT_GRANULARITIES.join(', ')}.`);
66
+ prompter.close();
67
+ return;
68
+ }
69
+ const granularity = granularityRaw;
57
70
  if (graphqlEndpoint) {
58
71
  // =========================================================================
59
72
  // GraphQL export mode
@@ -150,7 +163,8 @@ exports.default = async (argv, prompter, _options) => {
150
163
  prompter,
151
164
  argv,
152
165
  username,
153
- excludeCategories
166
+ excludeCategories,
167
+ granularity
154
168
  });
155
169
  }
156
170
  else {
@@ -270,7 +284,8 @@ exports.default = async (argv, prompter, _options) => {
270
284
  prompter,
271
285
  argv,
272
286
  username,
273
- excludeCategories
287
+ excludeCategories,
288
+ granularity
274
289
  });
275
290
  }
276
291
  prompter.close();
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@pgpmjs/core");
4
+ const logger_1 = require("@pgpmjs/logger");
5
+ const log = new logger_1.Logger('package');
4
6
  const packageUsageText = `
5
7
  Package Command:
6
8
 
@@ -17,11 +19,23 @@ Options:
17
19
  --bundle Also emit sql/<name>--<version>.bundle.tar.gz (default: true)
18
20
  --cwd <directory> Working directory (default: current directory)
19
21
 
22
+ Check mode (no writes — verify committed artifacts are in sync with deploy/):
23
+ --check Verify committed sql/<name>--<version>.bundle.tar.gz
24
+ matches deploy/ for changed modules; exit 1 on drift
25
+ --since <ref> Git branch/ref/tag to diff HEAD against for change
26
+ detection (default: PR base in CI, else working tree)
27
+ --all Check every workspace module (skip change detection)
28
+ --dependents Also re-check modules that require a changed module
29
+ --no-fail-fast Report all drifted modules instead of stopping at the first
30
+
20
31
  Examples:
21
32
  pgpm package Package with defaults
22
33
  pgpm package --no-plan Package without plan
23
34
  pgpm package --outputDiff Package and export AST diff files if mismatch detected
24
35
  pgpm package --no-bundle Package without emitting the bundle artifact
36
+ pgpm package --check Verify changed modules' bundles are in sync
37
+ pgpm package --check --since origin/main Verify modules changed vs origin/main
38
+ pgpm package --check --all Verify every module in the workspace
25
39
  `;
26
40
  exports.default = async (argv, prompter, _options) => {
27
41
  // Show usage if explicitly requested
@@ -29,6 +43,40 @@ exports.default = async (argv, prompter, _options) => {
29
43
  console.log(packageUsageText);
30
44
  process.exit(0);
31
45
  }
46
+ // Check mode: verify committed artifacts, never write.
47
+ if (argv.check) {
48
+ const result = await (0, core_1.checkPackages)({
49
+ cwd: argv.cwd,
50
+ since: typeof argv.since === 'string' ? argv.since : undefined,
51
+ all: argv.all === true,
52
+ dependents: argv.dependents === true,
53
+ failFast: argv.failFast !== false,
54
+ });
55
+ if (argv.all) {
56
+ log.info(`Checking all ${result.targeted.length} workspace module(s)`);
57
+ }
58
+ else {
59
+ log.info(`Change detection${result.base ? ` vs ${result.base}` : ' (working tree)'}: ` +
60
+ `${result.changedModules.length} changed module(s)` +
61
+ (result.targeted.length !== result.changedModules.length
62
+ ? ` (${result.targeted.length} incl. dependents)`
63
+ : ''));
64
+ }
65
+ if (result.drifted.length) {
66
+ for (const drift of result.drifted) {
67
+ log.error(`✖ ${drift.name}: ${drift.detail}`);
68
+ }
69
+ log.error(`${result.drifted.length} module(s) out of sync. Run \`pgpm package\` in each and commit the artifacts.`);
70
+ process.exit(1);
71
+ }
72
+ if (result.checked.length === 0) {
73
+ log.success('No changed modules to check.');
74
+ }
75
+ else {
76
+ log.success(`${result.checked.length} module(s) in sync.`);
77
+ }
78
+ return argv;
79
+ }
32
80
  const questions = [
33
81
  {
34
82
  type: 'confirm',
@@ -1,5 +1,5 @@
1
1
  import { PgpmPackage } from '@pgpmjs/core';
2
- import { exportMigrations, exportGraphQL, GraphQLClient, graphqlRowToPostgresRow } from '@pgpmjs/export';
2
+ import { exportMigrations, exportGraphQL, GraphQLClient, graphqlRowToPostgresRow, isExportGranularity, EXPORT_GRANULARITIES } from '@pgpmjs/export';
3
3
  import { getEnvOptions } from '@pgpmjs/env';
4
4
  import { getGitConfigInfo } from '@pgpmjs/types';
5
5
  import { resolve } from 'path';
@@ -23,11 +23,17 @@ Options:
23
23
  --metaExtensionName <name> Meta extension name (default: svc)
24
24
  --exclude-categories <list> Comma-separated sql_actions categories to omit
25
25
  (e.g. security,permissions,auth,memberships). Works in SQL and GraphQL modes.
26
+ --granularity <level> Restructure the exported database module through the
27
+ dials pipeline: atomic | object | consolidated.
28
+ Change paths are derived from the naming spec and
29
+ requires from the statement graph. When omitted,
30
+ sql_actions rows are exported unchanged.
26
31
  --cwd <directory> Working directory (default: current directory)
27
32
 
28
33
  Examples:
29
34
  pgpm export Export migrations from selected database (SQL mode)
30
35
  pgpm export --exclude-categories security,permissions,auth,memberships
36
+ pgpm export --granularity consolidated
31
37
  pgpm export --graphql-endpoint 'http://[::1]:3002/graphql' --migrate-endpoint 'http://[::1]:3000/graphql' --migrate-host db_migrate.localhost:3000
32
38
  `;
33
39
  export default async (argv, prompter, _options) => {
@@ -52,6 +58,13 @@ export default async (argv, prompter, _options) => {
52
58
  : Array.isArray(excludeCategoriesRaw)
53
59
  ? excludeCategoriesRaw
54
60
  : undefined;
61
+ const granularityRaw = argv.granularity;
62
+ if (granularityRaw !== undefined && !isExportGranularity(granularityRaw)) {
63
+ console.error(`Invalid --granularity "${granularityRaw}". Expected one of: ${EXPORT_GRANULARITIES.join(', ')}.`);
64
+ prompter.close();
65
+ return;
66
+ }
67
+ const granularity = granularityRaw;
55
68
  if (graphqlEndpoint) {
56
69
  // =========================================================================
57
70
  // GraphQL export mode
@@ -148,7 +161,8 @@ export default async (argv, prompter, _options) => {
148
161
  prompter,
149
162
  argv,
150
163
  username,
151
- excludeCategories
164
+ excludeCategories,
165
+ granularity
152
166
  });
153
167
  }
154
168
  else {
@@ -268,7 +282,8 @@ export default async (argv, prompter, _options) => {
268
282
  prompter,
269
283
  argv,
270
284
  username,
271
- excludeCategories
285
+ excludeCategories,
286
+ granularity
272
287
  });
273
288
  }
274
289
  prompter.close();
@@ -1,4 +1,6 @@
1
- import { PgpmPackage, writePackage } from '@pgpmjs/core';
1
+ import { checkPackages, PgpmPackage, writePackage } from '@pgpmjs/core';
2
+ import { Logger } from '@pgpmjs/logger';
3
+ const log = new Logger('package');
2
4
  const packageUsageText = `
3
5
  Package Command:
4
6
 
@@ -15,11 +17,23 @@ Options:
15
17
  --bundle Also emit sql/<name>--<version>.bundle.tar.gz (default: true)
16
18
  --cwd <directory> Working directory (default: current directory)
17
19
 
20
+ Check mode (no writes — verify committed artifacts are in sync with deploy/):
21
+ --check Verify committed sql/<name>--<version>.bundle.tar.gz
22
+ matches deploy/ for changed modules; exit 1 on drift
23
+ --since <ref> Git branch/ref/tag to diff HEAD against for change
24
+ detection (default: PR base in CI, else working tree)
25
+ --all Check every workspace module (skip change detection)
26
+ --dependents Also re-check modules that require a changed module
27
+ --no-fail-fast Report all drifted modules instead of stopping at the first
28
+
18
29
  Examples:
19
30
  pgpm package Package with defaults
20
31
  pgpm package --no-plan Package without plan
21
32
  pgpm package --outputDiff Package and export AST diff files if mismatch detected
22
33
  pgpm package --no-bundle Package without emitting the bundle artifact
34
+ pgpm package --check Verify changed modules' bundles are in sync
35
+ pgpm package --check --since origin/main Verify modules changed vs origin/main
36
+ pgpm package --check --all Verify every module in the workspace
23
37
  `;
24
38
  export default async (argv, prompter, _options) => {
25
39
  // Show usage if explicitly requested
@@ -27,6 +41,40 @@ export default async (argv, prompter, _options) => {
27
41
  console.log(packageUsageText);
28
42
  process.exit(0);
29
43
  }
44
+ // Check mode: verify committed artifacts, never write.
45
+ if (argv.check) {
46
+ const result = await checkPackages({
47
+ cwd: argv.cwd,
48
+ since: typeof argv.since === 'string' ? argv.since : undefined,
49
+ all: argv.all === true,
50
+ dependents: argv.dependents === true,
51
+ failFast: argv.failFast !== false,
52
+ });
53
+ if (argv.all) {
54
+ log.info(`Checking all ${result.targeted.length} workspace module(s)`);
55
+ }
56
+ else {
57
+ log.info(`Change detection${result.base ? ` vs ${result.base}` : ' (working tree)'}: ` +
58
+ `${result.changedModules.length} changed module(s)` +
59
+ (result.targeted.length !== result.changedModules.length
60
+ ? ` (${result.targeted.length} incl. dependents)`
61
+ : ''));
62
+ }
63
+ if (result.drifted.length) {
64
+ for (const drift of result.drifted) {
65
+ log.error(`✖ ${drift.name}: ${drift.detail}`);
66
+ }
67
+ log.error(`${result.drifted.length} module(s) out of sync. Run \`pgpm package\` in each and commit the artifacts.`);
68
+ process.exit(1);
69
+ }
70
+ if (result.checked.length === 0) {
71
+ log.success('No changed modules to check.');
72
+ }
73
+ else {
74
+ log.success(`${result.checked.length} module(s) in sync.`);
75
+ }
76
+ return argv;
77
+ }
30
78
  const questions = [
31
79
  {
32
80
  type: 'confirm',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgpm",
3
- "version": "5.17.4",
3
+ "version": "5.18.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL Package Manager - Database migration and package management CLI",
6
6
  "main": "index.js",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@inquirerer/utils": "^3.3.9",
49
- "@pgpmjs/core": "^7.20.4",
49
+ "@pgpmjs/core": "^7.21.0",
50
50
  "@pgpmjs/env": "^2.40.2",
51
- "@pgpmjs/export": "^1.13.4",
51
+ "@pgpmjs/export": "^1.14.0",
52
52
  "@pgpmjs/logger": "^2.23.2",
53
- "@pgpmjs/slice": "^0.13.4",
53
+ "@pgpmjs/slice": "^0.13.5",
54
54
  "@pgpmjs/types": "^2.49.2",
55
55
  "@pgsql/quotes": "^18.1.0",
56
56
  "appstash": "^0.7.0",
@@ -77,5 +77,5 @@
77
77
  "pg",
78
78
  "pgsql"
79
79
  ],
80
- "gitHead": "90f447482b056a4949134565db2665f21d11aca3"
80
+ "gitHead": "7a37da1f5655c36813343f09c6efa62ca0d7a855"
81
81
  }