pgpm 0.0.2 → 0.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/LICENSE +23 -0
- package/README.md +110 -115
- package/commands/add.js +7 -7
- package/commands/admin-users/add.js +8 -8
- package/commands/admin-users/bootstrap.js +7 -7
- package/commands/admin-users/remove.js +7 -7
- package/commands/admin-users.js +5 -5
- package/commands/analyze.js +1 -1
- package/commands/clear.js +3 -3
- package/commands/deploy.js +7 -7
- package/commands/export.js +4 -4
- package/commands/extension.js +3 -3
- package/commands/init/index.js +8 -8
- package/commands/install.js +6 -6
- package/commands/kill.js +6 -6
- package/commands/migrate/init.js +1 -1
- package/commands/migrate.js +1 -1
- package/commands/package.js +4 -4
- package/commands/plan.js +5 -5
- package/commands/remove.js +2 -2
- package/commands/rename.js +1 -1
- package/commands/revert.js +7 -7
- package/commands/tag.js +6 -6
- package/commands/verify.js +7 -7
- package/commands.d.ts +1 -0
- package/commands.js +7 -16
- package/esm/commands/add.js +7 -7
- package/esm/commands/admin-users/add.js +8 -8
- package/esm/commands/admin-users/bootstrap.js +7 -7
- package/esm/commands/admin-users/remove.js +7 -7
- package/esm/commands/admin-users.js +5 -5
- package/esm/commands/analyze.js +1 -1
- package/esm/commands/clear.js +3 -3
- package/esm/commands/deploy.js +7 -7
- package/esm/commands/export.js +4 -4
- package/esm/commands/extension.js +3 -3
- package/esm/commands/init/index.js +8 -8
- package/esm/commands/init/workspace.js +1 -1
- package/esm/commands/install.js +6 -6
- package/esm/commands/kill.js +6 -6
- package/esm/commands/migrate/init.js +1 -1
- package/esm/commands/migrate.js +1 -1
- package/esm/commands/package.js +4 -4
- package/esm/commands/plan.js +5 -5
- package/esm/commands/remove.js +2 -2
- package/esm/commands/rename.js +1 -1
- package/esm/commands/revert.js +7 -7
- package/esm/commands/tag.js +6 -6
- package/esm/commands/verify.js +7 -7
- package/esm/commands.js +5 -15
- package/esm/index.js +36 -10
- package/esm/utils/cli-error.js +1 -1
- package/esm/utils/display.js +13 -13
- package/esm/utils/index.js +3 -0
- package/index.d.ts +20 -0
- package/index.js +70 -10
- package/package.json +15 -18
- package/utils/cli-error.js +1 -1
- package/utils/display.d.ts +1 -1
- package/utils/display.js +13 -13
- package/utils/index.d.ts +3 -0
- package/utils/index.js +3 -0
- package/commands/explorer.d.ts +0 -3
- package/commands/explorer.js +0 -94
- package/commands/server.d.ts +0 -3
- package/commands/server.js +0 -187
- package/dist/README.md +0 -416
- package/dist/package.json +0 -77
- package/esm/commands/explorer.js +0 -92
- package/esm/commands/server.js +0 -185
package/esm/commands/server.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@launchql/logger';
|
|
2
|
-
import { LaunchQLServer as server } from '@launchql/server';
|
|
3
|
-
import { getEnvOptions } from '@launchql/env';
|
|
4
|
-
import { getPgPool } from 'pg-cache';
|
|
5
|
-
const log = new Logger('server');
|
|
6
|
-
const serverUsageText = `
|
|
7
|
-
LaunchQL Server Command:
|
|
8
|
-
|
|
9
|
-
lql server [OPTIONS]
|
|
10
|
-
|
|
11
|
-
Start LaunchQL GraphQL development server.
|
|
12
|
-
|
|
13
|
-
Options:
|
|
14
|
-
--help, -h Show this help message
|
|
15
|
-
--port <number> Server port (default: 5555)
|
|
16
|
-
--simpleInflection Use simple inflection (default: true)
|
|
17
|
-
--oppositeBaseNames Use opposite base names (default: false)
|
|
18
|
-
--postgis Enable PostGIS extension (default: true)
|
|
19
|
-
--metaApi Enable Meta API (default: true)
|
|
20
|
-
--cwd <directory> Working directory (default: current directory)
|
|
21
|
-
|
|
22
|
-
Examples:
|
|
23
|
-
lql server Start server with defaults
|
|
24
|
-
lql server --port 8080 Start server on custom port
|
|
25
|
-
lql server --no-postgis Start server without PostGIS
|
|
26
|
-
`;
|
|
27
|
-
const questions = [
|
|
28
|
-
{
|
|
29
|
-
name: 'simpleInflection',
|
|
30
|
-
message: 'Use simple inflection?',
|
|
31
|
-
type: 'confirm',
|
|
32
|
-
required: false,
|
|
33
|
-
default: true,
|
|
34
|
-
useDefault: true
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'oppositeBaseNames',
|
|
38
|
-
message: 'Use opposite base names?',
|
|
39
|
-
type: 'confirm',
|
|
40
|
-
required: false,
|
|
41
|
-
default: false,
|
|
42
|
-
useDefault: true
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'postgis',
|
|
46
|
-
message: 'Enable PostGIS extension?',
|
|
47
|
-
type: 'confirm',
|
|
48
|
-
required: false,
|
|
49
|
-
default: true,
|
|
50
|
-
useDefault: true
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: 'metaApi',
|
|
54
|
-
message: 'Enable Meta API?',
|
|
55
|
-
type: 'confirm',
|
|
56
|
-
required: false,
|
|
57
|
-
default: true,
|
|
58
|
-
useDefault: true
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'origin',
|
|
62
|
-
message: 'CORS origin (exact URL or *)',
|
|
63
|
-
type: 'text',
|
|
64
|
-
required: false,
|
|
65
|
-
// no default to avoid accidentally opening up CORS; pass explicitly or via env
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'port',
|
|
69
|
-
message: 'Development server port',
|
|
70
|
-
type: 'number',
|
|
71
|
-
required: false,
|
|
72
|
-
default: 5555,
|
|
73
|
-
useDefault: true
|
|
74
|
-
}
|
|
75
|
-
];
|
|
76
|
-
export default async (argv, prompter, _options) => {
|
|
77
|
-
// Show usage if explicitly requested
|
|
78
|
-
if (argv.help || argv.h) {
|
|
79
|
-
console.log(serverUsageText);
|
|
80
|
-
process.exit(0);
|
|
81
|
-
}
|
|
82
|
-
log.info('🔧 LaunchQL Server Configuration:\n');
|
|
83
|
-
let selectedDb = process.env.PGDATABASE;
|
|
84
|
-
if (!selectedDb) {
|
|
85
|
-
const db = await getPgPool({ database: 'postgres' });
|
|
86
|
-
const result = await db.query(`
|
|
87
|
-
SELECT datname FROM pg_database
|
|
88
|
-
WHERE datistemplate = false AND datname NOT IN ('postgres')
|
|
89
|
-
AND datname !~ '^pg_'
|
|
90
|
-
ORDER BY datname;
|
|
91
|
-
`);
|
|
92
|
-
const dbChoices = result.rows.map(row => row.datname);
|
|
93
|
-
const { database } = await prompter.prompt(argv, [
|
|
94
|
-
{
|
|
95
|
-
type: 'autocomplete',
|
|
96
|
-
name: 'database',
|
|
97
|
-
message: 'Select the database to use',
|
|
98
|
-
options: dbChoices,
|
|
99
|
-
required: true
|
|
100
|
-
}
|
|
101
|
-
]);
|
|
102
|
-
selectedDb = database;
|
|
103
|
-
log.info(`📌 Using database: "${selectedDb}"`);
|
|
104
|
-
}
|
|
105
|
-
const { oppositeBaseNames, port, postgis, simpleInflection, metaApi, origin } = await prompter.prompt(argv, questions);
|
|
106
|
-
// Warn when passing CORS override via CLI, especially in production
|
|
107
|
-
if (origin && origin.trim().length) {
|
|
108
|
-
const env = (process.env.NODE_ENV || 'development').toLowerCase();
|
|
109
|
-
if (env === 'production') {
|
|
110
|
-
if (origin.trim() === '*') {
|
|
111
|
-
log.warn('CORS wildcard ("*") provided via --origin in production: this effectively disables CORS and is not recommended. Prefer per-API CORS via meta schema.');
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
log.warn(`CORS override (origin=${origin.trim()}) provided via --origin in production. Prefer per-API CORS via meta schema.`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
let selectedSchemas = [];
|
|
119
|
-
let authRole;
|
|
120
|
-
let roleName;
|
|
121
|
-
if (!metaApi) {
|
|
122
|
-
const db = await getPgPool({ database: selectedDb });
|
|
123
|
-
const result = await db.query(`
|
|
124
|
-
SELECT nspname
|
|
125
|
-
FROM pg_namespace
|
|
126
|
-
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
|
127
|
-
ORDER BY nspname;
|
|
128
|
-
`);
|
|
129
|
-
const schemaChoices = result.rows.map(row => ({
|
|
130
|
-
name: row.nspname,
|
|
131
|
-
value: row.nspname,
|
|
132
|
-
selected: true
|
|
133
|
-
}));
|
|
134
|
-
const { schemas } = await prompter.prompt(argv, [
|
|
135
|
-
{
|
|
136
|
-
type: 'checkbox',
|
|
137
|
-
name: 'schemas',
|
|
138
|
-
message: 'Select schemas to expose',
|
|
139
|
-
options: schemaChoices,
|
|
140
|
-
required: true
|
|
141
|
-
}
|
|
142
|
-
]);
|
|
143
|
-
selectedSchemas = schemas.filter(s => s.selected).map(s => s.value);
|
|
144
|
-
const { authRole: selectedAuthRole, roleName: selectedRoleName } = await prompter.prompt(argv, [
|
|
145
|
-
{
|
|
146
|
-
type: 'autocomplete',
|
|
147
|
-
name: 'authRole',
|
|
148
|
-
message: 'Select the authentication role',
|
|
149
|
-
options: ['postgres', 'authenticated', 'anonymous'],
|
|
150
|
-
required: true
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
type: 'autocomplete',
|
|
154
|
-
name: 'roleName',
|
|
155
|
-
message: 'Enter the default role name:',
|
|
156
|
-
options: ['postgres', 'authenticated', 'anonymous'],
|
|
157
|
-
required: true
|
|
158
|
-
}
|
|
159
|
-
]);
|
|
160
|
-
authRole = selectedAuthRole;
|
|
161
|
-
roleName = selectedRoleName;
|
|
162
|
-
}
|
|
163
|
-
const options = getEnvOptions({
|
|
164
|
-
pg: { database: selectedDb },
|
|
165
|
-
features: {
|
|
166
|
-
oppositeBaseNames,
|
|
167
|
-
simpleInflection,
|
|
168
|
-
postgis
|
|
169
|
-
},
|
|
170
|
-
api: {
|
|
171
|
-
enableMetaApi: metaApi,
|
|
172
|
-
...(metaApi === false && { exposedSchemas: selectedSchemas, authRole, roleName })
|
|
173
|
-
},
|
|
174
|
-
server: {
|
|
175
|
-
port,
|
|
176
|
-
...(origin ? { origin } : {})
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
log.success('✅ Selected Configuration:');
|
|
180
|
-
for (const [key, value] of Object.entries(options)) {
|
|
181
|
-
log.debug(`${key}: ${JSON.stringify(value)}`);
|
|
182
|
-
}
|
|
183
|
-
log.success('🚀 Launching Server...\n');
|
|
184
|
-
server(options);
|
|
185
|
-
};
|