@t1mmen/srtd 0.0.0-next-20251227000343
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/LICENSE +21 -0
- package/README.md +363 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +50 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/apply.d.ts +2 -0
- package/dist/commands/apply.js +105 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +134 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/clear.d.ts +2 -0
- package/dist/commands/clear.js +161 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +91 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/menu.d.ts +4 -0
- package/dist/commands/menu.js +76 -0
- package/dist/commands/menu.js.map +1 -0
- package/dist/commands/promote.d.ts +2 -0
- package/dist/commands/promote.js +181 -0
- package/dist/commands/promote.js.map +1 -0
- package/dist/commands/register.d.ts +2 -0
- package/dist/commands/register.js +192 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/watch.d.ts +14 -0
- package/dist/commands/watch.js +190 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -0
- package/dist/services/DatabaseService.d.ts +113 -0
- package/dist/services/DatabaseService.js +343 -0
- package/dist/services/DatabaseService.js.map +1 -0
- package/dist/services/FileSystemService.d.ts +100 -0
- package/dist/services/FileSystemService.js +237 -0
- package/dist/services/FileSystemService.js.map +1 -0
- package/dist/services/MigrationBuilder.d.ts +106 -0
- package/dist/services/MigrationBuilder.js +193 -0
- package/dist/services/MigrationBuilder.js.map +1 -0
- package/dist/services/Orchestrator.d.ts +155 -0
- package/dist/services/Orchestrator.js +622 -0
- package/dist/services/Orchestrator.js.map +1 -0
- package/dist/services/StateService.d.ts +169 -0
- package/dist/services/StateService.js +463 -0
- package/dist/services/StateService.js.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/badge.d.ts +14 -0
- package/dist/ui/badge.js +28 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/branding.d.ts +9 -0
- package/dist/ui/branding.js +35 -0
- package/dist/ui/branding.js.map +1 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/results.d.ts +10 -0
- package/dist/ui/results.js +62 -0
- package/dist/ui/results.js.map +1 -0
- package/dist/ui/spinner.d.ts +5 -0
- package/dist/ui/spinner.js +8 -0
- package/dist/ui/spinner.js.map +1 -0
- package/dist/utils/config.d.ts +12 -0
- package/dist/utils/config.js +67 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/createEmptyBuildLog.d.ts +1 -0
- package/dist/utils/createEmptyBuildLog.js +10 -0
- package/dist/utils/createEmptyBuildLog.js.map +1 -0
- package/dist/utils/ensureDirectories.d.ts +4 -0
- package/dist/utils/ensureDirectories.js +23 -0
- package/dist/utils/ensureDirectories.js.map +1 -0
- package/dist/utils/fileExists.d.ts +1 -0
- package/dist/utils/fileExists.js +11 -0
- package/dist/utils/fileExists.js.map +1 -0
- package/dist/utils/findProjectRoot.d.ts +1 -0
- package/dist/utils/findProjectRoot.js +25 -0
- package/dist/utils/findProjectRoot.js.map +1 -0
- package/dist/utils/getErrorMessage.d.ts +9 -0
- package/dist/utils/getErrorMessage.js +14 -0
- package/dist/utils/getErrorMessage.js.map +1 -0
- package/dist/utils/getNextTimestamp.d.ts +2 -0
- package/dist/utils/getNextTimestamp.js +12 -0
- package/dist/utils/getNextTimestamp.js.map +1 -0
- package/dist/utils/isWipTemplate.d.ts +1 -0
- package/dist/utils/isWipTemplate.js +6 -0
- package/dist/utils/isWipTemplate.js.map +1 -0
- package/dist/utils/logger.d.ts +9 -0
- package/dist/utils/logger.js +12 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/safeCreate.d.ts +1 -0
- package/dist/utils/safeCreate.js +16 -0
- package/dist/utils/safeCreate.js.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import chalk from 'chalk';
|
|
54
|
+
// src/commands/build.ts
|
|
55
|
+
import { Command } from 'commander';
|
|
56
|
+
import figures from 'figures';
|
|
57
|
+
import { Orchestrator } from '../services/Orchestrator.js';
|
|
58
|
+
import { createSpinner, renderBranding, renderResults } from '../ui/index.js';
|
|
59
|
+
import { getConfig } from '../utils/config.js';
|
|
60
|
+
import { findProjectRoot } from '../utils/findProjectRoot.js';
|
|
61
|
+
import { getErrorMessage } from '../utils/getErrorMessage.js';
|
|
62
|
+
export const buildCommand = new Command('build')
|
|
63
|
+
.description('Build migrations from templates')
|
|
64
|
+
.option('-f, --force', 'Force building of all templates, irrespective of changes')
|
|
65
|
+
.option('-a, --apply', 'Apply the built templates')
|
|
66
|
+
.option('-b, --bundle', 'Bundle all templates into a single migration')
|
|
67
|
+
.action(async (options) => {
|
|
68
|
+
let exitCode = 0;
|
|
69
|
+
try {
|
|
70
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
71
|
+
try {
|
|
72
|
+
// Build subtitle with options
|
|
73
|
+
const parts = ['Build migrations'];
|
|
74
|
+
if (options.force)
|
|
75
|
+
parts.push('(forced)');
|
|
76
|
+
if (options.bundle)
|
|
77
|
+
parts.push('(bundled)');
|
|
78
|
+
const subtitle = parts.join(' ');
|
|
79
|
+
await renderBranding({ subtitle });
|
|
80
|
+
const spinner = createSpinner('Building templates...').start();
|
|
81
|
+
// Initialize Orchestrator
|
|
82
|
+
const projectRoot = await findProjectRoot();
|
|
83
|
+
const config = await getConfig(projectRoot);
|
|
84
|
+
const orchestrator = __addDisposableResource(env_1, await Orchestrator.create(projectRoot, config, { silent: true }), true);
|
|
85
|
+
// Execute build operation
|
|
86
|
+
const buildResult = await orchestrator.build({
|
|
87
|
+
force: options.force,
|
|
88
|
+
bundle: options.bundle,
|
|
89
|
+
silent: true,
|
|
90
|
+
});
|
|
91
|
+
let result = buildResult;
|
|
92
|
+
// If apply flag is set, also apply the templates
|
|
93
|
+
if (options.apply) {
|
|
94
|
+
spinner.text = 'Applying templates...';
|
|
95
|
+
const applyResult = await orchestrator.apply({
|
|
96
|
+
force: options.force,
|
|
97
|
+
silent: true,
|
|
98
|
+
});
|
|
99
|
+
// Merge results
|
|
100
|
+
result = {
|
|
101
|
+
errors: [...buildResult.errors, ...applyResult.errors],
|
|
102
|
+
applied: applyResult.applied,
|
|
103
|
+
built: buildResult.built,
|
|
104
|
+
skipped: [...buildResult.skipped, ...applyResult.skipped],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
spinner.stop();
|
|
108
|
+
// Show results
|
|
109
|
+
renderResults(result, {
|
|
110
|
+
showBuild: true,
|
|
111
|
+
showApply: !!options.apply,
|
|
112
|
+
});
|
|
113
|
+
exitCode = result.errors.length > 0 ? 1 : 0;
|
|
114
|
+
}
|
|
115
|
+
catch (e_1) {
|
|
116
|
+
env_1.error = e_1;
|
|
117
|
+
env_1.hasError = true;
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
const result_1 = __disposeResources(env_1);
|
|
121
|
+
if (result_1)
|
|
122
|
+
await result_1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.log();
|
|
127
|
+
console.log(chalk.red(`${figures.cross} Error building templates:`));
|
|
128
|
+
console.log(chalk.red(getErrorMessage(error)));
|
|
129
|
+
exitCode = 1;
|
|
130
|
+
}
|
|
131
|
+
// Exit AFTER the using block has completed, ensuring dispose() runs
|
|
132
|
+
process.exit(exitCode);
|
|
133
|
+
});
|
|
134
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,wBAAwB;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAQ9D,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,aAAa,EAAE,0DAA0D,CAAC;KACjF,MAAM,CAAC,aAAa,EAAE,2BAA2B,CAAC;KAClD,MAAM,CAAC,cAAc,EAAE,8CAA8C,CAAC;KACtE,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,EAAE;IACtC,IAAI,QAAQ,GAAG,CAAC,CAAC;IAEjB,IAAI,CAAC;;;YACH,8BAA8B;YAC9B,MAAM,KAAK,GAAa,CAAC,kBAAkB,CAA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AAW,CAAC,OAAO;oBAC5B,KAAK,EAAE,WAAW,CAAC,KAAK;oBACxB,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC;iBAC1D,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,eAAe;YACf,aAAa,CAAC,MAAM,EAAE;gBACpB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK;aAC3B,CAAC,CAAC;YAEH,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;KAE7C;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,4BAA4B,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/C,QAAQ,GAAG,CAAC,CAAC;IACf,CAAC;IAED,oEAAoE;IACpE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { select } from '@inquirer/prompts';
|
|
54
|
+
import chalk from 'chalk';
|
|
55
|
+
// src/commands/clear.ts
|
|
56
|
+
import { Command } from 'commander';
|
|
57
|
+
import figures from 'figures';
|
|
58
|
+
import { Orchestrator } from '../services/Orchestrator.js';
|
|
59
|
+
import { createSpinner, renderBranding } from '../ui/index.js';
|
|
60
|
+
import { getConfig, resetConfig } from '../utils/config.js';
|
|
61
|
+
import { findProjectRoot } from '../utils/findProjectRoot.js';
|
|
62
|
+
import { getErrorMessage, isPromptExit } from '../utils/getErrorMessage.js';
|
|
63
|
+
const clearOptions = [
|
|
64
|
+
{ name: 'Clear local build logs', value: 'local' },
|
|
65
|
+
{ name: 'Clear shared build logs', value: 'shared' },
|
|
66
|
+
{ name: 'Reset config and logs to initial defaults', value: 'full_reset' },
|
|
67
|
+
];
|
|
68
|
+
async function handleClearAction(value, projectRoot) {
|
|
69
|
+
const spinner = createSpinner('Processing...').start();
|
|
70
|
+
try {
|
|
71
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
72
|
+
try {
|
|
73
|
+
const config = await getConfig(projectRoot);
|
|
74
|
+
const orchestrator = __addDisposableResource(env_1, await Orchestrator.create(projectRoot, config, { silent: true }), true);
|
|
75
|
+
switch (value) {
|
|
76
|
+
case 'local':
|
|
77
|
+
await orchestrator.clearBuildLogs('local');
|
|
78
|
+
spinner.succeed('Cleared local build logs');
|
|
79
|
+
break;
|
|
80
|
+
case 'shared':
|
|
81
|
+
await orchestrator.clearBuildLogs('shared');
|
|
82
|
+
spinner.succeed('Cleared shared build logs');
|
|
83
|
+
break;
|
|
84
|
+
case 'full_reset':
|
|
85
|
+
await resetConfig(projectRoot);
|
|
86
|
+
await orchestrator.clearBuildLogs('both');
|
|
87
|
+
spinner.succeed('Reset config and cleared all build logs');
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
throw new Error('Invalid option');
|
|
91
|
+
}
|
|
92
|
+
console.log(chalk.green(`${figures.tick} Reset complete`));
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
catch (e_1) {
|
|
96
|
+
env_1.error = e_1;
|
|
97
|
+
env_1.hasError = true;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
const result_1 = __disposeResources(env_1);
|
|
101
|
+
if (result_1)
|
|
102
|
+
await result_1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
spinner.fail('Failed to clear');
|
|
107
|
+
console.log(chalk.red(`${figures.cross} ${getErrorMessage(err)}`));
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export const clearCommand = new Command('clear')
|
|
112
|
+
.description('Clear build logs or reset configuration')
|
|
113
|
+
.option('--local', 'Clear local build logs (non-interactive)')
|
|
114
|
+
.option('--shared', 'Clear shared build logs (non-interactive)')
|
|
115
|
+
.option('--reset', 'Reset config and logs to initial defaults (non-interactive)')
|
|
116
|
+
.action(async (options) => {
|
|
117
|
+
let exitCode = 0;
|
|
118
|
+
try {
|
|
119
|
+
await renderBranding({ subtitle: 'Maintenance' });
|
|
120
|
+
const projectRoot = await findProjectRoot();
|
|
121
|
+
// Non-interactive mode via flags
|
|
122
|
+
if (options.local) {
|
|
123
|
+
exitCode = await handleClearAction('local', projectRoot);
|
|
124
|
+
}
|
|
125
|
+
else if (options.shared) {
|
|
126
|
+
exitCode = await handleClearAction('shared', projectRoot);
|
|
127
|
+
}
|
|
128
|
+
else if (options.reset) {
|
|
129
|
+
exitCode = await handleClearAction('full_reset', projectRoot);
|
|
130
|
+
}
|
|
131
|
+
else if (!process.stdin.isTTY) {
|
|
132
|
+
// Interactive mode requires TTY
|
|
133
|
+
console.log(chalk.red(`${figures.cross} Interactive mode requires a TTY.`));
|
|
134
|
+
console.log(chalk.dim('Use --local, --shared, or --reset flags for non-interactive mode.'));
|
|
135
|
+
exitCode = 1;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Show interactive selection
|
|
139
|
+
const answer = await select({
|
|
140
|
+
message: 'Select what to clear:',
|
|
141
|
+
choices: clearOptions,
|
|
142
|
+
});
|
|
143
|
+
exitCode = await handleClearAction(answer, projectRoot);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// Handle Ctrl+C gracefully
|
|
148
|
+
if (isPromptExit(error)) {
|
|
149
|
+
exitCode = 0;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log();
|
|
153
|
+
console.log(chalk.red(`${figures.cross} Error accessing project:`));
|
|
154
|
+
console.log(chalk.red(getErrorMessage(error)));
|
|
155
|
+
exitCode = 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// Exit AFTER the await using block has completed, ensuring dispose() runs
|
|
159
|
+
process.exit(exitCode);
|
|
160
|
+
});
|
|
161
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../src/commands/clear.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,wBAAwB;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE5E,MAAM,YAAY,GAAG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CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,mCAAmC,CAAC,CAAC,CAAC;YAC5E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,mEAAmE,CAAC,CAAC,CAAC;YAC5F,QAAQ,GAAG,CAAC,CAAC;QACf,CAAC;aAAM,CAAC;YACN,6BAA6B;YAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;gBAC1B,OAAO,EAAE,uBAAuB;gBAChC,OAAO,EAAE,YAAY;aACtB,CAAC,CAAC;YAEH,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2BAA2B;QAC3B,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,QAAQ,GAAG,CAAC,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,2BAA2B,CAAC,CAAC,CAAC;YACpE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/C,QAAQ,GAAG,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// src/commands/init.ts
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import figures from 'figures';
|
|
7
|
+
import { CONFIG_FILE } from '../constants.js';
|
|
8
|
+
import { createSpinner, renderBranding } from '../ui/index.js';
|
|
9
|
+
import { getConfig, saveConfig } from '../utils/config.js';
|
|
10
|
+
import { createEmptyBuildLog } from '../utils/createEmptyBuildLog.js';
|
|
11
|
+
import { ensureDirectories } from '../utils/ensureDirectories.js';
|
|
12
|
+
import { fileExists } from '../utils/fileExists.js';
|
|
13
|
+
import { findProjectRoot } from '../utils/findProjectRoot.js';
|
|
14
|
+
import { getErrorMessage } from '../utils/getErrorMessage.js';
|
|
15
|
+
export const initCommand = new Command('init')
|
|
16
|
+
.description('Initialize srtd in the current project')
|
|
17
|
+
.action(async () => {
|
|
18
|
+
try {
|
|
19
|
+
await renderBranding({ subtitle: 'Initialize Project' });
|
|
20
|
+
const spinner = createSpinner('Initializing srtd...').start();
|
|
21
|
+
const baseDir = await findProjectRoot();
|
|
22
|
+
const config = await getConfig(baseDir);
|
|
23
|
+
const configPath = path.join(baseDir, CONFIG_FILE);
|
|
24
|
+
spinner.stop();
|
|
25
|
+
// Check and create config file
|
|
26
|
+
if (await fileExists(configPath)) {
|
|
27
|
+
console.log(chalk.cyan(`${figures.info} ${CONFIG_FILE} already exists`));
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
await saveConfig(baseDir, {});
|
|
31
|
+
console.log(chalk.green(`${figures.tick} Created ${CONFIG_FILE} with default configuration`));
|
|
32
|
+
}
|
|
33
|
+
// Ensure directories exist
|
|
34
|
+
const dirs = await ensureDirectories(baseDir);
|
|
35
|
+
if (dirs.templateDir) {
|
|
36
|
+
console.log(chalk.green(`${figures.tick} Created template directory ${config.templateDir}`));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(chalk.cyan(`${figures.info} Template directory ${config.templateDir} already exists`));
|
|
40
|
+
}
|
|
41
|
+
if (dirs.migrationDir) {
|
|
42
|
+
console.log(chalk.green(`${figures.tick} Created migration directory ${config.migrationDir}`));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(chalk.cyan(`${figures.info} Migration directory ${config.migrationDir} already exists`));
|
|
46
|
+
}
|
|
47
|
+
// Create build logs
|
|
48
|
+
const buildLogCreated = await createEmptyBuildLog(path.join(baseDir, config.buildLog));
|
|
49
|
+
const localBuildLogCreated = await createEmptyBuildLog(path.join(baseDir, config.localBuildLog));
|
|
50
|
+
if (buildLogCreated) {
|
|
51
|
+
console.log(chalk.green(`${figures.tick} Created build log at ${config.buildLog}`));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log(chalk.cyan(`${figures.info} Build log already exists at ${config.buildLog}`));
|
|
55
|
+
}
|
|
56
|
+
if (localBuildLogCreated) {
|
|
57
|
+
console.log(chalk.green(`${figures.tick} Created local build log at ${config.localBuildLog}`));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
console.log(chalk.cyan(`${figures.info} Local build log already exists at ${config.localBuildLog}`));
|
|
61
|
+
}
|
|
62
|
+
// Update .gitignore
|
|
63
|
+
const gitignorePath = path.join(baseDir, '.gitignore');
|
|
64
|
+
const ignoreEntry = path.basename(config.localBuildLog);
|
|
65
|
+
let content = '';
|
|
66
|
+
try {
|
|
67
|
+
content = await fs.readFile(gitignorePath, 'utf-8');
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Ignore if file doesn't exist
|
|
71
|
+
}
|
|
72
|
+
if (!content.includes(ignoreEntry)) {
|
|
73
|
+
content = `${content.trim()}\n\n# srtd's local logs should not be committed, as they're per-environment specific\n${ignoreEntry}\n`;
|
|
74
|
+
await fs.writeFile(gitignorePath, content);
|
|
75
|
+
console.log(chalk.green(`${figures.tick} Added ${ignoreEntry} to .gitignore`));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(chalk.cyan(`${figures.info} .gitignore already contains ${ignoreEntry}`));
|
|
79
|
+
}
|
|
80
|
+
console.log();
|
|
81
|
+
console.log(chalk.green(`${figures.tick} Initialization complete!`));
|
|
82
|
+
console.log(chalk.dim('Your project is ready to use srtd. Start by creating templates in the templates directory.'));
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.log();
|
|
87
|
+
console.log(chalk.red(`${figures.cross} Failed to initialize: ${getErrorMessage(error)}`));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,wCAAwC,CAAC;KACrD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,cAAc,CAAC,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC,CAAC;QAEzD,MAAM,OAAO,GAAG,aAAa,CAAC,sBAAsB,CAAC,CAAC,KAAK,EAAE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
1
|
+
// src/commands/menu.ts
|
|
2
|
+
import { select } from '@inquirer/prompts';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import figures from 'figures';
|
|
5
|
+
import { renderBranding } from '../ui/index.js';
|
|
6
|
+
import { getErrorMessage, isPromptExit } from '../utils/getErrorMessage.js';
|
|
7
|
+
const menuCommands = [
|
|
8
|
+
{ name: 'init - Initialize srtd in the current project', value: 'init' },
|
|
9
|
+
{ name: 'build - Build migrations from templates', value: 'build' },
|
|
10
|
+
{ name: 'apply - Apply built migrations to the database', value: 'apply' },
|
|
11
|
+
{ name: 'watch - Watch templates for changes and auto-apply', value: 'watch' },
|
|
12
|
+
{ name: 'register - Register templates to track them', value: 'register' },
|
|
13
|
+
{ name: 'promote - Promote a WIP template', value: 'promote' },
|
|
14
|
+
{ name: 'clear - Clear build logs or reset configuration', value: 'clear' },
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Shows the interactive menu and executes the selected command.
|
|
18
|
+
*/
|
|
19
|
+
export async function showMenu() {
|
|
20
|
+
try {
|
|
21
|
+
await renderBranding();
|
|
22
|
+
const selectedCommand = await select({
|
|
23
|
+
message: 'Select a command:',
|
|
24
|
+
choices: menuCommands,
|
|
25
|
+
});
|
|
26
|
+
// Execute the selected command by dynamically importing it
|
|
27
|
+
switch (selectedCommand) {
|
|
28
|
+
case 'init': {
|
|
29
|
+
const { initCommand } = await import('./init.js');
|
|
30
|
+
await initCommand.parseAsync(['node', 'srtd', 'init']);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case 'build': {
|
|
34
|
+
const { buildCommand } = await import('./build.js');
|
|
35
|
+
await buildCommand.parseAsync(['node', 'srtd', 'build']);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case 'apply': {
|
|
39
|
+
const { applyCommand } = await import('./apply.js');
|
|
40
|
+
await applyCommand.parseAsync(['node', 'srtd', 'apply']);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'watch': {
|
|
44
|
+
const { watchCommand } = await import('./watch.js');
|
|
45
|
+
await watchCommand.parseAsync(['node', 'srtd', 'watch']);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'register': {
|
|
49
|
+
const { registerCommand } = await import('./register.js');
|
|
50
|
+
await registerCommand.parseAsync(['node', 'srtd', 'register']);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case 'promote': {
|
|
54
|
+
const { promoteCommand } = await import('./promote.js');
|
|
55
|
+
await promoteCommand.parseAsync(['node', 'srtd', 'promote']);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'clear': {
|
|
59
|
+
const { clearCommand } = await import('./clear.js');
|
|
60
|
+
await clearCommand.parseAsync(['node', 'srtd', 'clear']);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// Handle Ctrl+C gracefully
|
|
67
|
+
if (isPromptExit(error)) {
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
console.log();
|
|
71
|
+
console.log(chalk.red(`${figures.cross} Error:`));
|
|
72
|
+
console.log(chalk.red(getErrorMessage(error)));
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../../src/commands/menu.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE5E,MAAM,YAAY,GAAG;IACnB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