pgpm 2.1.2 → 2.2.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/extension.js +1 -1
- package/commands/init/index.js +6 -1
- package/esm/commands/extension.js +1 -1
- package/esm/commands/init/index.js +6 -1
- package/package.json +3 -3
- package/commands/init/module.d.ts +0 -4
- package/commands/init/module.js +0 -96
- package/esm/commands/init/module.js +0 -90
package/commands/extension.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
28
28
|
}
|
|
29
29
|
const info = project.getModuleInfo();
|
|
30
30
|
const installed = project.getRequiredModules();
|
|
31
|
-
const available = project.getAvailableModules();
|
|
31
|
+
const available = await project.getAvailableModules();
|
|
32
32
|
const filtered = available.filter(name => name !== info.extname);
|
|
33
33
|
const questions = [
|
|
34
34
|
{
|
package/commands/init/index.js
CHANGED
|
@@ -239,7 +239,11 @@ async function handleModuleInit(argv, prompter, ctx) {
|
|
|
239
239
|
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
240
240
|
throw types_1.errors.NOT_IN_WORKSPACE_MODULE({});
|
|
241
241
|
}
|
|
242
|
-
const availExtensions = project.getAvailableModules();
|
|
242
|
+
const availExtensions = await project.getAvailableModules();
|
|
243
|
+
// Note: moduleName is needed here before scaffolding because initModule creates
|
|
244
|
+
// the directory first, then scaffolds. The boilerplate's ____moduleName____ question
|
|
245
|
+
// gets skipped because the answer is already passed through. So users only see it
|
|
246
|
+
// once, but the definition exists in two places for this architectural reason.
|
|
243
247
|
const moduleQuestions = [
|
|
244
248
|
{
|
|
245
249
|
name: 'moduleName',
|
|
@@ -254,6 +258,7 @@ async function handleModuleInit(argv, prompter, ctx) {
|
|
|
254
258
|
type: 'checkbox',
|
|
255
259
|
allowCustomOptions: true,
|
|
256
260
|
required: true,
|
|
261
|
+
default: ['plpgsql', 'uuid-ossp'],
|
|
257
262
|
},
|
|
258
263
|
];
|
|
259
264
|
const answers = await prompter.prompt(argv, moduleQuestions);
|
|
@@ -26,7 +26,7 @@ export default async (argv, prompter, _options) => {
|
|
|
26
26
|
}
|
|
27
27
|
const info = project.getModuleInfo();
|
|
28
28
|
const installed = project.getRequiredModules();
|
|
29
|
-
const available = project.getAvailableModules();
|
|
29
|
+
const available = await project.getAvailableModules();
|
|
30
30
|
const filtered = available.filter(name => name !== info.extname);
|
|
31
31
|
const questions = [
|
|
32
32
|
{
|
|
@@ -232,7 +232,11 @@ async function handleModuleInit(argv, prompter, ctx) {
|
|
|
232
232
|
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
233
233
|
throw errors.NOT_IN_WORKSPACE_MODULE({});
|
|
234
234
|
}
|
|
235
|
-
const availExtensions = project.getAvailableModules();
|
|
235
|
+
const availExtensions = await project.getAvailableModules();
|
|
236
|
+
// Note: moduleName is needed here before scaffolding because initModule creates
|
|
237
|
+
// the directory first, then scaffolds. The boilerplate's ____moduleName____ question
|
|
238
|
+
// gets skipped because the answer is already passed through. So users only see it
|
|
239
|
+
// once, but the definition exists in two places for this architectural reason.
|
|
236
240
|
const moduleQuestions = [
|
|
237
241
|
{
|
|
238
242
|
name: 'moduleName',
|
|
@@ -247,6 +251,7 @@ async function handleModuleInit(argv, prompter, ctx) {
|
|
|
247
251
|
type: 'checkbox',
|
|
248
252
|
allowCustomOptions: true,
|
|
249
253
|
required: true,
|
|
254
|
+
default: ['plpgsql', 'uuid-ossp'],
|
|
250
255
|
},
|
|
251
256
|
];
|
|
252
257
|
const answers = await prompter.prompt(argv, moduleQuestions);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ts-node": "^10.9.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pgpmjs/core": "^4.0
|
|
48
|
+
"@pgpmjs/core": "^4.1.0",
|
|
49
49
|
"@pgpmjs/env": "^2.8.10",
|
|
50
50
|
"@pgpmjs/logger": "^1.3.5",
|
|
51
51
|
"@pgpmjs/types": "^2.12.7",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"pg",
|
|
74
74
|
"pgsql"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "30931619fc721648340e9cb1667cd99314527085"
|
|
77
77
|
}
|
package/commands/init/module.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = runModuleSetup;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const core_1 = require("@pgpmjs/core");
|
|
10
|
-
const types_1 = require("@pgpmjs/types");
|
|
11
|
-
const DEFAULT_MOTD = `
|
|
12
|
-
| _ _
|
|
13
|
-
=== |.===. '\\-//\`
|
|
14
|
-
(o o) {}o o{} (o o)
|
|
15
|
-
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
16
|
-
`;
|
|
17
|
-
async function runModuleSetup(argv, prompter) {
|
|
18
|
-
const { cwd = process.cwd() } = argv;
|
|
19
|
-
const project = new core_1.PgpmPackage(cwd);
|
|
20
|
-
if (!project.workspacePath) {
|
|
21
|
-
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
22
|
-
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
23
|
-
}
|
|
24
|
-
if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
|
|
25
|
-
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
26
|
-
throw types_1.errors.NOT_IN_WORKSPACE_MODULE({});
|
|
27
|
-
}
|
|
28
|
-
const availExtensions = project.getAvailableModules();
|
|
29
|
-
const moduleQuestions = [
|
|
30
|
-
{
|
|
31
|
-
name: 'moduleName',
|
|
32
|
-
message: 'Enter the module name',
|
|
33
|
-
required: true,
|
|
34
|
-
type: 'text',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'extensions',
|
|
38
|
-
message: 'Which extensions?',
|
|
39
|
-
options: availExtensions,
|
|
40
|
-
type: 'checkbox',
|
|
41
|
-
allowCustomOptions: true,
|
|
42
|
-
required: true,
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
const answers = await prompter.prompt(argv, moduleQuestions);
|
|
46
|
-
const modName = (0, core_1.sluggify)(answers.moduleName);
|
|
47
|
-
// Avoid overlapping readline listeners with create-gen-app's prompts.
|
|
48
|
-
prompter.close();
|
|
49
|
-
const extensions = answers.extensions
|
|
50
|
-
.filter((opt) => opt.selected)
|
|
51
|
-
.map((opt) => opt.name);
|
|
52
|
-
const templateRepo = argv.repo ?? core_1.DEFAULT_TEMPLATE_REPO;
|
|
53
|
-
const templatePath = argv.templatePath;
|
|
54
|
-
const dir = argv.dir;
|
|
55
|
-
const templateAnswers = {
|
|
56
|
-
...argv,
|
|
57
|
-
...answers,
|
|
58
|
-
moduleName: modName,
|
|
59
|
-
packageIdentifier: argv.packageIdentifier || modName
|
|
60
|
-
};
|
|
61
|
-
await project.initModule({
|
|
62
|
-
name: modName,
|
|
63
|
-
description: answers.description || modName,
|
|
64
|
-
author: answers.author || modName,
|
|
65
|
-
extensions,
|
|
66
|
-
templateRepo,
|
|
67
|
-
templatePath,
|
|
68
|
-
branch: argv.fromBranch,
|
|
69
|
-
dir,
|
|
70
|
-
toolName: core_1.DEFAULT_TEMPLATE_TOOL_NAME,
|
|
71
|
-
answers: templateAnswers,
|
|
72
|
-
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true')
|
|
73
|
-
});
|
|
74
|
-
const isRoot = path_1.default.resolve(project.getWorkspacePath()) === path_1.default.resolve(cwd);
|
|
75
|
-
const modulePath = isRoot
|
|
76
|
-
? path_1.default.join(cwd, 'packages', modName)
|
|
77
|
-
: path_1.default.join(cwd, modName);
|
|
78
|
-
const motdPath = path_1.default.join(modulePath, '.motd');
|
|
79
|
-
let motd = DEFAULT_MOTD;
|
|
80
|
-
if (fs_1.default.existsSync(motdPath)) {
|
|
81
|
-
try {
|
|
82
|
-
motd = fs_1.default.readFileSync(motdPath, 'utf8');
|
|
83
|
-
fs_1.default.unlinkSync(motdPath);
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
// Ignore errors reading/deleting .motd
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
process.stdout.write(motd);
|
|
90
|
-
if (!motd.endsWith('\n')) {
|
|
91
|
-
process.stdout.write('\n');
|
|
92
|
-
}
|
|
93
|
-
const relPath = isRoot ? `packages/${modName}` : modName;
|
|
94
|
-
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
95
|
-
return { ...argv, ...answers };
|
|
96
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, PgpmPackage, sluggify } from '@pgpmjs/core';
|
|
4
|
-
import { errors } from '@pgpmjs/types';
|
|
5
|
-
const DEFAULT_MOTD = `
|
|
6
|
-
| _ _
|
|
7
|
-
=== |.===. '\\-//\`
|
|
8
|
-
(o o) {}o o{} (o o)
|
|
9
|
-
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
10
|
-
`;
|
|
11
|
-
export default async function runModuleSetup(argv, prompter) {
|
|
12
|
-
const { cwd = process.cwd() } = argv;
|
|
13
|
-
const project = new PgpmPackage(cwd);
|
|
14
|
-
if (!project.workspacePath) {
|
|
15
|
-
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
16
|
-
throw errors.NOT_IN_WORKSPACE({});
|
|
17
|
-
}
|
|
18
|
-
if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
|
|
19
|
-
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
20
|
-
throw errors.NOT_IN_WORKSPACE_MODULE({});
|
|
21
|
-
}
|
|
22
|
-
const availExtensions = project.getAvailableModules();
|
|
23
|
-
const moduleQuestions = [
|
|
24
|
-
{
|
|
25
|
-
name: 'moduleName',
|
|
26
|
-
message: 'Enter the module name',
|
|
27
|
-
required: true,
|
|
28
|
-
type: 'text',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'extensions',
|
|
32
|
-
message: 'Which extensions?',
|
|
33
|
-
options: availExtensions,
|
|
34
|
-
type: 'checkbox',
|
|
35
|
-
allowCustomOptions: true,
|
|
36
|
-
required: true,
|
|
37
|
-
},
|
|
38
|
-
];
|
|
39
|
-
const answers = await prompter.prompt(argv, moduleQuestions);
|
|
40
|
-
const modName = sluggify(answers.moduleName);
|
|
41
|
-
// Avoid overlapping readline listeners with create-gen-app's prompts.
|
|
42
|
-
prompter.close();
|
|
43
|
-
const extensions = answers.extensions
|
|
44
|
-
.filter((opt) => opt.selected)
|
|
45
|
-
.map((opt) => opt.name);
|
|
46
|
-
const templateRepo = argv.repo ?? DEFAULT_TEMPLATE_REPO;
|
|
47
|
-
const templatePath = argv.templatePath;
|
|
48
|
-
const dir = argv.dir;
|
|
49
|
-
const templateAnswers = {
|
|
50
|
-
...argv,
|
|
51
|
-
...answers,
|
|
52
|
-
moduleName: modName,
|
|
53
|
-
packageIdentifier: argv.packageIdentifier || modName
|
|
54
|
-
};
|
|
55
|
-
await project.initModule({
|
|
56
|
-
name: modName,
|
|
57
|
-
description: answers.description || modName,
|
|
58
|
-
author: answers.author || modName,
|
|
59
|
-
extensions,
|
|
60
|
-
templateRepo,
|
|
61
|
-
templatePath,
|
|
62
|
-
branch: argv.fromBranch,
|
|
63
|
-
dir,
|
|
64
|
-
toolName: DEFAULT_TEMPLATE_TOOL_NAME,
|
|
65
|
-
answers: templateAnswers,
|
|
66
|
-
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true')
|
|
67
|
-
});
|
|
68
|
-
const isRoot = path.resolve(project.getWorkspacePath()) === path.resolve(cwd);
|
|
69
|
-
const modulePath = isRoot
|
|
70
|
-
? path.join(cwd, 'packages', modName)
|
|
71
|
-
: path.join(cwd, modName);
|
|
72
|
-
const motdPath = path.join(modulePath, '.motd');
|
|
73
|
-
let motd = DEFAULT_MOTD;
|
|
74
|
-
if (fs.existsSync(motdPath)) {
|
|
75
|
-
try {
|
|
76
|
-
motd = fs.readFileSync(motdPath, 'utf8');
|
|
77
|
-
fs.unlinkSync(motdPath);
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
// Ignore errors reading/deleting .motd
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
process.stdout.write(motd);
|
|
84
|
-
if (!motd.endsWith('\n')) {
|
|
85
|
-
process.stdout.write('\n');
|
|
86
|
-
}
|
|
87
|
-
const relPath = isRoot ? `packages/${modName}` : modName;
|
|
88
|
-
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
89
|
-
return { ...argv, ...answers };
|
|
90
|
-
}
|