directus-template-cli 0.7.4 → 0.7.6
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/bin/dev.js +0 -1
- package/bin/run.js +1 -0
- package/dist/commands/apply.d.ts +2 -1
- package/dist/commands/apply.js +42 -34
- package/dist/commands/base.d.ts +2 -2
- package/dist/commands/base.js +14 -14
- package/dist/commands/extract.d.ts +2 -2
- package/dist/commands/extract.js +17 -17
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +34 -26
- package/dist/lib/init/index.js +14 -13
- package/dist/lib/load/apply-flags.d.ts +2 -1
- package/dist/lib/load/load-collections.js +0 -2
- package/dist/lib/load/load-settings.js +0 -2
- package/dist/lib/sdk.d.ts +1 -1
- package/dist/lib/types/extension.d.ts +2 -2
- package/dist/lib/types.d.ts +4 -4
- package/dist/lib/utils/animated-bunny.js +2 -2
- package/dist/lib/utils/auth.d.ts +5 -5
- package/dist/lib/utils/auth.js +14 -13
- package/dist/lib/utils/catch-error.js +4 -4
- package/dist/lib/utils/logger.js +1 -1
- package/dist/lib/utils/parse-github-url.js +3 -3
- package/dist/lib/utils/path.js +1 -1
- package/dist/lib/utils/read-templates.d.ts +1 -1
- package/dist/lib/utils/sanitize-flags.js +2 -4
- package/dist/lib/utils/template-config.d.ts +1 -1
- package/dist/lib/utils/template-config.js +1 -1
- package/dist/services/docker.js +24 -19
- package/dist/services/execution-context.d.ts +1 -1
- package/dist/services/github.d.ts +1 -1
- package/dist/services/github.js +16 -16
- package/dist/services/posthog.d.ts +10 -10
- package/dist/services/posthog.js +5 -5
- package/oclif.manifest.json +28 -22
- package/package.json +8 -7
package/dist/services/github.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ux } from '@oclif/core';
|
|
1
2
|
import { Octokit } from '@octokit/rest';
|
|
2
3
|
import { DEFAULT_REPO } from '../lib/constants.js';
|
|
3
4
|
import { parseGitHubUrl } from '../lib/utils/parse-github-url.js';
|
|
4
|
-
import { ux } from '@oclif/core';
|
|
5
5
|
export function createGitHub(token) {
|
|
6
6
|
const octokit = new Octokit({
|
|
7
7
|
auth: token,
|
|
@@ -19,9 +19,9 @@ export function createGitHub(token) {
|
|
|
19
19
|
try {
|
|
20
20
|
const { data } = await octokit.rest.repos.getContent({
|
|
21
21
|
owner: repo.owner,
|
|
22
|
-
repo: repo.repo,
|
|
23
22
|
path: repo.path || '',
|
|
24
23
|
ref: repo.ref,
|
|
24
|
+
repo: repo.repo,
|
|
25
25
|
});
|
|
26
26
|
if (!Array.isArray(data))
|
|
27
27
|
return [];
|
|
@@ -31,7 +31,7 @@ export function createGitHub(token) {
|
|
|
31
31
|
.filter(item => item.type === 'dir')
|
|
32
32
|
.map(item => item.name);
|
|
33
33
|
}
|
|
34
|
-
catch
|
|
34
|
+
catch {
|
|
35
35
|
// If we can't get contents, return empty array
|
|
36
36
|
// This indicates no frontends are available
|
|
37
37
|
return [];
|
|
@@ -53,7 +53,7 @@ export function createGitHub(token) {
|
|
|
53
53
|
.filter(item => item.type === 'dir' && item.name !== 'directus')
|
|
54
54
|
.map(item => item.name);
|
|
55
55
|
}
|
|
56
|
-
catch
|
|
56
|
+
catch {
|
|
57
57
|
// If we can't get contents, return empty array
|
|
58
58
|
return [];
|
|
59
59
|
}
|
|
@@ -74,13 +74,13 @@ export function createGitHub(token) {
|
|
|
74
74
|
const packageJsonPath = joinPath(parsed.path || '', 'package.json');
|
|
75
75
|
try {
|
|
76
76
|
const { data: packageJsonContent } = await octokit.rest.repos.getContent({
|
|
77
|
-
owner: parsed.owner,
|
|
78
|
-
repo: parsed.repo,
|
|
79
|
-
path: packageJsonPath,
|
|
80
|
-
ref: parsed.ref,
|
|
81
77
|
mediaType: {
|
|
82
78
|
format: 'raw',
|
|
83
79
|
},
|
|
80
|
+
owner: parsed.owner,
|
|
81
|
+
path: packageJsonPath,
|
|
82
|
+
ref: parsed.ref,
|
|
83
|
+
repo: parsed.repo,
|
|
84
84
|
});
|
|
85
85
|
// getContent with mediaType: raw returns string directly
|
|
86
86
|
if (typeof packageJsonContent === 'string') {
|
|
@@ -103,7 +103,7 @@ export function createGitHub(token) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
// Return a single item array for the direct URL case
|
|
106
|
-
return [{ id: customUrl, name
|
|
106
|
+
return [{ description, id: customUrl, name }];
|
|
107
107
|
}
|
|
108
108
|
const repo = customUrl ? parseGitHubUrl(customUrl) : DEFAULT_REPO;
|
|
109
109
|
const { data: rootContent } = await octokit.rest.repos.getContent({
|
|
@@ -116,19 +116,19 @@ export function createGitHub(token) {
|
|
|
116
116
|
return [];
|
|
117
117
|
const directories = rootContent.filter(item => item.type === 'dir');
|
|
118
118
|
// Fetch package.json for each directory concurrently
|
|
119
|
-
|
|
119
|
+
const templateInfos = await Promise.all(directories.map(async (dir) => {
|
|
120
120
|
const packageJsonPath = joinPath(repo.path || '', dir.path, 'package.json');
|
|
121
|
-
let name = dir
|
|
121
|
+
let { name } = dir;
|
|
122
122
|
let description;
|
|
123
123
|
try {
|
|
124
124
|
const { data: packageJsonContent } = await octokit.rest.repos.getContent({
|
|
125
|
-
owner: repo.owner,
|
|
126
|
-
repo: repo.repo,
|
|
127
|
-
path: packageJsonPath,
|
|
128
|
-
ref: repo.ref,
|
|
129
125
|
mediaType: {
|
|
130
126
|
format: 'raw',
|
|
131
127
|
},
|
|
128
|
+
owner: repo.owner,
|
|
129
|
+
path: packageJsonPath,
|
|
130
|
+
ref: repo.ref,
|
|
131
|
+
repo: repo.repo,
|
|
132
132
|
});
|
|
133
133
|
// getContent with mediaType: raw returns string directly
|
|
134
134
|
if (typeof packageJsonContent === 'string') {
|
|
@@ -149,9 +149,9 @@ export function createGitHub(token) {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
return {
|
|
152
|
+
description,
|
|
152
153
|
id: dir.name,
|
|
153
154
|
name,
|
|
154
|
-
description,
|
|
155
155
|
};
|
|
156
156
|
}));
|
|
157
157
|
// Sort the templates to put "blank" last
|
|
@@ -24,16 +24,16 @@ export declare function shutdown(debug?: boolean): Promise<void>;
|
|
|
24
24
|
* @param options.properties Optional additional properties to track
|
|
25
25
|
* @param options.debug Whether to log debug information
|
|
26
26
|
*/
|
|
27
|
-
export declare function track({
|
|
28
|
-
lifecycle: 'start' | 'complete' | 'error';
|
|
29
|
-
message?: string;
|
|
30
|
-
distinctId: string;
|
|
27
|
+
export declare function track({ command, config, debug, distinctId, flags, lifecycle, message, properties, runId }: {
|
|
31
28
|
command?: string;
|
|
32
|
-
flags?: Record<string, unknown>;
|
|
33
|
-
runId?: string;
|
|
34
29
|
config?: Config;
|
|
35
|
-
properties?: Record<string, unknown>;
|
|
36
30
|
debug?: boolean;
|
|
31
|
+
distinctId: string;
|
|
32
|
+
flags?: Record<string, unknown>;
|
|
33
|
+
lifecycle: 'complete' | 'error' | 'start';
|
|
34
|
+
message?: string;
|
|
35
|
+
properties?: Record<string, unknown>;
|
|
36
|
+
runId?: string;
|
|
37
37
|
}): void;
|
|
38
38
|
/**
|
|
39
39
|
* Manually capture an exception in PostHog
|
|
@@ -42,9 +42,9 @@ export declare function track({ lifecycle, distinctId, command, flags, runId, me
|
|
|
42
42
|
* @param properties Optional additional properties to track
|
|
43
43
|
* @param debug Whether to log debug information
|
|
44
44
|
*/
|
|
45
|
-
export declare function captureException({
|
|
46
|
-
|
|
45
|
+
export declare function captureException({ debug, distinctId, error, properties }: {
|
|
46
|
+
debug?: boolean;
|
|
47
47
|
distinctId: string;
|
|
48
|
+
error: unknown;
|
|
48
49
|
properties?: Record<string, unknown>;
|
|
49
|
-
debug?: boolean;
|
|
50
50
|
}): void;
|
package/dist/services/posthog.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ux } from '@oclif/core';
|
|
2
2
|
import { PostHog } from 'posthog-node';
|
|
3
|
-
import {
|
|
3
|
+
import { POSTHOG_HOST, POSTHOG_PUBLIC_KEY } from '../lib/constants.js';
|
|
4
4
|
import { sanitizeFlags } from '../lib/utils/sanitize-flags.js';
|
|
5
5
|
// Create a singleton client using module scope
|
|
6
6
|
let client = null;
|
|
@@ -14,8 +14,8 @@ export function getClient(debug = false) {
|
|
|
14
14
|
ux.stdout('Initializing PostHog client...');
|
|
15
15
|
if (!client) {
|
|
16
16
|
client = new PostHog(POSTHOG_PUBLIC_KEY, {
|
|
17
|
-
host: POSTHOG_HOST,
|
|
18
17
|
disableGeoip: false,
|
|
18
|
+
host: POSTHOG_HOST,
|
|
19
19
|
});
|
|
20
20
|
// Add error handling
|
|
21
21
|
client.on('error', err => {
|
|
@@ -58,14 +58,14 @@ export async function shutdown(debug = false) {
|
|
|
58
58
|
* @param options.properties Optional additional properties to track
|
|
59
59
|
* @param options.debug Whether to log debug information
|
|
60
60
|
*/
|
|
61
|
-
export function track({
|
|
61
|
+
export function track({ command, config, debug = false, distinctId, flags, lifecycle, message, properties = {}, runId }) {
|
|
62
62
|
if (debug)
|
|
63
63
|
ux.stdout('Tracking event...');
|
|
64
64
|
const phClient = getClient(debug);
|
|
65
65
|
const eventProperties = command
|
|
66
66
|
? {
|
|
67
|
-
runId,
|
|
68
67
|
message,
|
|
68
|
+
runId,
|
|
69
69
|
...properties,
|
|
70
70
|
...getEnvironmentInfo(config),
|
|
71
71
|
// Always sanitize sensitive flags
|
|
@@ -91,7 +91,7 @@ export function track({ lifecycle, distinctId, command, flags, runId, message, c
|
|
|
91
91
|
* @param properties Optional additional properties to track
|
|
92
92
|
* @param debug Whether to log debug information
|
|
93
93
|
*/
|
|
94
|
-
export function captureException({
|
|
94
|
+
export function captureException({ debug = false, distinctId, error, properties = {} }) {
|
|
95
95
|
if (debug)
|
|
96
96
|
ux.stdout('Capturing exception...');
|
|
97
97
|
const phClient = getClient(debug);
|
package/oclif.manifest.json
CHANGED
|
@@ -42,6 +42,13 @@
|
|
|
42
42
|
"multiple": false,
|
|
43
43
|
"type": "option"
|
|
44
44
|
},
|
|
45
|
+
"disableTelemetry": {
|
|
46
|
+
"description": "Disable telemetry",
|
|
47
|
+
"env": "DISABLE_TELEMETRY",
|
|
48
|
+
"name": "disableTelemetry",
|
|
49
|
+
"allowNo": false,
|
|
50
|
+
"type": "boolean"
|
|
51
|
+
},
|
|
45
52
|
"extensions": {
|
|
46
53
|
"description": "Load Extensions",
|
|
47
54
|
"name": "extensions",
|
|
@@ -60,6 +67,12 @@
|
|
|
60
67
|
"allowNo": true,
|
|
61
68
|
"type": "boolean"
|
|
62
69
|
},
|
|
70
|
+
"noExit": {
|
|
71
|
+
"hidden": true,
|
|
72
|
+
"name": "noExit",
|
|
73
|
+
"allowNo": false,
|
|
74
|
+
"type": "boolean"
|
|
75
|
+
},
|
|
63
76
|
"partial": {
|
|
64
77
|
"dependsOn": [
|
|
65
78
|
"programmatic"
|
|
@@ -159,13 +172,6 @@
|
|
|
159
172
|
"name": "users",
|
|
160
173
|
"allowNo": true,
|
|
161
174
|
"type": "boolean"
|
|
162
|
-
},
|
|
163
|
-
"disableTelemetry": {
|
|
164
|
-
"description": "Disable telemetry",
|
|
165
|
-
"env": "DISABLE_TELEMETRY",
|
|
166
|
-
"name": "disableTelemetry",
|
|
167
|
-
"allowNo": false,
|
|
168
|
-
"type": "boolean"
|
|
169
175
|
}
|
|
170
176
|
},
|
|
171
177
|
"hasDynamicHelp": false,
|
|
@@ -231,6 +237,13 @@
|
|
|
231
237
|
"multiple": false,
|
|
232
238
|
"type": "option"
|
|
233
239
|
},
|
|
240
|
+
"disableTelemetry": {
|
|
241
|
+
"description": "Disable telemetry",
|
|
242
|
+
"env": "DISABLE_TELEMETRY",
|
|
243
|
+
"name": "disableTelemetry",
|
|
244
|
+
"allowNo": false,
|
|
245
|
+
"type": "boolean"
|
|
246
|
+
},
|
|
234
247
|
"programmatic": {
|
|
235
248
|
"char": "p",
|
|
236
249
|
"description": "Run in programmatic mode (non-interactive) for use cases such as CI/CD pipelines.",
|
|
@@ -288,13 +301,6 @@
|
|
|
288
301
|
"hasDynamicHelp": false,
|
|
289
302
|
"multiple": false,
|
|
290
303
|
"type": "option"
|
|
291
|
-
},
|
|
292
|
-
"disableTelemetry": {
|
|
293
|
-
"description": "Disable telemetry",
|
|
294
|
-
"env": "DISABLE_TELEMETRY",
|
|
295
|
-
"name": "disableTelemetry",
|
|
296
|
-
"allowNo": false,
|
|
297
|
-
"type": "boolean"
|
|
298
304
|
}
|
|
299
305
|
},
|
|
300
306
|
"hasDynamicHelp": false,
|
|
@@ -330,6 +336,13 @@
|
|
|
330
336
|
"$ directus-template-cli init my-project --frontend=nextjs --template=simple-cms"
|
|
331
337
|
],
|
|
332
338
|
"flags": {
|
|
339
|
+
"disableTelemetry": {
|
|
340
|
+
"description": "Disable telemetry",
|
|
341
|
+
"env": "DISABLE_TELEMETRY",
|
|
342
|
+
"name": "disableTelemetry",
|
|
343
|
+
"allowNo": false,
|
|
344
|
+
"type": "boolean"
|
|
345
|
+
},
|
|
333
346
|
"frontend": {
|
|
334
347
|
"description": "Frontend framework to use (e.g., nextjs, nuxt, astro)",
|
|
335
348
|
"name": "frontend",
|
|
@@ -370,13 +383,6 @@
|
|
|
370
383
|
"hasDynamicHelp": false,
|
|
371
384
|
"multiple": false,
|
|
372
385
|
"type": "option"
|
|
373
|
-
},
|
|
374
|
-
"disableTelemetry": {
|
|
375
|
-
"description": "Disable telemetry",
|
|
376
|
-
"env": "DISABLE_TELEMETRY",
|
|
377
|
-
"name": "disableTelemetry",
|
|
378
|
-
"allowNo": false,
|
|
379
|
-
"type": "boolean"
|
|
380
386
|
}
|
|
381
387
|
},
|
|
382
388
|
"hasDynamicHelp": false,
|
|
@@ -395,5 +401,5 @@
|
|
|
395
401
|
]
|
|
396
402
|
}
|
|
397
403
|
},
|
|
398
|
-
"version": "0.7.
|
|
404
|
+
"version": "0.7.6"
|
|
399
405
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directus-template-cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
4
4
|
"description": "CLI Utility for applying templates to a Directus instance.",
|
|
5
5
|
"author": "bryantgillespie @bryantgillespie",
|
|
6
6
|
"type": "module",
|
|
@@ -42,21 +42,21 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@directus/types": "^13.0.0",
|
|
45
|
+
"@eslint/compat": "^1",
|
|
45
46
|
"@oclif/prettier-config": "^0.2.1",
|
|
46
47
|
"@oclif/test": "^4",
|
|
47
48
|
"@types/chai": "^5.2.0",
|
|
48
49
|
"@types/mocha": "^10",
|
|
49
50
|
"@types/node": "^18",
|
|
50
51
|
"chai": "^5.2.0",
|
|
51
|
-
"eslint": "^9",
|
|
52
|
-
"eslint-config-oclif": "^
|
|
53
|
-
"eslint-config-
|
|
54
|
-
"eslint-config-prettier": "^9",
|
|
52
|
+
"eslint": "^9.39.2",
|
|
53
|
+
"eslint-config-oclif": "^6.0.130",
|
|
54
|
+
"eslint-config-prettier": "^10",
|
|
55
55
|
"mocha": "^10",
|
|
56
56
|
"oclif": "^4",
|
|
57
|
+
"prettier": "^3.7.4",
|
|
57
58
|
"shx": "^0.3.3",
|
|
58
59
|
"ts-node": "^10",
|
|
59
|
-
"tslib": "^2.8.1",
|
|
60
60
|
"typescript": "^5.8.2"
|
|
61
61
|
},
|
|
62
62
|
"oclif": {
|
|
@@ -85,7 +85,8 @@
|
|
|
85
85
|
"types": "dist/index.d.ts",
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "shx rm -rf dist && tsc -b",
|
|
88
|
-
"
|
|
88
|
+
"format": "prettier --write .",
|
|
89
|
+
"lint": "eslint",
|
|
89
90
|
"posttest": "pnpm run lint",
|
|
90
91
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
91
92
|
"version": "oclif readme && git add README.md",
|