pgpm 2.9.0 → 2.10.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/commands/init/index.js +114 -65
- package/esm/commands/init/index.js +114 -65
- package/package.json +4 -4
package/commands/init/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.createInitUsageText = void 0;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const core_1 = require("@pgpmjs/core");
|
|
10
|
+
const env_1 = require("@pgpmjs/env");
|
|
10
11
|
const types_1 = require("@pgpmjs/types");
|
|
11
12
|
const inquirerer_1 = require("inquirerer");
|
|
12
13
|
const DEFAULT_MOTD = `
|
|
@@ -97,7 +98,7 @@ async function handleInit(argv, prompter) {
|
|
|
97
98
|
cwd,
|
|
98
99
|
});
|
|
99
100
|
}
|
|
100
|
-
// Default to module init (for 'module' type or unknown types)
|
|
101
|
+
// Default to module init (for 'module' type, 'generic' type, or unknown types)
|
|
101
102
|
return handleModuleInit(argv, prompter, {
|
|
102
103
|
fromPath,
|
|
103
104
|
templateRepo,
|
|
@@ -105,6 +106,7 @@ async function handleInit(argv, prompter) {
|
|
|
105
106
|
dir,
|
|
106
107
|
noTty,
|
|
107
108
|
cwd,
|
|
109
|
+
requiresWorkspace: inspection.config?.requiresWorkspace,
|
|
108
110
|
}, wasExplicitModuleRequest);
|
|
109
111
|
}
|
|
110
112
|
async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
@@ -172,7 +174,7 @@ async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
|
172
174
|
cwd: ctx.cwd,
|
|
173
175
|
});
|
|
174
176
|
}
|
|
175
|
-
// Default to module init (for 'module' type or unknown types)
|
|
177
|
+
// Default to module init (for 'module' type, 'generic' type, or unknown types)
|
|
176
178
|
// When using --boilerplate, user made an explicit choice, so treat as explicit request
|
|
177
179
|
return handleModuleInit(argv, prompter, {
|
|
178
180
|
fromPath,
|
|
@@ -181,6 +183,7 @@ async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
|
181
183
|
dir: ctx.dir,
|
|
182
184
|
noTty: ctx.noTty,
|
|
183
185
|
cwd: ctx.cwd,
|
|
186
|
+
requiresWorkspace: inspection.config?.requiresWorkspace,
|
|
184
187
|
}, true);
|
|
185
188
|
}
|
|
186
189
|
async function handleWorkspaceInit(argv, prompter, ctx) {
|
|
@@ -233,49 +236,67 @@ async function handleWorkspaceInit(argv, prompter, ctx) {
|
|
|
233
236
|
return { ...argv, ...answers, cwd: targetPath };
|
|
234
237
|
}
|
|
235
238
|
async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest = false) {
|
|
239
|
+
// Determine workspace requirement (defaults to 'pgpm' for backward compatibility)
|
|
240
|
+
const workspaceType = ctx.requiresWorkspace ?? 'pgpm';
|
|
241
|
+
// Whether this is a pgpm-managed template (creates pgpm.plan, .control files)
|
|
242
|
+
const isPgpmTemplate = workspaceType === 'pgpm';
|
|
236
243
|
const project = new core_1.PgpmPackage(ctx.cwd);
|
|
237
|
-
if
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
// Check workspace requirement based on type (skip if workspaceType is false)
|
|
245
|
+
if (workspaceType !== false) {
|
|
246
|
+
let workspacePath;
|
|
247
|
+
let workspaceTypeName = '';
|
|
248
|
+
if (workspaceType === 'pgpm') {
|
|
249
|
+
workspacePath = project.workspacePath;
|
|
250
|
+
workspaceTypeName = 'PGPM';
|
|
244
251
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
else {
|
|
253
|
+
workspacePath = (0, env_1.resolveWorkspaceByType)(ctx.cwd, workspaceType);
|
|
254
|
+
workspaceTypeName = workspaceType.toUpperCase();
|
|
255
|
+
}
|
|
256
|
+
if (!workspacePath) {
|
|
257
|
+
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true');
|
|
258
|
+
// If user explicitly requested module init or we're in non-interactive mode,
|
|
259
|
+
// just show the error with helpful guidance
|
|
260
|
+
if (wasExplicitModuleRequest || noTty) {
|
|
261
|
+
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
262
|
+
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
263
|
+
}
|
|
264
|
+
// Only offer to create a workspace for pgpm templates
|
|
265
|
+
if (workspaceType === 'pgpm') {
|
|
266
|
+
const recoveryQuestion = [
|
|
267
|
+
{
|
|
268
|
+
name: 'workspace',
|
|
269
|
+
alias: 'w',
|
|
270
|
+
message: `You are not inside a ${workspaceTypeName} workspace. Would you like to create a new workspace instead?`,
|
|
271
|
+
type: 'confirm',
|
|
272
|
+
required: true,
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
const { workspace } = await prompter.prompt(argv, recoveryQuestion);
|
|
276
|
+
if (workspace) {
|
|
277
|
+
return handleWorkspaceInit(argv, prompter, {
|
|
278
|
+
fromPath: 'workspace',
|
|
279
|
+
templateRepo: ctx.templateRepo,
|
|
280
|
+
branch: ctx.branch,
|
|
281
|
+
dir: ctx.dir,
|
|
282
|
+
noTty: ctx.noTty,
|
|
283
|
+
cwd: ctx.cwd,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// User declined or non-pgpm workspace type, show the error
|
|
288
|
+
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
289
|
+
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
265
290
|
}
|
|
266
|
-
// User declined, show the error
|
|
267
|
-
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
268
|
-
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
269
291
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
292
|
+
// Only check workspace directory constraints if we're in a workspace
|
|
293
|
+
if (project.workspacePath) {
|
|
294
|
+
if (!project.isInsideAllowedDirs(ctx.cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(ctx.cwd)) {
|
|
295
|
+
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
296
|
+
throw types_1.errors.NOT_IN_WORKSPACE_MODULE({});
|
|
297
|
+
}
|
|
273
298
|
}
|
|
274
|
-
|
|
275
|
-
// Note: moduleName is needed here before scaffolding because initModule creates
|
|
276
|
-
// the directory first, then scaffolds. The boilerplate's ____moduleName____ question
|
|
277
|
-
// gets skipped because the answer is already passed through. So users only see it
|
|
278
|
-
// once, but the definition exists in two places for this architectural reason.
|
|
299
|
+
// Build questions based on whether this is a pgpm template
|
|
279
300
|
const moduleQuestions = [
|
|
280
301
|
{
|
|
281
302
|
name: 'moduleName',
|
|
@@ -283,7 +304,11 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
283
304
|
required: true,
|
|
284
305
|
type: 'text',
|
|
285
306
|
},
|
|
286
|
-
|
|
307
|
+
];
|
|
308
|
+
// Only ask for extensions if this is a pgpm template
|
|
309
|
+
if (isPgpmTemplate && project.workspacePath) {
|
|
310
|
+
const availExtensions = await project.getAvailableModules();
|
|
311
|
+
moduleQuestions.push({
|
|
287
312
|
name: 'extensions',
|
|
288
313
|
message: 'Which extensions?',
|
|
289
314
|
options: availExtensions,
|
|
@@ -291,36 +316,61 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
291
316
|
allowCustomOptions: true,
|
|
292
317
|
required: true,
|
|
293
318
|
default: ['plpgsql', 'uuid-ossp'],
|
|
294
|
-
}
|
|
295
|
-
|
|
319
|
+
});
|
|
320
|
+
}
|
|
296
321
|
const answers = await prompter.prompt(argv, moduleQuestions);
|
|
297
322
|
const modName = (0, core_1.sluggify)(answers.moduleName);
|
|
298
|
-
const extensions = answers.extensions
|
|
299
|
-
|
|
300
|
-
|
|
323
|
+
const extensions = isPgpmTemplate && answers.extensions
|
|
324
|
+
? answers.extensions
|
|
325
|
+
.filter((opt) => opt.selected)
|
|
326
|
+
.map((opt) => opt.name)
|
|
327
|
+
: [];
|
|
301
328
|
const templateAnswers = {
|
|
302
329
|
...argv,
|
|
303
330
|
...answers,
|
|
304
331
|
moduleName: modName,
|
|
305
332
|
packageIdentifier: argv.packageIdentifier || modName
|
|
306
333
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
// Determine output path based on whether we're in a workspace
|
|
335
|
+
let modulePath;
|
|
336
|
+
if (project.workspacePath) {
|
|
337
|
+
// Use workspace-aware initModule
|
|
338
|
+
await project.initModule({
|
|
339
|
+
name: modName,
|
|
340
|
+
description: answers.description || modName,
|
|
341
|
+
author: answers.author || modName,
|
|
342
|
+
extensions,
|
|
343
|
+
templateRepo: ctx.templateRepo,
|
|
344
|
+
templatePath: ctx.fromPath,
|
|
345
|
+
branch: ctx.branch,
|
|
346
|
+
dir: ctx.dir,
|
|
347
|
+
toolName: core_1.DEFAULT_TEMPLATE_TOOL_NAME,
|
|
348
|
+
answers: templateAnswers,
|
|
349
|
+
noTty: ctx.noTty,
|
|
350
|
+
pgpm: isPgpmTemplate,
|
|
351
|
+
});
|
|
352
|
+
const isRoot = path_1.default.resolve(project.workspacePath) === path_1.default.resolve(ctx.cwd);
|
|
353
|
+
modulePath = isRoot
|
|
354
|
+
? path_1.default.join(ctx.cwd, 'packages', modName)
|
|
355
|
+
: path_1.default.join(ctx.cwd, modName);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// Not in a workspace - scaffold directly to current directory
|
|
359
|
+
modulePath = path_1.default.join(ctx.cwd, modName);
|
|
360
|
+
fs_1.default.mkdirSync(modulePath, { recursive: true });
|
|
361
|
+
await (0, core_1.scaffoldTemplate)({
|
|
362
|
+
fromPath: ctx.fromPath,
|
|
363
|
+
outputDir: modulePath,
|
|
364
|
+
templateRepo: ctx.templateRepo,
|
|
365
|
+
branch: ctx.branch,
|
|
366
|
+
dir: ctx.dir,
|
|
367
|
+
answers: templateAnswers,
|
|
368
|
+
noTty: ctx.noTty,
|
|
369
|
+
toolName: core_1.DEFAULT_TEMPLATE_TOOL_NAME,
|
|
370
|
+
cwd: ctx.cwd,
|
|
371
|
+
prompter
|
|
372
|
+
});
|
|
373
|
+
}
|
|
324
374
|
const motdPath = path_1.default.join(modulePath, '.motd');
|
|
325
375
|
let motd = DEFAULT_MOTD;
|
|
326
376
|
if (fs_1.default.existsSync(motdPath)) {
|
|
@@ -336,7 +386,6 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
336
386
|
if (!motd.endsWith('\n')) {
|
|
337
387
|
process.stdout.write('\n');
|
|
338
388
|
}
|
|
339
|
-
|
|
340
|
-
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
389
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${modName}\n`);
|
|
341
390
|
return { ...argv, ...answers };
|
|
342
391
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, inspectTemplate, PgpmPackage, resolveBoilerplateBaseDir, scaffoldTemplate, scanBoilerplates, sluggify, } from '@pgpmjs/core';
|
|
4
|
+
import { resolveWorkspaceByType } from '@pgpmjs/env';
|
|
4
5
|
import { errors } from '@pgpmjs/types';
|
|
5
6
|
import { registerDefaultResolver } from 'inquirerer';
|
|
6
7
|
const DEFAULT_MOTD = `
|
|
@@ -90,7 +91,7 @@ async function handleInit(argv, prompter) {
|
|
|
90
91
|
cwd,
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
// Default to module init (for 'module' type or unknown types)
|
|
94
|
+
// Default to module init (for 'module' type, 'generic' type, or unknown types)
|
|
94
95
|
return handleModuleInit(argv, prompter, {
|
|
95
96
|
fromPath,
|
|
96
97
|
templateRepo,
|
|
@@ -98,6 +99,7 @@ async function handleInit(argv, prompter) {
|
|
|
98
99
|
dir,
|
|
99
100
|
noTty,
|
|
100
101
|
cwd,
|
|
102
|
+
requiresWorkspace: inspection.config?.requiresWorkspace,
|
|
101
103
|
}, wasExplicitModuleRequest);
|
|
102
104
|
}
|
|
103
105
|
async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
@@ -165,7 +167,7 @@ async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
|
165
167
|
cwd: ctx.cwd,
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
|
-
// Default to module init (for 'module' type or unknown types)
|
|
170
|
+
// Default to module init (for 'module' type, 'generic' type, or unknown types)
|
|
169
171
|
// When using --boilerplate, user made an explicit choice, so treat as explicit request
|
|
170
172
|
return handleModuleInit(argv, prompter, {
|
|
171
173
|
fromPath,
|
|
@@ -174,6 +176,7 @@ async function handleBoilerplateInit(argv, prompter, ctx) {
|
|
|
174
176
|
dir: ctx.dir,
|
|
175
177
|
noTty: ctx.noTty,
|
|
176
178
|
cwd: ctx.cwd,
|
|
179
|
+
requiresWorkspace: inspection.config?.requiresWorkspace,
|
|
177
180
|
}, true);
|
|
178
181
|
}
|
|
179
182
|
async function handleWorkspaceInit(argv, prompter, ctx) {
|
|
@@ -226,49 +229,67 @@ async function handleWorkspaceInit(argv, prompter, ctx) {
|
|
|
226
229
|
return { ...argv, ...answers, cwd: targetPath };
|
|
227
230
|
}
|
|
228
231
|
async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest = false) {
|
|
232
|
+
// Determine workspace requirement (defaults to 'pgpm' for backward compatibility)
|
|
233
|
+
const workspaceType = ctx.requiresWorkspace ?? 'pgpm';
|
|
234
|
+
// Whether this is a pgpm-managed template (creates pgpm.plan, .control files)
|
|
235
|
+
const isPgpmTemplate = workspaceType === 'pgpm';
|
|
229
236
|
const project = new PgpmPackage(ctx.cwd);
|
|
230
|
-
if
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
+
// Check workspace requirement based on type (skip if workspaceType is false)
|
|
238
|
+
if (workspaceType !== false) {
|
|
239
|
+
let workspacePath;
|
|
240
|
+
let workspaceTypeName = '';
|
|
241
|
+
if (workspaceType === 'pgpm') {
|
|
242
|
+
workspacePath = project.workspacePath;
|
|
243
|
+
workspaceTypeName = 'PGPM';
|
|
237
244
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
245
|
+
else {
|
|
246
|
+
workspacePath = resolveWorkspaceByType(ctx.cwd, workspaceType);
|
|
247
|
+
workspaceTypeName = workspaceType.toUpperCase();
|
|
248
|
+
}
|
|
249
|
+
if (!workspacePath) {
|
|
250
|
+
const noTty = Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true');
|
|
251
|
+
// If user explicitly requested module init or we're in non-interactive mode,
|
|
252
|
+
// just show the error with helpful guidance
|
|
253
|
+
if (wasExplicitModuleRequest || noTty) {
|
|
254
|
+
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
255
|
+
throw errors.NOT_IN_WORKSPACE({});
|
|
256
|
+
}
|
|
257
|
+
// Only offer to create a workspace for pgpm templates
|
|
258
|
+
if (workspaceType === 'pgpm') {
|
|
259
|
+
const recoveryQuestion = [
|
|
260
|
+
{
|
|
261
|
+
name: 'workspace',
|
|
262
|
+
alias: 'w',
|
|
263
|
+
message: `You are not inside a ${workspaceTypeName} workspace. Would you like to create a new workspace instead?`,
|
|
264
|
+
type: 'confirm',
|
|
265
|
+
required: true,
|
|
266
|
+
},
|
|
267
|
+
];
|
|
268
|
+
const { workspace } = await prompter.prompt(argv, recoveryQuestion);
|
|
269
|
+
if (workspace) {
|
|
270
|
+
return handleWorkspaceInit(argv, prompter, {
|
|
271
|
+
fromPath: 'workspace',
|
|
272
|
+
templateRepo: ctx.templateRepo,
|
|
273
|
+
branch: ctx.branch,
|
|
274
|
+
dir: ctx.dir,
|
|
275
|
+
noTty: ctx.noTty,
|
|
276
|
+
cwd: ctx.cwd,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// User declined or non-pgpm workspace type, show the error
|
|
281
|
+
process.stderr.write(`Not inside a ${workspaceTypeName} workspace.\n`);
|
|
282
|
+
throw errors.NOT_IN_WORKSPACE({});
|
|
258
283
|
}
|
|
259
|
-
// User declined, show the error
|
|
260
|
-
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
261
|
-
throw errors.NOT_IN_WORKSPACE({});
|
|
262
284
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
285
|
+
// Only check workspace directory constraints if we're in a workspace
|
|
286
|
+
if (project.workspacePath) {
|
|
287
|
+
if (!project.isInsideAllowedDirs(ctx.cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(ctx.cwd)) {
|
|
288
|
+
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
289
|
+
throw errors.NOT_IN_WORKSPACE_MODULE({});
|
|
290
|
+
}
|
|
266
291
|
}
|
|
267
|
-
|
|
268
|
-
// Note: moduleName is needed here before scaffolding because initModule creates
|
|
269
|
-
// the directory first, then scaffolds. The boilerplate's ____moduleName____ question
|
|
270
|
-
// gets skipped because the answer is already passed through. So users only see it
|
|
271
|
-
// once, but the definition exists in two places for this architectural reason.
|
|
292
|
+
// Build questions based on whether this is a pgpm template
|
|
272
293
|
const moduleQuestions = [
|
|
273
294
|
{
|
|
274
295
|
name: 'moduleName',
|
|
@@ -276,7 +297,11 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
276
297
|
required: true,
|
|
277
298
|
type: 'text',
|
|
278
299
|
},
|
|
279
|
-
|
|
300
|
+
];
|
|
301
|
+
// Only ask for extensions if this is a pgpm template
|
|
302
|
+
if (isPgpmTemplate && project.workspacePath) {
|
|
303
|
+
const availExtensions = await project.getAvailableModules();
|
|
304
|
+
moduleQuestions.push({
|
|
280
305
|
name: 'extensions',
|
|
281
306
|
message: 'Which extensions?',
|
|
282
307
|
options: availExtensions,
|
|
@@ -284,36 +309,61 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
284
309
|
allowCustomOptions: true,
|
|
285
310
|
required: true,
|
|
286
311
|
default: ['plpgsql', 'uuid-ossp'],
|
|
287
|
-
}
|
|
288
|
-
|
|
312
|
+
});
|
|
313
|
+
}
|
|
289
314
|
const answers = await prompter.prompt(argv, moduleQuestions);
|
|
290
315
|
const modName = sluggify(answers.moduleName);
|
|
291
|
-
const extensions = answers.extensions
|
|
292
|
-
|
|
293
|
-
|
|
316
|
+
const extensions = isPgpmTemplate && answers.extensions
|
|
317
|
+
? answers.extensions
|
|
318
|
+
.filter((opt) => opt.selected)
|
|
319
|
+
.map((opt) => opt.name)
|
|
320
|
+
: [];
|
|
294
321
|
const templateAnswers = {
|
|
295
322
|
...argv,
|
|
296
323
|
...answers,
|
|
297
324
|
moduleName: modName,
|
|
298
325
|
packageIdentifier: argv.packageIdentifier || modName
|
|
299
326
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
327
|
+
// Determine output path based on whether we're in a workspace
|
|
328
|
+
let modulePath;
|
|
329
|
+
if (project.workspacePath) {
|
|
330
|
+
// Use workspace-aware initModule
|
|
331
|
+
await project.initModule({
|
|
332
|
+
name: modName,
|
|
333
|
+
description: answers.description || modName,
|
|
334
|
+
author: answers.author || modName,
|
|
335
|
+
extensions,
|
|
336
|
+
templateRepo: ctx.templateRepo,
|
|
337
|
+
templatePath: ctx.fromPath,
|
|
338
|
+
branch: ctx.branch,
|
|
339
|
+
dir: ctx.dir,
|
|
340
|
+
toolName: DEFAULT_TEMPLATE_TOOL_NAME,
|
|
341
|
+
answers: templateAnswers,
|
|
342
|
+
noTty: ctx.noTty,
|
|
343
|
+
pgpm: isPgpmTemplate,
|
|
344
|
+
});
|
|
345
|
+
const isRoot = path.resolve(project.workspacePath) === path.resolve(ctx.cwd);
|
|
346
|
+
modulePath = isRoot
|
|
347
|
+
? path.join(ctx.cwd, 'packages', modName)
|
|
348
|
+
: path.join(ctx.cwd, modName);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// Not in a workspace - scaffold directly to current directory
|
|
352
|
+
modulePath = path.join(ctx.cwd, modName);
|
|
353
|
+
fs.mkdirSync(modulePath, { recursive: true });
|
|
354
|
+
await scaffoldTemplate({
|
|
355
|
+
fromPath: ctx.fromPath,
|
|
356
|
+
outputDir: modulePath,
|
|
357
|
+
templateRepo: ctx.templateRepo,
|
|
358
|
+
branch: ctx.branch,
|
|
359
|
+
dir: ctx.dir,
|
|
360
|
+
answers: templateAnswers,
|
|
361
|
+
noTty: ctx.noTty,
|
|
362
|
+
toolName: DEFAULT_TEMPLATE_TOOL_NAME,
|
|
363
|
+
cwd: ctx.cwd,
|
|
364
|
+
prompter
|
|
365
|
+
});
|
|
366
|
+
}
|
|
317
367
|
const motdPath = path.join(modulePath, '.motd');
|
|
318
368
|
let motd = DEFAULT_MOTD;
|
|
319
369
|
if (fs.existsSync(motdPath)) {
|
|
@@ -329,7 +379,6 @@ async function handleModuleInit(argv, prompter, ctx, wasExplicitModuleRequest =
|
|
|
329
379
|
if (!motd.endsWith('\n')) {
|
|
330
380
|
process.stdout.write('\n');
|
|
331
381
|
}
|
|
332
|
-
|
|
333
|
-
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
382
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${modName}\n`);
|
|
334
383
|
return { ...argv, ...answers };
|
|
335
384
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "PostgreSQL Package Manager - Database migration and package management CLI",
|
|
6
6
|
"main": "index.js",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@inquirerer/utils": "^3.1.2",
|
|
50
|
-
"@pgpmjs/core": "^4.
|
|
51
|
-
"@pgpmjs/env": "^2.9.
|
|
50
|
+
"@pgpmjs/core": "^4.10.0",
|
|
51
|
+
"@pgpmjs/env": "^2.9.3",
|
|
52
52
|
"@pgpmjs/logger": "^1.3.7",
|
|
53
53
|
"@pgpmjs/types": "^2.14.0",
|
|
54
54
|
"appstash": "^0.2.7",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"pg",
|
|
76
76
|
"pgsql"
|
|
77
77
|
],
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "ba5bbacf7ccc1980cba10bf3f45ebb0ca639fb79"
|
|
79
79
|
}
|