directus-template-cli 0.7.0-beta.4 → 0.7.0-beta.5
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 +2 -3
- package/bin/dev.js +3 -0
- package/bin/run +0 -1
- package/bin/run.js +5 -0
- package/dist/commands/apply.d.ts +17 -17
- package/dist/commands/apply.js +160 -173
- package/dist/commands/extract.d.ts +13 -7
- package/dist/commands/extract.js +89 -73
- package/dist/commands/init.d.ts +7 -7
- package/dist/commands/init.js +78 -80
- package/dist/flags/common.d.ts +7 -7
- package/dist/flags/common.js +8 -11
- package/dist/index.js +1 -5
- package/dist/lib/constants.js +6 -9
- package/dist/lib/extract/extract-access.js +11 -15
- package/dist/lib/extract/extract-assets.js +20 -25
- package/dist/lib/extract/extract-collections.js +12 -16
- package/dist/lib/extract/extract-content.js +14 -19
- package/dist/lib/extract/extract-dashboards.js +22 -28
- package/dist/lib/extract/extract-extensions.js +12 -16
- package/dist/lib/extract/extract-fields.js +13 -17
- package/dist/lib/extract/extract-files.js +15 -19
- package/dist/lib/extract/extract-flows.js +22 -28
- package/dist/lib/extract/extract-folders.js +15 -19
- package/dist/lib/extract/extract-permissions.js +12 -16
- package/dist/lib/extract/extract-policies.js +12 -16
- package/dist/lib/extract/extract-presets.js +12 -16
- package/dist/lib/extract/extract-relations.js +14 -18
- package/dist/lib/extract/extract-roles.js +15 -19
- package/dist/lib/extract/extract-schema.js +17 -21
- package/dist/lib/extract/extract-settings.js +12 -16
- package/dist/lib/extract/extract-translations.js +12 -16
- package/dist/lib/extract/extract-users.js +15 -19
- package/dist/lib/extract/index.js +47 -51
- package/dist/lib/init/config.d.ts +1 -1
- package/dist/lib/init/config.js +2 -5
- package/dist/lib/init/index.js +54 -59
- package/dist/lib/init/types.js +1 -2
- package/dist/lib/init.d.ts +1 -0
- package/dist/lib/init.js +2 -0
- package/dist/lib/load/apply-flags.js +17 -23
- package/dist/lib/load/index.js +40 -44
- package/dist/lib/load/load-access.js +15 -20
- package/dist/lib/load/load-collections.js +27 -32
- package/dist/lib/load/load-dashboards.js +19 -25
- package/dist/lib/load/load-data.js +43 -49
- package/dist/lib/load/load-extensions.js +30 -38
- package/dist/lib/load/load-files.js +20 -24
- package/dist/lib/load/load-flows.js +23 -29
- package/dist/lib/load/load-folders.js +16 -20
- package/dist/lib/load/load-permissions.js +13 -17
- package/dist/lib/load/load-policies.js +14 -18
- package/dist/lib/load/load-presets.js +14 -18
- package/dist/lib/load/load-relations.d.ts +2 -0
- package/dist/lib/load/load-relations.js +16 -18
- package/dist/lib/load/load-roles.js +19 -23
- package/dist/lib/load/load-settings.js +18 -21
- package/dist/lib/load/load-translations.js +14 -18
- package/dist/lib/load/load-users.js +21 -25
- package/dist/lib/load/update-required-fields.js +13 -17
- package/dist/lib/sdk.d.ts +1 -2
- package/dist/lib/sdk.js +27 -27
- package/dist/lib/types/extension.js +1 -2
- package/dist/lib/utils/animated-bunny.js +9 -14
- package/dist/lib/utils/auth.d.ts +2 -2
- package/dist/lib/utils/auth.js +32 -33
- package/dist/lib/utils/catch-error.js +8 -11
- package/dist/lib/utils/check-template.js +4 -8
- package/dist/lib/utils/chunk-array.js +1 -5
- package/dist/lib/utils/ensure-dir.js +7 -12
- package/dist/lib/utils/filter-fields.js +1 -4
- package/dist/lib/utils/get-role-ids.d.ts +1 -1
- package/dist/lib/utils/get-role-ids.js +7 -12
- package/dist/lib/utils/get-template.js +33 -37
- package/dist/lib/utils/logger.js +11 -13
- package/dist/lib/utils/open-url.js +5 -8
- package/dist/lib/utils/parse-github-url.js +4 -9
- package/dist/lib/utils/path.js +6 -10
- package/dist/lib/utils/protected-domains.js +1 -4
- package/dist/lib/utils/read-file.js +8 -12
- package/dist/lib/utils/read-templates.js +9 -15
- package/dist/lib/utils/system-fields.js +19 -22
- package/dist/lib/utils/template-defaults.d.ts +1 -1
- package/dist/lib/utils/template-defaults.js +5 -14
- package/dist/lib/utils/transform-github-url.js +1 -5
- package/dist/lib/utils/validate-url.js +3 -6
- package/dist/lib/utils/wait.js +1 -5
- package/dist/lib/utils/write-to-file.js +8 -11
- package/dist/services/docker.js +11 -18
- package/dist/services/github.d.ts +1 -1
- package/dist/services/github.js +8 -12
- package/oclif.manifest.json +4 -4
- package/package.json +36 -32
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const protected_domains_1 = require("./protected-domains");
|
|
4
|
-
function validateUrl(url) {
|
|
1
|
+
import { protectedDomains } from './protected-domains.js';
|
|
2
|
+
export default function validateUrl(url) {
|
|
5
3
|
try {
|
|
6
4
|
const parsedUrl = new URL(url);
|
|
7
|
-
return !
|
|
5
|
+
return !protectedDomains.includes(parsedUrl.hostname);
|
|
8
6
|
}
|
|
9
7
|
catch {
|
|
10
8
|
return false;
|
|
11
9
|
}
|
|
12
10
|
}
|
|
13
|
-
exports.default = validateUrl;
|
package/dist/lib/utils/wait.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitFor = void 0;
|
|
4
|
-
async function waitFor(checkFn, options = {}) {
|
|
1
|
+
export async function waitFor(checkFn, options = {}) {
|
|
5
2
|
const { errorMessage = 'Operation timed out', interval = 2000, maxAttempts = 30, } = options;
|
|
6
3
|
for (let i = 0; i < maxAttempts; i++) {
|
|
7
4
|
if (await checkFn())
|
|
@@ -10,4 +7,3 @@ async function waitFor(checkFn, options = {}) {
|
|
|
10
7
|
}
|
|
11
8
|
throw new Error(errorMessage);
|
|
12
9
|
}
|
|
13
|
-
exports.waitFor = waitFor;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
5
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
-
exports.default = async (fileName, data, dir) => {
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'pathe';
|
|
3
|
+
export default async (fileName, data, dir) => {
|
|
7
4
|
const folders = fileName.split('/');
|
|
8
5
|
const endFileName = folders.pop();
|
|
9
6
|
const folderPath = folders.join('/');
|
|
10
7
|
// Generate the full path where you want to write the file
|
|
11
|
-
const fullPath =
|
|
8
|
+
const fullPath = path.join(dir, folderPath);
|
|
12
9
|
// Check if the directory exists. Create if it doesn't.
|
|
13
|
-
if (!
|
|
14
|
-
|
|
10
|
+
if (!fs.existsSync(fullPath)) {
|
|
11
|
+
fs.mkdirSync(fullPath, { recursive: true });
|
|
15
12
|
}
|
|
16
13
|
// Construct the full file path
|
|
17
|
-
const fullFilePath =
|
|
14
|
+
const fullFilePath = path.join(fullPath, `${endFileName}.json`);
|
|
18
15
|
try {
|
|
19
16
|
// Write the file
|
|
20
|
-
await
|
|
17
|
+
await fs.promises.writeFile(fullFilePath, JSON.stringify(data, null, 2));
|
|
21
18
|
// console.log(`Wrote ${fullFilePath}`);
|
|
22
19
|
}
|
|
23
20
|
catch (error) {
|
package/dist/services/docker.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const prompts_1 = require("@clack/prompts");
|
|
6
|
-
const catch_error_1 = tslib_1.__importDefault(require("../lib/utils/catch-error"));
|
|
7
|
-
const wait_1 = require("../lib/utils/wait");
|
|
1
|
+
import { spinner } from '@clack/prompts';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import catchError from '../lib/utils/catch-error.js';
|
|
4
|
+
import { waitFor } from '../lib/utils/wait.js';
|
|
8
5
|
/**
|
|
9
6
|
* Check if Docker is installed and running
|
|
10
7
|
* @returns {Promise<DockerCheckResult>} Docker installation and running status
|
|
@@ -12,7 +9,6 @@ const wait_1 = require("../lib/utils/wait");
|
|
|
12
9
|
async function checkDocker() {
|
|
13
10
|
try {
|
|
14
11
|
// Check if Docker is installed
|
|
15
|
-
const { execa } = await Promise.resolve().then(() => tslib_1.__importStar(require('execa')));
|
|
16
12
|
const versionResult = await execa('docker', ['--version']);
|
|
17
13
|
const isInstalled = versionResult.exitCode === 0;
|
|
18
14
|
if (!isInstalled) {
|
|
@@ -43,9 +39,8 @@ async function checkDocker() {
|
|
|
43
39
|
*/
|
|
44
40
|
async function startContainers(cwd) {
|
|
45
41
|
try {
|
|
46
|
-
const { execa } = await Promise.resolve().then(() => tslib_1.__importStar(require('execa')));
|
|
47
42
|
// ux.action.start('Starting Docker containers')
|
|
48
|
-
const s =
|
|
43
|
+
const s = spinner();
|
|
49
44
|
s.start('Starting Docker containers');
|
|
50
45
|
return execa('docker-compose', ['up', '-d'], {
|
|
51
46
|
cwd,
|
|
@@ -55,7 +50,7 @@ async function startContainers(cwd) {
|
|
|
55
50
|
});
|
|
56
51
|
}
|
|
57
52
|
catch (error) {
|
|
58
|
-
(
|
|
53
|
+
catchError(error, {
|
|
59
54
|
context: { cwd, function: 'startContainers' },
|
|
60
55
|
fatal: true,
|
|
61
56
|
logToFile: true,
|
|
@@ -70,14 +65,13 @@ async function startContainers(cwd) {
|
|
|
70
65
|
*/
|
|
71
66
|
async function stopContainers(cwd) {
|
|
72
67
|
try {
|
|
73
|
-
const { execa } = await Promise.resolve().then(() => tslib_1.__importStar(require('execa')));
|
|
74
68
|
return execa('docker-compose', ['down'], {
|
|
75
69
|
cwd,
|
|
76
70
|
// stdio: 'inherit',
|
|
77
71
|
}).then(() => { });
|
|
78
72
|
}
|
|
79
73
|
catch (error) {
|
|
80
|
-
(
|
|
74
|
+
catchError(error, {
|
|
81
75
|
context: { cwd, function: 'stopContainers' },
|
|
82
76
|
fatal: false,
|
|
83
77
|
logToFile: true,
|
|
@@ -92,10 +86,10 @@ async function stopContainers(cwd) {
|
|
|
92
86
|
*/
|
|
93
87
|
function createWaitForHealthy(config) {
|
|
94
88
|
async function waitForHealthy(healthCheckUrl) {
|
|
95
|
-
const s =
|
|
89
|
+
const s = spinner();
|
|
96
90
|
s.start('Waiting for Directus to be ready.');
|
|
97
91
|
try {
|
|
98
|
-
await
|
|
92
|
+
await waitFor(async () => {
|
|
99
93
|
try {
|
|
100
94
|
const response = await fetch(healthCheckUrl);
|
|
101
95
|
return response.ok;
|
|
@@ -113,7 +107,7 @@ function createWaitForHealthy(config) {
|
|
|
113
107
|
}
|
|
114
108
|
catch (error) {
|
|
115
109
|
s.stop('');
|
|
116
|
-
(
|
|
110
|
+
catchError(error, {
|
|
117
111
|
context: { function: 'waitForHealthy', url: healthCheckUrl },
|
|
118
112
|
fatal: true,
|
|
119
113
|
logToFile: true,
|
|
@@ -128,7 +122,7 @@ function createWaitForHealthy(config) {
|
|
|
128
122
|
* @param {DockerConfig} config - The Docker configuration
|
|
129
123
|
* @returns {DockerService} - Returns a Docker service instance
|
|
130
124
|
*/
|
|
131
|
-
function createDocker(config) {
|
|
125
|
+
export function createDocker(config) {
|
|
132
126
|
return {
|
|
133
127
|
checkDocker,
|
|
134
128
|
startContainers,
|
|
@@ -136,4 +130,3 @@ function createDocker(config) {
|
|
|
136
130
|
waitForHealthy: createWaitForHealthy(config),
|
|
137
131
|
};
|
|
138
132
|
}
|
|
139
|
-
exports.createDocker = createDocker;
|
package/dist/services/github.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const parse_github_url_1 = require("../lib/utils/parse-github-url");
|
|
7
|
-
function createGitHub(token) {
|
|
8
|
-
const octokit = new rest_1.Octokit({
|
|
1
|
+
import { Octokit } from '@octokit/rest';
|
|
2
|
+
import { DEFAULT_REPO } from '../lib/constants.js';
|
|
3
|
+
import { parseGitHubUrl } from '../lib/utils/parse-github-url.js';
|
|
4
|
+
export function createGitHub(token) {
|
|
5
|
+
const octokit = new Octokit({
|
|
9
6
|
auth: token,
|
|
10
7
|
});
|
|
11
8
|
/**
|
|
@@ -15,7 +12,7 @@ function createGitHub(token) {
|
|
|
15
12
|
* @returns The directories for the template.
|
|
16
13
|
*/
|
|
17
14
|
async function getTemplateDirectories(template, customUrl) {
|
|
18
|
-
const repo = customUrl ?
|
|
15
|
+
const repo = customUrl ? parseGitHubUrl(customUrl) : DEFAULT_REPO;
|
|
19
16
|
const templatePath = repo.path ? `${repo.path}/${template}` : template;
|
|
20
17
|
const { data } = await octokit.rest.repos.getContent({
|
|
21
18
|
owner: repo.owner,
|
|
@@ -35,7 +32,7 @@ function createGitHub(token) {
|
|
|
35
32
|
* @returns The templates for the repository.
|
|
36
33
|
*/
|
|
37
34
|
async function getTemplates(customUrl) {
|
|
38
|
-
const repo = customUrl ?
|
|
35
|
+
const repo = customUrl ? parseGitHubUrl(customUrl) : DEFAULT_REPO;
|
|
39
36
|
const { data } = await octokit.rest.repos.getContent({
|
|
40
37
|
owner: repo.owner,
|
|
41
38
|
path: repo.path || '',
|
|
@@ -51,7 +48,6 @@ function createGitHub(token) {
|
|
|
51
48
|
return {
|
|
52
49
|
getTemplateDirectories,
|
|
53
50
|
getTemplates,
|
|
54
|
-
parseGitHubUrl
|
|
51
|
+
parseGitHubUrl,
|
|
55
52
|
};
|
|
56
53
|
}
|
|
57
|
-
exports.createGitHub = createGitHub;
|
package/oclif.manifest.json
CHANGED
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
"pluginType": "core",
|
|
170
170
|
"strict": true,
|
|
171
171
|
"enableJsonFlag": false,
|
|
172
|
-
"isESM":
|
|
172
|
+
"isESM": true,
|
|
173
173
|
"relativePath": [
|
|
174
174
|
"dist",
|
|
175
175
|
"commands",
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
"pluginType": "core",
|
|
273
273
|
"strict": true,
|
|
274
274
|
"enableJsonFlag": false,
|
|
275
|
-
"isESM":
|
|
275
|
+
"isESM": true,
|
|
276
276
|
"relativePath": [
|
|
277
277
|
"dist",
|
|
278
278
|
"commands",
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
"pluginType": "core",
|
|
352
352
|
"strict": true,
|
|
353
353
|
"enableJsonFlag": false,
|
|
354
|
-
"isESM":
|
|
354
|
+
"isESM": true,
|
|
355
355
|
"relativePath": [
|
|
356
356
|
"dist",
|
|
357
357
|
"commands",
|
|
@@ -359,5 +359,5 @@
|
|
|
359
359
|
]
|
|
360
360
|
}
|
|
361
361
|
},
|
|
362
|
-
"version": "0.7.0-beta.
|
|
362
|
+
"version": "0.7.0-beta.5"
|
|
363
363
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "directus-template-cli",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.5",
|
|
4
4
|
"description": "CLI Utility for applying templates to a Directus instance.",
|
|
5
5
|
"author": "bryantgillespie @bryantgillespie",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
|
-
"directus-template-cli": "./bin/run"
|
|
8
|
+
"directus-template-cli": "./bin/run.js"
|
|
8
9
|
},
|
|
9
10
|
"homepage": "https://github.com/directus-community/directus-template-cli",
|
|
10
11
|
"license": "MIT",
|
|
@@ -18,42 +19,45 @@
|
|
|
18
19
|
],
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@clack/prompts": "^0.10.0",
|
|
21
|
-
"@directus/sdk": "^
|
|
22
|
-
"@
|
|
23
|
-
"@oclif/
|
|
24
|
-
"@oclif/plugin-
|
|
22
|
+
"@directus/sdk": "^19.0.1",
|
|
23
|
+
"@inquirer/prompts": "^7.3.3",
|
|
24
|
+
"@oclif/core": "^4.2.9",
|
|
25
|
+
"@oclif/plugin-help": "^6.2.26",
|
|
26
|
+
"@oclif/plugin-plugins": "^5.4.34",
|
|
25
27
|
"@octokit/rest": "^21.1.1",
|
|
28
|
+
"@sindresorhus/slugify": "^2.2.1",
|
|
26
29
|
"bottleneck": "^2.19.5",
|
|
27
|
-
"chalk": "4.1
|
|
30
|
+
"chalk": "5.4.1",
|
|
31
|
+
"cli-progress": "^3.12.0",
|
|
28
32
|
"defu": "^6.1.4",
|
|
29
|
-
"dotenv": "^16.4.
|
|
30
|
-
"execa": "
|
|
33
|
+
"dotenv": "^16.4.7",
|
|
34
|
+
"execa": "9.5.2",
|
|
31
35
|
"formdata-node": "^6.0.3",
|
|
32
|
-
"giget": "^
|
|
36
|
+
"giget": "^2.0.0",
|
|
33
37
|
"glob": "^11.0.1",
|
|
34
|
-
"inquirer": "^8.2.5",
|
|
35
38
|
"log-update": "^6.1.0",
|
|
36
|
-
"nypm": "^0.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"slugify": "^1.6.6"
|
|
39
|
+
"nypm": "^0.6.0",
|
|
40
|
+
"pathe": "^2.0.3",
|
|
41
|
+
"posthog-node": "^4.10.1"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"eslint
|
|
50
|
-
"eslint-config-oclif
|
|
51
|
-
"
|
|
52
|
-
"
|
|
44
|
+
"@oclif/prettier-config": "^0.2.1",
|
|
45
|
+
"@directus/types": "^13.0.0",
|
|
46
|
+
"@oclif/test": "^4",
|
|
47
|
+
"@types/chai": "^5.2.0",
|
|
48
|
+
"@types/mocha": "^10",
|
|
49
|
+
"@types/node": "^18",
|
|
50
|
+
"chai": "^5.2.0",
|
|
51
|
+
"eslint": "^9",
|
|
52
|
+
"eslint-config-oclif": "^5",
|
|
53
|
+
"eslint-config-oclif-typescript": "^3",
|
|
54
|
+
"eslint-config-prettier": "^9",
|
|
55
|
+
"mocha": "^10",
|
|
56
|
+
"oclif": "^4",
|
|
53
57
|
"shx": "^0.3.3",
|
|
54
|
-
"ts-node": "^10
|
|
55
|
-
"tslib": "^2.
|
|
56
|
-
"typescript": "^5.
|
|
58
|
+
"ts-node": "^10",
|
|
59
|
+
"tslib": "^2.8.1",
|
|
60
|
+
"typescript": "^5.8.2"
|
|
57
61
|
},
|
|
58
62
|
"oclif": {
|
|
59
63
|
"bin": "directus-template-cli",
|
|
@@ -70,11 +74,11 @@
|
|
|
70
74
|
"build": "shx rm -rf dist && tsc -b",
|
|
71
75
|
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
72
76
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
73
|
-
"posttest": "
|
|
74
|
-
"prepack": "
|
|
77
|
+
"posttest": "pnpm run lint",
|
|
78
|
+
"prepack": "pnpm run build && oclif manifest && oclif readme",
|
|
75
79
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
76
80
|
"version": "oclif readme && git add README.md",
|
|
77
|
-
"run": "./bin/run"
|
|
81
|
+
"run": "./bin/run.js"
|
|
78
82
|
},
|
|
79
83
|
"engines": {
|
|
80
84
|
"node": ">=18.0.0"
|