@pgpmjs/core 4.5.3 → 4.6.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/core/class/pgpm.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface InitModuleOptions {
|
|
|
23
23
|
noTty?: boolean;
|
|
24
24
|
toolName?: string;
|
|
25
25
|
answers?: Record<string, any>;
|
|
26
|
+
/**
|
|
27
|
+
* Parent directory where the module should be created.
|
|
28
|
+
* When provided, bypasses createModuleDirectory() and creates the module at outputDir/name.
|
|
29
|
+
* Must be an absolute path or relative to workspace root.
|
|
30
|
+
*/
|
|
31
|
+
outputDir?: string;
|
|
26
32
|
}
|
|
27
33
|
export declare class PgpmPackage {
|
|
28
34
|
cwd: string;
|
package/core/class/pgpm.js
CHANGED
|
@@ -364,7 +364,19 @@ class PgpmPackage {
|
|
|
364
364
|
}
|
|
365
365
|
async initModule(options) {
|
|
366
366
|
this.ensureWorkspace();
|
|
367
|
-
|
|
367
|
+
// If outputDir is provided, use it directly instead of createModuleDirectory
|
|
368
|
+
let targetPath;
|
|
369
|
+
if (options.outputDir) {
|
|
370
|
+
// Resolve outputDir relative to workspace if not absolute
|
|
371
|
+
const resolvedOutputDir = path_1.default.isAbsolute(options.outputDir)
|
|
372
|
+
? options.outputDir
|
|
373
|
+
: path_1.default.resolve(this.workspacePath, options.outputDir);
|
|
374
|
+
targetPath = path_1.default.join(resolvedOutputDir, options.name);
|
|
375
|
+
fs_1.default.mkdirSync(targetPath, { recursive: true });
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
targetPath = this.createModuleDirectory(options.name);
|
|
379
|
+
}
|
|
368
380
|
const answers = {
|
|
369
381
|
...options.answers,
|
|
370
382
|
name: options.name,
|
package/esm/core/class/pgpm.js
CHANGED
|
@@ -325,7 +325,19 @@ export class PgpmPackage {
|
|
|
325
325
|
}
|
|
326
326
|
async initModule(options) {
|
|
327
327
|
this.ensureWorkspace();
|
|
328
|
-
|
|
328
|
+
// If outputDir is provided, use it directly instead of createModuleDirectory
|
|
329
|
+
let targetPath;
|
|
330
|
+
if (options.outputDir) {
|
|
331
|
+
// Resolve outputDir relative to workspace if not absolute
|
|
332
|
+
const resolvedOutputDir = path.isAbsolute(options.outputDir)
|
|
333
|
+
? options.outputDir
|
|
334
|
+
: path.resolve(this.workspacePath, options.outputDir);
|
|
335
|
+
targetPath = path.join(resolvedOutputDir, options.name);
|
|
336
|
+
fs.mkdirSync(targetPath, { recursive: true });
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
targetPath = this.createModuleDirectory(options.name);
|
|
340
|
+
}
|
|
329
341
|
const answers = {
|
|
330
342
|
...options.answers,
|
|
331
343
|
name: options.name,
|
|
@@ -92,8 +92,10 @@ const installMissingModules = async (moduleDir, missingModules) => {
|
|
|
92
92
|
await moduleProject.installModules(...missingNames);
|
|
93
93
|
console.log('Modules installed successfully.');
|
|
94
94
|
};
|
|
95
|
-
const exportMigrationsToDisk = async ({ project, options, database, databaseId, databaseName, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username }) => {
|
|
95
|
+
const exportMigrationsToDisk = async ({ project, options, database, databaseId, databaseName, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username, serviceOutdir }) => {
|
|
96
96
|
outdir = outdir + '/';
|
|
97
|
+
// Use serviceOutdir for service module, defaulting to outdir if not provided
|
|
98
|
+
const svcOutdir = (serviceOutdir || outdir.slice(0, -1)) + '/';
|
|
97
99
|
const pgPool = getPgPool({
|
|
98
100
|
...options.pg,
|
|
99
101
|
database
|
|
@@ -153,11 +155,11 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
|
|
|
153
155
|
const metaDesc = metaExtensionDesc || `${metaExtensionName} service utilities for managing domains, APIs, and services`;
|
|
154
156
|
// Detect missing modules at workspace level and prompt user
|
|
155
157
|
const svcMissingResult = await detectMissingModules(project, [...SERVICE_REQUIRED_EXTENSIONS], prompter);
|
|
156
|
-
// Create/prepare the module directory
|
|
158
|
+
// Create/prepare the module directory (use serviceOutdir if provided)
|
|
157
159
|
const svcModuleDir = await preparePackage({
|
|
158
160
|
project,
|
|
159
161
|
author,
|
|
160
|
-
outdir,
|
|
162
|
+
outdir: svcOutdir,
|
|
161
163
|
name: metaExtensionName,
|
|
162
164
|
description: metaDesc,
|
|
163
165
|
extensions: [...SERVICE_REQUIRED_EXTENSIONS],
|
|
@@ -211,12 +213,13 @@ SET session_replication_role TO DEFAULT;
|
|
|
211
213
|
];
|
|
212
214
|
opts.replacer = metaReplacer.replacer;
|
|
213
215
|
opts.name = metaExtensionName;
|
|
216
|
+
opts.outdir = svcOutdir;
|
|
214
217
|
writePgpmPlan(metaPackage, opts);
|
|
215
218
|
writePgpmFiles(metaPackage, opts);
|
|
216
219
|
}
|
|
217
220
|
pgPool.end();
|
|
218
221
|
};
|
|
219
|
-
export const exportMigrations = async ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username }) => {
|
|
222
|
+
export const exportMigrations = async ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username, serviceOutdir }) => {
|
|
220
223
|
for (let v = 0; v < dbInfo.database_ids.length; v++) {
|
|
221
224
|
const databaseId = dbInfo.database_ids[v];
|
|
222
225
|
await exportMigrationsToDisk({
|
|
@@ -234,7 +237,8 @@ export const exportMigrations = async ({ project, options, dbInfo, author, outdi
|
|
|
234
237
|
outdir,
|
|
235
238
|
prompter,
|
|
236
239
|
repoName,
|
|
237
|
-
username
|
|
240
|
+
username,
|
|
241
|
+
serviceOutdir
|
|
238
242
|
});
|
|
239
243
|
}
|
|
240
244
|
};
|
|
@@ -257,6 +261,8 @@ const preparePackage = async ({ project, author, outdir, name, description, exte
|
|
|
257
261
|
description,
|
|
258
262
|
author,
|
|
259
263
|
extensions,
|
|
264
|
+
// Use outputDir to create module directly in the specified location
|
|
265
|
+
outputDir: outdir,
|
|
260
266
|
answers: {
|
|
261
267
|
moduleName: name,
|
|
262
268
|
moduleDesc: description,
|
|
@@ -27,6 +27,8 @@ interface ExportOptions {
|
|
|
27
27
|
repoName?: string;
|
|
28
28
|
/** GitHub username/org for module scaffolding. Required for non-interactive use. */
|
|
29
29
|
username?: string;
|
|
30
|
+
/** Output directory for service/meta module. Defaults to outdir if not provided. */
|
|
31
|
+
serviceOutdir?: string;
|
|
30
32
|
}
|
|
31
|
-
export declare const exportMigrations: ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username }: ExportOptions) => Promise<void>;
|
|
33
|
+
export declare const exportMigrations: ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username, serviceOutdir }: ExportOptions) => Promise<void>;
|
|
32
34
|
export {};
|
|
@@ -98,8 +98,10 @@ const installMissingModules = async (moduleDir, missingModules) => {
|
|
|
98
98
|
await moduleProject.installModules(...missingNames);
|
|
99
99
|
console.log('Modules installed successfully.');
|
|
100
100
|
};
|
|
101
|
-
const exportMigrationsToDisk = async ({ project, options, database, databaseId, databaseName, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username }) => {
|
|
101
|
+
const exportMigrationsToDisk = async ({ project, options, database, databaseId, databaseName, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username, serviceOutdir }) => {
|
|
102
102
|
outdir = outdir + '/';
|
|
103
|
+
// Use serviceOutdir for service module, defaulting to outdir if not provided
|
|
104
|
+
const svcOutdir = (serviceOutdir || outdir.slice(0, -1)) + '/';
|
|
103
105
|
const pgPool = (0, pg_cache_1.getPgPool)({
|
|
104
106
|
...options.pg,
|
|
105
107
|
database
|
|
@@ -159,11 +161,11 @@ const exportMigrationsToDisk = async ({ project, options, database, databaseId,
|
|
|
159
161
|
const metaDesc = metaExtensionDesc || `${metaExtensionName} service utilities for managing domains, APIs, and services`;
|
|
160
162
|
// Detect missing modules at workspace level and prompt user
|
|
161
163
|
const svcMissingResult = await detectMissingModules(project, [...SERVICE_REQUIRED_EXTENSIONS], prompter);
|
|
162
|
-
// Create/prepare the module directory
|
|
164
|
+
// Create/prepare the module directory (use serviceOutdir if provided)
|
|
163
165
|
const svcModuleDir = await preparePackage({
|
|
164
166
|
project,
|
|
165
167
|
author,
|
|
166
|
-
outdir,
|
|
168
|
+
outdir: svcOutdir,
|
|
167
169
|
name: metaExtensionName,
|
|
168
170
|
description: metaDesc,
|
|
169
171
|
extensions: [...SERVICE_REQUIRED_EXTENSIONS],
|
|
@@ -217,12 +219,13 @@ SET session_replication_role TO DEFAULT;
|
|
|
217
219
|
];
|
|
218
220
|
opts.replacer = metaReplacer.replacer;
|
|
219
221
|
opts.name = metaExtensionName;
|
|
222
|
+
opts.outdir = svcOutdir;
|
|
220
223
|
(0, files_1.writePgpmPlan)(metaPackage, opts);
|
|
221
224
|
(0, files_1.writePgpmFiles)(metaPackage, opts);
|
|
222
225
|
}
|
|
223
226
|
pgPool.end();
|
|
224
227
|
};
|
|
225
|
-
const exportMigrations = async ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username }) => {
|
|
228
|
+
const exportMigrations = async ({ project, options, dbInfo, author, outdir, schema_names, extensionName, extensionDesc, metaExtensionName, metaExtensionDesc, prompter, repoName, username, serviceOutdir }) => {
|
|
226
229
|
for (let v = 0; v < dbInfo.database_ids.length; v++) {
|
|
227
230
|
const databaseId = dbInfo.database_ids[v];
|
|
228
231
|
await exportMigrationsToDisk({
|
|
@@ -240,7 +243,8 @@ const exportMigrations = async ({ project, options, dbInfo, author, outdir, sche
|
|
|
240
243
|
outdir,
|
|
241
244
|
prompter,
|
|
242
245
|
repoName,
|
|
243
|
-
username
|
|
246
|
+
username,
|
|
247
|
+
serviceOutdir
|
|
244
248
|
});
|
|
245
249
|
}
|
|
246
250
|
};
|
|
@@ -264,6 +268,8 @@ const preparePackage = async ({ project, author, outdir, name, description, exte
|
|
|
264
268
|
description,
|
|
265
269
|
author,
|
|
266
270
|
extensions,
|
|
271
|
+
// Use outputDir to create module directly in the specified location
|
|
272
|
+
outputDir: outdir,
|
|
267
273
|
answers: {
|
|
268
274
|
moduleName: name,
|
|
269
275
|
moduleDesc: description,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpmjs/core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PGPM Package and Migration Tools",
|
|
6
6
|
"main": "index.js",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"pgsql-parser": "^17.9.5",
|
|
65
65
|
"yanse": "^0.1.8"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "bec3240e4e0f93b8edb386734eeb560403f574da"
|
|
68
68
|
}
|