pgpm 3.1.0 → 3.1.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/commands/init/index.js +32 -10
- package/esm/commands/init/index.js +32 -10
- package/package.json +2 -2
package/commands/init/index.js
CHANGED
|
@@ -241,19 +241,20 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
241
241
|
// Whether this is a pgpm-managed template (creates pgpm.plan, .control files)
|
|
242
242
|
const isPgpmTemplate = workspaceType === 'pgpm';
|
|
243
243
|
const project = new core_1.PgpmPackage(ctx.cwd);
|
|
244
|
+
// Track resolved workspace path for both pgpm and non-pgpm workspace types
|
|
245
|
+
let resolvedWorkspacePath;
|
|
246
|
+
let workspaceTypeName = '';
|
|
244
247
|
// Check workspace requirement based on type (skip if workspaceType is false)
|
|
245
248
|
if (workspaceType !== false) {
|
|
246
|
-
let workspacePath;
|
|
247
|
-
let workspaceTypeName = '';
|
|
248
249
|
if (workspaceType === 'pgpm') {
|
|
249
|
-
|
|
250
|
+
resolvedWorkspacePath = project.workspacePath;
|
|
250
251
|
workspaceTypeName = 'PGPM';
|
|
251
252
|
}
|
|
252
253
|
else {
|
|
253
|
-
|
|
254
|
+
resolvedWorkspacePath = (0, env_1.resolveWorkspaceByType)(ctx.cwd, workspaceType);
|
|
254
255
|
workspaceTypeName = workspaceType.toUpperCase();
|
|
255
256
|
}
|
|
256
|
-
if (!
|
|
257
|
+
if (!resolvedWorkspacePath) {
|
|
257
258
|
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true');
|
|
258
259
|
// If user explicitly requested module init or we're in non-interactive mode,
|
|
259
260
|
// just show the error with helpful guidance
|
|
@@ -261,8 +262,9 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
261
262
|
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
262
263
|
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
263
264
|
}
|
|
264
|
-
//
|
|
265
|
-
|
|
265
|
+
// Offer to create a workspace for pgpm templates or when --dir is specified
|
|
266
|
+
// (when --dir is specified, we know which workspace variant to use)
|
|
267
|
+
if (workspaceType === 'pgpm' || ctx.dir) {
|
|
266
268
|
const recoveryQuestion = [
|
|
267
269
|
{
|
|
268
270
|
name: 'workspace',
|
|
@@ -284,7 +286,7 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
284
286
|
});
|
|
285
287
|
}
|
|
286
288
|
}
|
|
287
|
-
// User declined or non-pgpm workspace type, show the error
|
|
289
|
+
// User declined or non-pgpm workspace type without --dir, show the error
|
|
288
290
|
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
289
291
|
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
290
292
|
}
|
|
@@ -334,7 +336,7 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
334
336
|
// Determine output path based on whether we're in a workspace
|
|
335
337
|
let modulePath;
|
|
336
338
|
if (project.workspacePath) {
|
|
337
|
-
//
|
|
339
|
+
// PGPM workspace - use workspace-aware initModule
|
|
338
340
|
await project.initModule({
|
|
339
341
|
name: modName,
|
|
340
342
|
description: answers.description || modName,
|
|
@@ -354,8 +356,28 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
354
356
|
? path_1.default.join(ctx.cwd, 'packages', modName)
|
|
355
357
|
: path_1.default.join(ctx.cwd, modName);
|
|
356
358
|
}
|
|
359
|
+
else if (resolvedWorkspacePath && workspaceType !== false) {
|
|
360
|
+
// Non-pgpm workspace (pnpm, lerna, npm) - scaffold to packages/ directory
|
|
361
|
+
const isRoot = path_1.default.resolve(resolvedWorkspacePath) === path_1.default.resolve(ctx.cwd);
|
|
362
|
+
modulePath = isRoot
|
|
363
|
+
? path_1.default.join(ctx.cwd, 'packages', modName)
|
|
364
|
+
: path_1.default.join(ctx.cwd, modName);
|
|
365
|
+
fs_1.default.mkdirSync(modulePath, { recursive: true });
|
|
366
|
+
await (0, core_1.scaffoldTemplate)({
|
|
367
|
+
fromPath: ctx.fromPath,
|
|
368
|
+
outputDir: modulePath,
|
|
369
|
+
templateRepo: ctx.templateRepo,
|
|
370
|
+
branch: ctx.branch,
|
|
371
|
+
dir: ctx.dir,
|
|
372
|
+
answers: templateAnswers,
|
|
373
|
+
noTty: ctx.noTty,
|
|
374
|
+
toolName: core_1.DEFAULT_TEMPLATE_TOOL_NAME,
|
|
375
|
+
cwd: ctx.cwd,
|
|
376
|
+
prompter
|
|
377
|
+
});
|
|
378
|
+
}
|
|
357
379
|
else {
|
|
358
|
-
// Not in
|
|
380
|
+
// Not in any workspace (requiresWorkspace: false) - scaffold to current directory
|
|
359
381
|
modulePath = path_1.default.join(ctx.cwd, modName);
|
|
360
382
|
fs_1.default.mkdirSync(modulePath, { recursive: true });
|
|
361
383
|
await (0, core_1.scaffoldTemplate)({
|
|
@@ -234,19 +234,20 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
234
234
|
// Whether this is a pgpm-managed template (creates pgpm.plan, .control files)
|
|
235
235
|
const isPgpmTemplate = workspaceType === 'pgpm';
|
|
236
236
|
const project = new PgpmPackage(ctx.cwd);
|
|
237
|
+
// Track resolved workspace path for both pgpm and non-pgpm workspace types
|
|
238
|
+
let resolvedWorkspacePath;
|
|
239
|
+
let workspaceTypeName = '';
|
|
237
240
|
// Check workspace requirement based on type (skip if workspaceType is false)
|
|
238
241
|
if (workspaceType !== false) {
|
|
239
|
-
let workspacePath;
|
|
240
|
-
let workspaceTypeName = '';
|
|
241
242
|
if (workspaceType === 'pgpm') {
|
|
242
|
-
|
|
243
|
+
resolvedWorkspacePath = project.workspacePath;
|
|
243
244
|
workspaceTypeName = 'PGPM';
|
|
244
245
|
}
|
|
245
246
|
else {
|
|
246
|
-
|
|
247
|
+
resolvedWorkspacePath = resolveWorkspaceByType(ctx.cwd, workspaceType);
|
|
247
248
|
workspaceTypeName = workspaceType.toUpperCase();
|
|
248
249
|
}
|
|
249
|
-
if (!
|
|
250
|
+
if (!resolvedWorkspacePath) {
|
|
250
251
|
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true');
|
|
251
252
|
// If user explicitly requested module init or we're in non-interactive mode,
|
|
252
253
|
// just show the error with helpful guidance
|
|
@@ -254,8 +255,9 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
254
255
|
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
255
256
|
throw errors.NOT_IN_WORKSPACE({});
|
|
256
257
|
}
|
|
257
|
-
//
|
|
258
|
-
|
|
258
|
+
// Offer to create a workspace for pgpm templates or when --dir is specified
|
|
259
|
+
// (when --dir is specified, we know which workspace variant to use)
|
|
260
|
+
if (workspaceType === 'pgpm' || ctx.dir) {
|
|
259
261
|
const recoveryQuestion = [
|
|
260
262
|
{
|
|
261
263
|
name: 'workspace',
|
|
@@ -277,7 +279,7 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
277
279
|
});
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
|
-
// User declined or non-pgpm workspace type, show the error
|
|
282
|
+
// User declined or non-pgpm workspace type without --dir, show the error
|
|
281
283
|
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
282
284
|
throw errors.NOT_IN_WORKSPACE({});
|
|
283
285
|
}
|
|
@@ -327,7 +329,7 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
327
329
|
// Determine output path based on whether we're in a workspace
|
|
328
330
|
let modulePath;
|
|
329
331
|
if (project.workspacePath) {
|
|
330
|
-
//
|
|
332
|
+
// PGPM workspace - use workspace-aware initModule
|
|
331
333
|
await project.initModule({
|
|
332
334
|
name: modName,
|
|
333
335
|
description: answers.description || modName,
|
|
@@ -347,8 +349,28 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
347
349
|
? path.join(ctx.cwd, 'packages', modName)
|
|
348
350
|
: path.join(ctx.cwd, modName);
|
|
349
351
|
}
|
|
352
|
+
else if (resolvedWorkspacePath && workspaceType !== false) {
|
|
353
|
+
// Non-pgpm workspace (pnpm, lerna, npm) - scaffold to packages/ directory
|
|
354
|
+
const isRoot = path.resolve(resolvedWorkspacePath) === path.resolve(ctx.cwd);
|
|
355
|
+
modulePath = isRoot
|
|
356
|
+
? path.join(ctx.cwd, 'packages', modName)
|
|
357
|
+
: path.join(ctx.cwd, modName);
|
|
358
|
+
fs.mkdirSync(modulePath, { recursive: true });
|
|
359
|
+
await scaffoldTemplate({
|
|
360
|
+
fromPath: ctx.fromPath,
|
|
361
|
+
outputDir: modulePath,
|
|
362
|
+
templateRepo: ctx.templateRepo,
|
|
363
|
+
branch: ctx.branch,
|
|
364
|
+
dir: ctx.dir,
|
|
365
|
+
answers: templateAnswers,
|
|
366
|
+
noTty: ctx.noTty,
|
|
367
|
+
toolName: DEFAULT_TEMPLATE_TOOL_NAME,
|
|
368
|
+
cwd: ctx.cwd,
|
|
369
|
+
prompter
|
|
370
|
+
});
|
|
371
|
+
}
|
|
350
372
|
else {
|
|
351
|
-
// Not in
|
|
373
|
+
// Not in any workspace (requiresWorkspace: false) - scaffold to current directory
|
|
352
374
|
modulePath = path.join(ctx.cwd, modName);
|
|
353
375
|
fs.mkdirSync(modulePath, { recursive: true });
|
|
354
376
|
await scaffoldTemplate({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL Package Manager - Database migration and package management CLI",
|
|
6
6
|
"main": "index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"pg",
|
|
75
75
|
"pgsql"
|
|
76
76
|
],
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "cb4843d3d80592f369e7f1a67b8a9223e6bfe48c"
|
|
78
78
|
}
|