@xubylele/schema-forge 1.9.0 → 1.10.1
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/README.md +1 -1
- package/dist/api.d.ts +1 -0
- package/dist/api.js +4 -1
- package/dist/cli.js +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A modern CLI tool for database schema management with a clean DSL and automatic SQL migration generation.
|
|
4
4
|
|
|
5
|
-
**Website:** [schemaforge.xuby.cl](https://schemaforge.xuby.cl/) · **npm package:** [@xubylele/schema-forge](https://www.npmjs.com/package/@xubylele/schema-forge)
|
|
5
|
+
**Website:** [schemaforge.xuby.cl](https://schemaforge.xuby.cl/) · **npm package:** [@xubylele/schema-forge](https://www.npmjs.com/package/@xubylele/schema-forge) · **Roadmap:** [ROADMAP.md](ROADMAP.md)
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
|
@@ -2950,6 +2950,9 @@ var EXIT_CODES = {
|
|
|
2950
2950
|
/** Destructive operation detected in CI environment without --force */
|
|
2951
2951
|
CI_DESTRUCTIVE: 3
|
|
2952
2952
|
};
|
|
2953
|
+
function shouldFailCIDestructive(isCIEnvironment, hasDestructiveFindings2, isForceEnabled) {
|
|
2954
|
+
return isCIEnvironment && hasDestructiveFindings2 && !isForceEnabled;
|
|
2955
|
+
}
|
|
2953
2956
|
|
|
2954
2957
|
// src/utils/output.ts
|
|
2955
2958
|
var import_boxen = __toESM(require("boxen"));
|
|
@@ -3583,7 +3586,7 @@ async function runValidate(options = {}) {
|
|
|
3583
3586
|
}
|
|
3584
3587
|
const findings = await validateSchemaChanges2(previousState, schema);
|
|
3585
3588
|
const report = await toValidationReport2(findings);
|
|
3586
|
-
if (isCI()
|
|
3589
|
+
if (shouldFailCIDestructive(isCI(), hasDestructiveFindings(findings), Boolean(options.force))) {
|
|
3587
3590
|
process.exitCode = EXIT_CODES.CI_DESTRUCTIVE;
|
|
3588
3591
|
} else {
|
|
3589
3592
|
process.exitCode = report.hasErrors ? EXIT_CODES.VALIDATION_ERROR : EXIT_CODES.SUCCESS;
|
package/dist/cli.js
CHANGED
|
@@ -2733,7 +2733,7 @@ var import_commander8 = require("commander");
|
|
|
2733
2733
|
// package.json
|
|
2734
2734
|
var package_default = {
|
|
2735
2735
|
name: "@xubylele/schema-forge",
|
|
2736
|
-
version: "1.
|
|
2736
|
+
version: "1.10.1",
|
|
2737
2737
|
description: "Universal migration generator from schema DSL",
|
|
2738
2738
|
main: "dist/cli.js",
|
|
2739
2739
|
type: "commonjs",
|
|
@@ -3015,6 +3015,9 @@ var EXIT_CODES = {
|
|
|
3015
3015
|
/** Destructive operation detected in CI environment without --force */
|
|
3016
3016
|
CI_DESTRUCTIVE: 3
|
|
3017
3017
|
};
|
|
3018
|
+
function shouldFailCIDestructive(isCIEnvironment, hasDestructiveFindings2, isForceEnabled) {
|
|
3019
|
+
return isCIEnvironment && hasDestructiveFindings2 && !isForceEnabled;
|
|
3020
|
+
}
|
|
3018
3021
|
|
|
3019
3022
|
// src/utils/output.ts
|
|
3020
3023
|
var import_boxen = __toESM(require("boxen"));
|
|
@@ -3648,7 +3651,7 @@ async function runValidate(options = {}) {
|
|
|
3648
3651
|
}
|
|
3649
3652
|
const findings = await validateSchemaChanges2(previousState, schema);
|
|
3650
3653
|
const report = await toValidationReport2(findings);
|
|
3651
|
-
if (isCI()
|
|
3654
|
+
if (shouldFailCIDestructive(isCI(), hasDestructiveFindings(findings), Boolean(options.force))) {
|
|
3652
3655
|
process.exitCode = EXIT_CODES.CI_DESTRUCTIVE;
|
|
3653
3656
|
} else {
|
|
3654
3657
|
process.exitCode = report.hasErrors ? EXIT_CODES.VALIDATION_ERROR : EXIT_CODES.SUCCESS;
|
|
@@ -3788,9 +3791,11 @@ program.command("import").description("Import schema from SQL migrations").argum
|
|
|
3788
3791
|
await handleError(error2);
|
|
3789
3792
|
}
|
|
3790
3793
|
});
|
|
3791
|
-
program.command("validate").description("Detect destructive or risky schema changes. In CI environments (CI=true), exits with code 3 if destructive operations are detected.").option("--json", "Output structured JSON").option("--url <string>", "PostgreSQL connection URL for live drift validation (defaults to DATABASE_URL)").option("--schema <list>", "Comma-separated schema names to introspect (default: public)").action(async (options) => {
|
|
3794
|
+
program.command("validate").description("Detect destructive or risky schema changes. In CI environments (CI=true), exits with code 3 if destructive operations are detected unless --force is used.").option("--json", "Output structured JSON").option("--url <string>", "PostgreSQL connection URL for live drift validation (defaults to DATABASE_URL)").option("--schema <list>", "Comma-separated schema names to introspect (default: public)").action(async (options) => {
|
|
3792
3795
|
try {
|
|
3793
|
-
|
|
3796
|
+
const globalOptions = program.opts();
|
|
3797
|
+
validateFlagExclusivity(globalOptions);
|
|
3798
|
+
await runValidate({ ...options, ...globalOptions });
|
|
3794
3799
|
} catch (error2) {
|
|
3795
3800
|
await handleError(error2);
|
|
3796
3801
|
}
|