@ftschopp/dynatable-migrations 1.3.2 → 2.0.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.
@@ -33,104 +33,82 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ConfigLoader = void 0;
36
+ exports.createDefaultConfig = void 0;
37
37
  exports.loadConfig = loadConfig;
38
38
  const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
+ const CONFIG_FILE_NAMES = [
41
+ 'dynatable.config.js',
42
+ 'dynatable.config.json',
43
+ '.dynatablerc.js',
44
+ '.dynatablerc.json',
45
+ ];
46
+ const findConfigFile = () => {
47
+ const root = path.parse(process.cwd()).root;
48
+ const climb = (dir) => {
49
+ if (dir === root)
50
+ return null;
51
+ const match = CONFIG_FILE_NAMES.map((n) => path.join(dir, n)).find((p) => fs.existsSync(p));
52
+ return match ?? climb(path.dirname(dir));
53
+ };
54
+ return climb(process.cwd());
55
+ };
56
+ const validateAndNormalizeConfig = (config) => {
57
+ if (!config.tableName) {
58
+ throw new Error("Configuration error: 'tableName' is required");
59
+ }
60
+ // DynamoDB table-name rules: 3-255 chars, alphanumeric plus . _ -.
61
+ // Cheapest place to catch typos before the SDK rejects the request.
62
+ if (!/^[a-zA-Z0-9._-]{3,255}$/.test(config.tableName)) {
63
+ throw new Error(`Configuration error: 'tableName' must be 3-255 characters and contain only ` +
64
+ `letters, numbers, '.', '_', or '-' (got: ${JSON.stringify(config.tableName)})`);
65
+ }
66
+ if (!config.client?.region) {
67
+ throw new Error("Configuration error: 'client.region' is required");
68
+ }
69
+ const migrationsDir = config.migrationsDir || './migrations';
70
+ // We don't auto-create the directory here — `dynatable-migrate init`
71
+ // and `create` both handle that. But if the user explicitly pointed
72
+ // at something that exists and isn't a directory, fail loudly.
73
+ if (fs.existsSync(migrationsDir) && !fs.statSync(migrationsDir).isDirectory()) {
74
+ throw new Error(`Configuration error: 'migrationsDir' (${migrationsDir}) exists but is not a directory.`);
75
+ }
76
+ return {
77
+ tableName: config.tableName,
78
+ client: {
79
+ region: config.client.region,
80
+ endpoint: config.client.endpoint,
81
+ credentials: config.client.credentials,
82
+ },
83
+ migrationsDir,
84
+ trackingPrefix: config.trackingPrefix || '_SCHEMA#VERSION',
85
+ gsi1Name: config.gsi1Name || 'GSI1',
86
+ };
87
+ };
40
88
  /**
41
- * Load migration configuration
89
+ * Get config from environment or file
42
90
  */
43
- class ConfigLoader {
44
- constructor(configPath) {
45
- this.configPath = configPath || this.findConfigFile() || 'dynatable.config.js';
46
- }
47
- /**
48
- * Find config file in current directory or parent directories
49
- */
50
- findConfigFile() {
51
- const configFileNames = [
52
- 'dynatable.config.js',
53
- 'dynatable.config.json',
54
- '.dynatablerc.js',
55
- '.dynatablerc.json',
56
- ];
57
- let currentDir = process.cwd();
58
- const root = path.parse(currentDir).root;
59
- while (currentDir !== root) {
60
- for (const fileName of configFileNames) {
61
- const filePath = path.join(currentDir, fileName);
62
- if (fs.existsSync(filePath)) {
63
- return filePath;
64
- }
65
- }
66
- currentDir = path.dirname(currentDir);
67
- }
68
- return null;
91
+ async function loadConfig(configPath) {
92
+ const resolved = configPath || findConfigFile() || 'dynatable.config.js';
93
+ if (!fs.existsSync(resolved)) {
94
+ throw new Error(`Configuration file not found: ${resolved}\n\nPlease create a dynatable.config.js file in your project root.`);
69
95
  }
70
- /**
71
- * Load configuration from file
72
- */
73
- async load() {
74
- if (!fs.existsSync(this.configPath)) {
75
- throw new Error(`Configuration file not found: ${this.configPath}\n\nPlease create a dynatable.config.js file in your project root.`);
76
- }
77
- try {
78
- let config;
79
- if (this.configPath.endsWith('.json')) {
80
- const content = fs.readFileSync(this.configPath, 'utf-8');
81
- config = JSON.parse(content);
82
- }
83
- else {
84
- // JavaScript config file
85
- const module = await Promise.resolve(`${this.configPath}`).then(s => __importStar(require(s)));
86
- config = module.default || module;
87
- }
88
- return this.validateAndNormalizeConfig(config);
89
- }
90
- catch (error) {
91
- throw new Error(`Failed to load configuration: ${error.message}`);
92
- }
96
+ try {
97
+ const config = resolved.endsWith('.json')
98
+ ? JSON.parse(fs.readFileSync(resolved, 'utf-8'))
99
+ : await Promise.resolve(`${resolved}`).then(s => __importStar(require(s))).then((m) => m.default || m);
100
+ return validateAndNormalizeConfig(config);
93
101
  }
94
- /**
95
- * Validate and normalize configuration
96
- */
97
- validateAndNormalizeConfig(config) {
98
- if (!config.tableName) {
99
- throw new Error("Configuration error: 'tableName' is required");
100
- }
101
- // DynamoDB table-name rules: 3-255 chars, alphanumeric plus . _ -.
102
- // Cheapest place to catch typos before the SDK rejects the request.
103
- if (!/^[a-zA-Z0-9._-]{3,255}$/.test(config.tableName)) {
104
- throw new Error(`Configuration error: 'tableName' must be 3-255 characters and contain only ` +
105
- `letters, numbers, '.', '_', or '-' (got: ${JSON.stringify(config.tableName)})`);
106
- }
107
- if (!config.client?.region) {
108
- throw new Error("Configuration error: 'client.region' is required");
109
- }
110
- const migrationsDir = config.migrationsDir || './migrations';
111
- // We don't auto-create the directory here — `dynatable-migrate init`
112
- // and `create` both handle that. But if the user explicitly pointed
113
- // at something that exists and isn't a directory, fail loudly.
114
- if (fs.existsSync(migrationsDir) && !fs.statSync(migrationsDir).isDirectory()) {
115
- throw new Error(`Configuration error: 'migrationsDir' (${migrationsDir}) exists but is not a directory.`);
116
- }
117
- return {
118
- tableName: config.tableName,
119
- client: {
120
- region: config.client.region,
121
- endpoint: config.client.endpoint,
122
- credentials: config.client.credentials,
123
- },
124
- migrationsDir,
125
- trackingPrefix: config.trackingPrefix || '_SCHEMA#VERSION',
126
- gsi1Name: config.gsi1Name || 'GSI1',
127
- };
102
+ catch (error) {
103
+ const message = error instanceof Error ? error.message : String(error);
104
+ throw new Error(`Failed to load configuration: ${message}`);
128
105
  }
129
- /**
130
- * Create default config file
131
- */
132
- static createDefaultConfig(targetPath) {
133
- const defaultConfig = `module.exports = {
106
+ }
107
+ /**
108
+ * Create default config file in the given path.
109
+ */
110
+ const createDefaultConfig = (targetPath) => {
111
+ const defaultConfig = `module.exports = {
134
112
  // DynamoDB table name
135
113
  tableName: "MyTable",
136
114
 
@@ -158,16 +136,8 @@ class ConfigLoader {
158
136
  gsi1Name: "GSI1",
159
137
  };
160
138
  `;
161
- fs.writeFileSync(targetPath, defaultConfig, 'utf-8');
162
- console.log(`✅ Created config file: ${targetPath}`);
163
- }
164
- }
165
- exports.ConfigLoader = ConfigLoader;
166
- /**
167
- * Get config from environment or file
168
- */
169
- async function loadConfig(configPath) {
170
- const loader = new ConfigLoader(configPath);
171
- return loader.load();
172
- }
139
+ fs.writeFileSync(targetPath, defaultConfig, 'utf-8');
140
+ console.log(`✅ Created config file: ${targetPath}`);
141
+ };
142
+ exports.createDefaultConfig = createDefaultConfig;
173
143
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,gCAGC;AA9JD,uCAAyB;AACzB,2CAA6B;AAG7B;;GAEG;AACH,MAAa,YAAY;IAGvB,YAAY,UAAmB;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,IAAI,IAAI,CAAC,cAAc,EAAE,IAAI,qBAAqB,CAAC;IACjF,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,MAAM,eAAe,GAAG;YACtB,qBAAqB;YACrB,uBAAuB;YACvB,iBAAiB;YACjB,mBAAmB;SACpB,CAAC;QAEF,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;QAEzC,OAAO,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3B,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACvC,MAAM,QAAQ,GAAG,IAAI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c,EAAE,IAAI,qBAAqB,CAAC;IAEzE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,iCAAiC,QAAQ,oEAAoE,CAC9G,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAoB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YACxD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAChD,CAAC,CAAC,MAAM,mBAAO,QAAQ,wCAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;QAEvD,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC;AAED;;GAEG;AACI,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAQ,EAAE;IAC9D,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BvB,CAAC;IAEA,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;AACtD,CAAC,CAAC;AAhCW,QAAA,mBAAmB,uBAgC9B"}
@@ -1,71 +1,25 @@
1
1
  import { MigrationFile } from '../types';
2
2
  /**
3
- * Load all migration files from directory
3
+ * Calculate checksum of a file
4
4
  */
5
- export declare class MigrationLoader {
6
- private migrationsDir;
7
- /**
8
- * Memoized result of `loadMigrations()`. Set on first successful load and
9
- * reused for the lifetime of the loader instance. The runner consults the
10
- * loader many times per command (per-version checksum check, per-rollback
11
- * lookup, status display) — without this, each call re-runs `readdirSync`,
12
- * re-imports every migration module, and re-md5s every file, turning an
13
- * O(N) operation into O(N²) in IO and require()s. Call `invalidateCache()`
14
- * if you need to pick up newly-added files mid-process.
15
- */
16
- private cachedMigrations;
17
- constructor(migrationsDir: string);
18
- /**
19
- * Calculate checksum of a file
20
- */
21
- calculateChecksum(filePath: string): string;
22
- /**
23
- * Drop the in-memory cache so the next `loadMigrations()` call re-reads
24
- * the directory. Use after generating a new migration file mid-process.
25
- */
26
- invalidateCache(): void;
27
- /**
28
- * Load all migration files
29
- */
5
+ export declare const calculateChecksum: (filePath: string) => string;
6
+ export interface MigrationLoaderHandle {
30
7
  loadMigrations(): Promise<MigrationFile[]>;
31
- /**
32
- * Load single migration file
33
- */
34
- private loadMigration;
35
- /**
36
- * Register ts-node for TypeScript file loading.
37
- *
38
- * `ts-node` and `typescript` are declared as optional peerDependencies of
39
- * this package — consumers who only ever write `.js` migrations don't pay
40
- * the install cost. The lazy `require` here keeps the module out of the
41
- * runtime graph until a `.ts` migration is actually loaded, so JS-only
42
- * users never hit this path.
43
- */
44
- private registerTsNode;
45
- /**
46
- * Validate migration file name format
47
- * Expected: 1.0.0_migration_name.ts (semver format)
48
- */
49
- private isValidMigrationFileName;
50
- /**
51
- * Parse version and name from file name
52
- */
53
- private parseMigrationFileName;
54
- /**
55
- * Validate migration structure
56
- */
57
- private validateMigration;
58
- /**
59
- * Get pending migrations (not yet applied)
60
- */
8
+ invalidateCache(): void;
61
9
  getPendingMigrations(appliedVersions: string[]): Promise<MigrationFile[]>;
62
- /**
63
- * Get migration by version
64
- */
65
10
  getMigration(version: string): Promise<MigrationFile | null>;
66
- /**
67
- * Generate next version number (increments patch by default)
68
- */
69
11
  getNextVersion(): Promise<string>;
12
+ calculateChecksum(filePath: string): string;
70
13
  }
14
+ /**
15
+ * Create a migration loader for the given directory.
16
+ *
17
+ * Internally memoizes `loadMigrations()` — the runner consults the loader
18
+ * many times per command (per-version checksum check, per-rollback
19
+ * lookup, status display) — without this, each call re-runs `readdirSync`,
20
+ * re-imports every migration module, and re-md5s every file, turning an
21
+ * O(N) operation into O(N²) in IO and require()s. Call `invalidateCache()`
22
+ * if you need to pick up newly-added files mid-process.
23
+ */
24
+ export declare const createMigrationLoader: (migrationsDir: string) => MigrationLoaderHandle;
71
25
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/core/loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,aAAa,EAAE,MAAM,UAAU,CAAC;AAwBpD;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,aAAa,CAAS;IAC9B;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB,CAAgC;gBAE5C,aAAa,EAAE,MAAM;IAIjC;;OAEG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAK3C;;;OAGG;IACH,eAAe,IAAI,IAAI;IAIvB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAuChD;;OAEG;YACW,aAAa;IA4D3B;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;IAkCtB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAKhC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAkB9B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAkBzB;;OAEG;IACG,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAK/E;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAKlE;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CA6BxC"}
1
+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