@momentumcms/migrations 0.3.0 → 0.4.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.
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
- "name": "@momentumcms/migrations",
3
- "version": "0.3.0",
4
- "description": "Database migration system for Momentum CMS",
5
- "license": "MIT",
6
- "main": "./index.cjs",
7
- "types": "./src/index.d.ts",
8
- "peerDependencies": {
9
- "@momentumcms/core": ">=0.0.1",
10
- "pg": "^8.0.0"
11
- },
12
- "module": "./index.js"
13
- }
2
+ "name": "@momentumcms/migrations",
3
+ "version": "0.4.0",
4
+ "description": "Database migration system for Momentum CMS",
5
+ "license": "MIT",
6
+ "main": "./src/index.cjs",
7
+ "module": "./src/index.js",
8
+ "types": "./src/index.d.ts",
9
+ "schematics": "./schematics/collection.json",
10
+ "peerDependencies": {
11
+ "@angular-devkit/schematics": ">=17.0.0",
12
+ "@momentumcms/core": ">=0.0.1",
13
+ "pg": "^8.0.0"
14
+ },
15
+ "peerDependenciesMeta": {
16
+ "@angular-devkit/schematics": {
17
+ "optional": true
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "generate": {
5
+ "description": "Generate a new migration by diffing the current schema against the snapshot",
6
+ "factory": "./generate/index#migrationGenerate",
7
+ "schema": "./generate/schema.json"
8
+ },
9
+ "run": {
10
+ "description": "Run pending migrations with optional clone-test-apply safety",
11
+ "factory": "./run/index#migrationRun",
12
+ "schema": "./run/schema.json"
13
+ },
14
+ "rollback": {
15
+ "description": "Rollback the latest batch of applied migrations",
16
+ "factory": "./rollback/index#migrationRollback",
17
+ "schema": "./rollback/schema.json"
18
+ },
19
+ "status": {
20
+ "description": "Show the status of all migrations (applied vs pending)",
21
+ "factory": "./status/index#migrationStatus",
22
+ "schema": "./status/schema.json"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/migrations/schematics/generate/index.ts
21
+ var generate_exports = {};
22
+ __export(generate_exports, {
23
+ migrationGenerate: () => migrationGenerate
24
+ });
25
+ module.exports = __toCommonJS(generate_exports);
26
+ var import_node_child_process = require("node:child_process");
27
+ function migrationGenerate(options) {
28
+ return (_tree, context) => {
29
+ const configPath = options.configPath || "src/momentum.config.ts";
30
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/generate.cjs", configPath];
31
+ if (options.name) {
32
+ args.push("--name", options.name);
33
+ }
34
+ if (options.dryRun) {
35
+ args.push("--dry-run");
36
+ }
37
+ context.logger.info(`Generating migration from ${configPath}...`);
38
+ try {
39
+ (0, import_node_child_process.execFileSync)("npx", args, { stdio: "inherit", shell: true });
40
+ } catch (error) {
41
+ context.logger.error("Migration generation failed.");
42
+ throw error;
43
+ }
44
+ return _tree;
45
+ };
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ migrationGenerate
50
+ });
@@ -0,0 +1,25 @@
1
+ // libs/migrations/schematics/generate/index.ts
2
+ import { execFileSync } from "node:child_process";
3
+ function migrationGenerate(options) {
4
+ return (_tree, context) => {
5
+ const configPath = options.configPath || "src/momentum.config.ts";
6
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/generate.cjs", configPath];
7
+ if (options.name) {
8
+ args.push("--name", options.name);
9
+ }
10
+ if (options.dryRun) {
11
+ args.push("--dry-run");
12
+ }
13
+ context.logger.info(`Generating migration from ${configPath}...`);
14
+ try {
15
+ execFileSync("npx", args, { stdio: "inherit", shell: true });
16
+ } catch (error) {
17
+ context.logger.error("Migration generation failed.");
18
+ throw error;
19
+ }
20
+ return _tree;
21
+ };
22
+ }
23
+ export {
24
+ migrationGenerate
25
+ };
@@ -0,0 +1,5 @@
1
+ export interface MigrationGenerateSchema {
2
+ configPath: string;
3
+ name?: string;
4
+ dryRun: boolean;
5
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "MomentumMigrationGenerate",
4
+ "title": "Generate Migration",
5
+ "description": "Diff current collections against the snapshot and generate a migration file",
6
+ "type": "object",
7
+ "properties": {
8
+ "configPath": {
9
+ "type": "string",
10
+ "description": "Path to momentum.config.ts",
11
+ "default": "src/momentum.config.ts"
12
+ },
13
+ "name": {
14
+ "type": "string",
15
+ "description": "Name for the migration (e.g., add-posts-table)"
16
+ },
17
+ "dryRun": {
18
+ "type": "boolean",
19
+ "description": "Preview the migration without writing files",
20
+ "default": false
21
+ }
22
+ },
23
+ "required": []
24
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/migrations/schematics/rollback/index.ts
21
+ var rollback_exports = {};
22
+ __export(rollback_exports, {
23
+ migrationRollback: () => migrationRollback
24
+ });
25
+ module.exports = __toCommonJS(rollback_exports);
26
+ var import_node_child_process = require("node:child_process");
27
+ function migrationRollback(options) {
28
+ return (_tree, context) => {
29
+ const configPath = options.configPath || "src/momentum.config.ts";
30
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/rollback.cjs", configPath];
31
+ context.logger.info("Rolling back latest migration batch...");
32
+ try {
33
+ (0, import_node_child_process.execFileSync)("npx", args, { stdio: "inherit", shell: true });
34
+ } catch (error) {
35
+ context.logger.error("Migration rollback failed.");
36
+ throw error;
37
+ }
38
+ return _tree;
39
+ };
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ migrationRollback
44
+ });
@@ -0,0 +1,19 @@
1
+ // libs/migrations/schematics/rollback/index.ts
2
+ import { execFileSync } from "node:child_process";
3
+ function migrationRollback(options) {
4
+ return (_tree, context) => {
5
+ const configPath = options.configPath || "src/momentum.config.ts";
6
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/rollback.cjs", configPath];
7
+ context.logger.info("Rolling back latest migration batch...");
8
+ try {
9
+ execFileSync("npx", args, { stdio: "inherit", shell: true });
10
+ } catch (error) {
11
+ context.logger.error("Migration rollback failed.");
12
+ throw error;
13
+ }
14
+ return _tree;
15
+ };
16
+ }
17
+ export {
18
+ migrationRollback
19
+ };
@@ -0,0 +1,3 @@
1
+ export interface MigrationRollbackSchema {
2
+ configPath: string;
3
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "MomentumMigrationRollback",
4
+ "title": "Rollback Migration",
5
+ "description": "Rollback the latest batch of applied migrations",
6
+ "type": "object",
7
+ "properties": {
8
+ "configPath": {
9
+ "type": "string",
10
+ "description": "Path to momentum.config.ts",
11
+ "default": "src/momentum.config.ts"
12
+ }
13
+ },
14
+ "required": []
15
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/migrations/schematics/run/index.ts
21
+ var run_exports = {};
22
+ __export(run_exports, {
23
+ migrationRun: () => migrationRun
24
+ });
25
+ module.exports = __toCommonJS(run_exports);
26
+ var import_node_child_process = require("node:child_process");
27
+ function migrationRun(options) {
28
+ return (_tree, context) => {
29
+ const configPath = options.configPath || "src/momentum.config.ts";
30
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/run.cjs", configPath];
31
+ if (options.testOnly) {
32
+ args.push("--test-only");
33
+ }
34
+ if (options.skipCloneTest) {
35
+ args.push("--skip-clone-test");
36
+ }
37
+ context.logger.info("Running pending migrations...");
38
+ try {
39
+ (0, import_node_child_process.execFileSync)("npx", args, { stdio: "inherit", shell: true });
40
+ } catch (error) {
41
+ context.logger.error("Migration run failed.");
42
+ throw error;
43
+ }
44
+ return _tree;
45
+ };
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ migrationRun
50
+ });
@@ -0,0 +1,25 @@
1
+ // libs/migrations/schematics/run/index.ts
2
+ import { execFileSync } from "node:child_process";
3
+ function migrationRun(options) {
4
+ return (_tree, context) => {
5
+ const configPath = options.configPath || "src/momentum.config.ts";
6
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/run.cjs", configPath];
7
+ if (options.testOnly) {
8
+ args.push("--test-only");
9
+ }
10
+ if (options.skipCloneTest) {
11
+ args.push("--skip-clone-test");
12
+ }
13
+ context.logger.info("Running pending migrations...");
14
+ try {
15
+ execFileSync("npx", args, { stdio: "inherit", shell: true });
16
+ } catch (error) {
17
+ context.logger.error("Migration run failed.");
18
+ throw error;
19
+ }
20
+ return _tree;
21
+ };
22
+ }
23
+ export {
24
+ migrationRun
25
+ };
@@ -0,0 +1,5 @@
1
+ export interface MigrationRunSchema {
2
+ configPath: string;
3
+ testOnly: boolean;
4
+ skipCloneTest: boolean;
5
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "MomentumMigrationRun",
4
+ "title": "Run Migrations",
5
+ "description": "Apply pending migrations with optional clone-test-apply safety pipeline",
6
+ "type": "object",
7
+ "properties": {
8
+ "configPath": {
9
+ "type": "string",
10
+ "description": "Path to momentum.config.ts",
11
+ "default": "src/momentum.config.ts"
12
+ },
13
+ "testOnly": {
14
+ "type": "boolean",
15
+ "description": "Test migrations on a clone without applying to the real database",
16
+ "default": false
17
+ },
18
+ "skipCloneTest": {
19
+ "type": "boolean",
20
+ "description": "Skip the clone-test safety check (not recommended for production)",
21
+ "default": false
22
+ }
23
+ },
24
+ "required": []
25
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/migrations/schematics/status/index.ts
21
+ var status_exports = {};
22
+ __export(status_exports, {
23
+ migrationStatus: () => migrationStatus
24
+ });
25
+ module.exports = __toCommonJS(status_exports);
26
+ var import_node_child_process = require("node:child_process");
27
+ function migrationStatus(options) {
28
+ return (_tree, context) => {
29
+ const configPath = options.configPath || "src/momentum.config.ts";
30
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/status.cjs", configPath];
31
+ context.logger.info("Checking migration status...");
32
+ try {
33
+ (0, import_node_child_process.execFileSync)("npx", args, { stdio: "inherit", shell: true });
34
+ } catch (error) {
35
+ context.logger.error("Migration status check failed.");
36
+ throw error;
37
+ }
38
+ return _tree;
39
+ };
40
+ }
41
+ // Annotate the CommonJS export names for ESM import in node:
42
+ 0 && (module.exports = {
43
+ migrationStatus
44
+ });
@@ -0,0 +1,19 @@
1
+ // libs/migrations/schematics/status/index.ts
2
+ import { execFileSync } from "node:child_process";
3
+ function migrationStatus(options) {
4
+ return (_tree, context) => {
5
+ const configPath = options.configPath || "src/momentum.config.ts";
6
+ const args = ["tsx", "node_modules/@momentumcms/migrations/cli/status.cjs", configPath];
7
+ context.logger.info("Checking migration status...");
8
+ try {
9
+ execFileSync("npx", args, { stdio: "inherit", shell: true });
10
+ } catch (error) {
11
+ context.logger.error("Migration status check failed.");
12
+ throw error;
13
+ }
14
+ return _tree;
15
+ };
16
+ }
17
+ export {
18
+ migrationStatus
19
+ };
@@ -0,0 +1,3 @@
1
+ export interface MigrationStatusSchema {
2
+ configPath: string;
3
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "MomentumMigrationStatus",
4
+ "title": "Migration Status",
5
+ "description": "Show the status of all migrations (applied vs pending)",
6
+ "type": "object",
7
+ "properties": {
8
+ "configPath": {
9
+ "type": "string",
10
+ "description": "Path to momentum.config.ts",
11
+ "default": "src/momentum.config.ts"
12
+ }
13
+ },
14
+ "required": []
15
+ }