@strapi/strapi 5.12.0 → 5.12.2
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/dist/cli.js +89 -45
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +90 -42
- package/dist/cli.mjs.map +1 -1
- package/dist/package.json.js +6 -0
- package/dist/package.json.js.map +1 -0
- package/dist/package.json.mjs +4 -0
- package/dist/package.json.mjs.map +1 -0
- package/dist/src/cli/commands/admin/create-user.js +124 -0
- package/dist/src/cli/commands/admin/create-user.js.map +1 -0
- package/dist/src/cli/commands/admin/create-user.mjs +121 -0
- package/dist/src/cli/commands/admin/create-user.mjs.map +1 -0
- package/dist/src/cli/commands/admin/reset-user-password.js +61 -0
- package/dist/src/cli/commands/admin/reset-user-password.js.map +1 -0
- package/dist/src/cli/commands/admin/reset-user-password.mjs +58 -0
- package/dist/src/cli/commands/admin/reset-user-password.mjs.map +1 -0
- package/dist/src/cli/commands/build.js +29 -0
- package/dist/src/cli/commands/build.js.map +1 -0
- package/dist/src/cli/commands/build.mjs +27 -0
- package/dist/src/cli/commands/build.mjs.map +1 -0
- package/dist/src/cli/commands/components/list.js +32 -0
- package/dist/src/cli/commands/components/list.js.map +1 -0
- package/dist/src/cli/commands/components/list.mjs +29 -0
- package/dist/src/cli/commands/components/list.mjs.map +1 -0
- package/dist/src/cli/commands/configuration/dump.js +53 -0
- package/dist/src/cli/commands/configuration/dump.js.map +1 -0
- package/dist/src/cli/commands/configuration/dump.mjs +50 -0
- package/dist/src/cli/commands/configuration/dump.mjs.map +1 -0
- package/dist/src/cli/commands/configuration/restore.js +173 -0
- package/dist/src/cli/commands/configuration/restore.js.map +1 -0
- package/dist/src/cli/commands/configuration/restore.mjs +170 -0
- package/dist/src/cli/commands/configuration/restore.mjs.map +1 -0
- package/dist/src/cli/commands/console.js +31 -0
- package/dist/src/cli/commands/console.js.map +1 -0
- package/dist/src/cli/commands/console.mjs +28 -0
- package/dist/src/cli/commands/console.mjs.map +1 -0
- package/dist/src/cli/commands/content-types/list.js +32 -0
- package/dist/src/cli/commands/content-types/list.js.map +1 -0
- package/dist/src/cli/commands/content-types/list.mjs +29 -0
- package/dist/src/cli/commands/content-types/list.mjs.map +1 -0
- package/dist/src/cli/commands/controllers/list.js +32 -0
- package/dist/src/cli/commands/controllers/list.js.map +1 -0
- package/dist/src/cli/commands/controllers/list.mjs +29 -0
- package/dist/src/cli/commands/controllers/list.mjs.map +1 -0
- package/dist/src/cli/commands/develop.js +32 -0
- package/dist/src/cli/commands/develop.js.map +1 -0
- package/dist/src/cli/commands/develop.mjs +30 -0
- package/dist/src/cli/commands/develop.mjs.map +1 -0
- package/dist/src/cli/commands/export/action.js +126 -0
- package/dist/src/cli/commands/export/action.js.map +1 -0
- package/dist/src/cli/commands/export/action.mjs +124 -0
- package/dist/src/cli/commands/export/action.mjs.map +1 -0
- package/dist/src/cli/commands/export/command.js +15 -0
- package/dist/src/cli/commands/export/command.js.map +1 -0
- package/dist/src/cli/commands/export/command.mjs +13 -0
- package/dist/src/cli/commands/export/command.mjs.map +1 -0
- package/dist/src/cli/commands/generate.js +18 -0
- package/dist/src/cli/commands/generate.js.map +1 -0
- package/dist/src/cli/commands/generate.mjs +16 -0
- package/dist/src/cli/commands/generate.mjs.map +1 -0
- package/dist/src/cli/commands/hooks/list.js +32 -0
- package/dist/src/cli/commands/hooks/list.js.map +1 -0
- package/dist/src/cli/commands/hooks/list.mjs +29 -0
- package/dist/src/cli/commands/hooks/list.mjs.map +1 -0
- package/dist/src/cli/commands/import/action.js +124 -0
- package/dist/src/cli/commands/import/action.js.map +1 -0
- package/dist/src/cli/commands/import/action.mjs +122 -0
- package/dist/src/cli/commands/import/action.mjs.map +1 -0
- package/dist/src/cli/commands/import/command.js +59 -0
- package/dist/src/cli/commands/import/command.js.map +1 -0
- package/dist/src/cli/commands/import/command.mjs +57 -0
- package/dist/src/cli/commands/import/command.mjs.map +1 -0
- package/dist/src/cli/commands/index.js +64 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/index.mjs +62 -0
- package/dist/src/cli/commands/index.mjs.map +1 -0
- package/dist/src/cli/commands/middlewares/list.js +32 -0
- package/dist/src/cli/commands/middlewares/list.js.map +1 -0
- package/dist/src/cli/commands/middlewares/list.mjs +29 -0
- package/dist/src/cli/commands/middlewares/list.mjs.map +1 -0
- package/dist/src/cli/commands/policies/list.js +32 -0
- package/dist/src/cli/commands/policies/list.js.map +1 -0
- package/dist/src/cli/commands/policies/list.mjs +29 -0
- package/dist/src/cli/commands/policies/list.mjs.map +1 -0
- package/dist/src/cli/commands/report.js +39 -0
- package/dist/src/cli/commands/report.js.map +1 -0
- package/dist/src/cli/commands/report.mjs +37 -0
- package/dist/src/cli/commands/report.mjs.map +1 -0
- package/dist/src/cli/commands/routes/list.js +40 -0
- package/dist/src/cli/commands/routes/list.js.map +1 -0
- package/dist/src/cli/commands/routes/list.mjs +37 -0
- package/dist/src/cli/commands/routes/list.mjs.map +1 -0
- package/dist/src/cli/commands/services/list.js +32 -0
- package/dist/src/cli/commands/services/list.js.map +1 -0
- package/dist/src/cli/commands/services/list.mjs +29 -0
- package/dist/src/cli/commands/services/list.mjs.map +1 -0
- package/dist/src/cli/commands/start.js +28 -0
- package/dist/src/cli/commands/start.js.map +1 -0
- package/dist/src/cli/commands/start.mjs +26 -0
- package/dist/src/cli/commands/start.mjs.map +1 -0
- package/dist/src/cli/commands/telemetry/disable.js +72 -0
- package/dist/src/cli/commands/telemetry/disable.js.map +1 -0
- package/dist/src/cli/commands/telemetry/disable.mjs +69 -0
- package/dist/src/cli/commands/telemetry/disable.mjs.map +1 -0
- package/dist/src/cli/commands/telemetry/enable.js +88 -0
- package/dist/src/cli/commands/telemetry/enable.js.map +1 -0
- package/dist/src/cli/commands/telemetry/enable.mjs +85 -0
- package/dist/src/cli/commands/telemetry/enable.mjs.map +1 -0
- package/dist/src/cli/commands/templates/generate.js +15 -0
- package/dist/src/cli/commands/templates/generate.js.map +1 -0
- package/dist/src/cli/commands/templates/generate.mjs +13 -0
- package/dist/src/cli/commands/templates/generate.mjs.map +1 -0
- package/dist/src/cli/commands/transfer/action.js +141 -0
- package/dist/src/cli/commands/transfer/action.js.map +1 -0
- package/dist/src/cli/commands/transfer/action.mjs +139 -0
- package/dist/src/cli/commands/transfer/action.mjs.map +1 -0
- package/dist/src/cli/commands/transfer/command.js +61 -0
- package/dist/src/cli/commands/transfer/command.js.map +1 -0
- package/dist/src/cli/commands/transfer/command.mjs +59 -0
- package/dist/src/cli/commands/transfer/command.mjs.map +1 -0
- package/dist/src/cli/commands/ts/generate-types.js +40 -0
- package/dist/src/cli/commands/ts/generate-types.js.map +1 -0
- package/dist/src/cli/commands/ts/generate-types.mjs +37 -0
- package/dist/src/cli/commands/ts/generate-types.mjs.map +1 -0
- package/dist/src/cli/commands/version.js +17 -0
- package/dist/src/cli/commands/version.js.map +1 -0
- package/dist/src/cli/commands/version.mjs +15 -0
- package/dist/src/cli/commands/version.mjs.map +1 -0
- package/dist/src/cli/utils/commander.js +125 -0
- package/dist/src/cli/utils/commander.js.map +1 -0
- package/dist/src/cli/utils/commander.mjs +116 -0
- package/dist/src/cli/utils/commander.mjs.map +1 -0
- package/dist/src/cli/utils/data-transfer.js +378 -0
- package/dist/src/cli/utils/data-transfer.js.map +1 -0
- package/dist/src/cli/utils/data-transfer.mjs +359 -0
- package/dist/src/cli/utils/data-transfer.mjs.map +1 -0
- package/dist/src/cli/utils/helpers.js +114 -0
- package/dist/src/cli/utils/helpers.js.map +1 -0
- package/dist/src/cli/utils/helpers.mjs +107 -0
- package/dist/src/cli/utils/helpers.mjs.map +1 -0
- package/dist/src/cli/utils/logger.js +125 -0
- package/dist/src/cli/utils/logger.js.map +1 -0
- package/dist/src/cli/utils/logger.mjs +104 -0
- package/dist/src/cli/utils/logger.mjs.map +1 -0
- package/dist/src/cli/utils/telemetry.js +27 -0
- package/dist/src/cli/utils/telemetry.js.map +1 -0
- package/dist/src/cli/utils/telemetry.mjs +25 -0
- package/dist/src/cli/utils/telemetry.mjs.map +1 -0
- package/dist/src/cli/utils/tsconfig.js +25 -0
- package/dist/src/cli/utils/tsconfig.js.map +1 -0
- package/dist/src/cli/utils/tsconfig.mjs +23 -0
- package/dist/src/cli/utils/tsconfig.mjs.map +1 -0
- package/dist/src/node/build.js +90 -0
- package/dist/src/node/build.js.map +1 -0
- package/dist/src/node/build.mjs +69 -0
- package/dist/src/node/build.mjs.map +1 -0
- package/dist/src/node/core/admin-customisations.js +27 -0
- package/dist/src/node/core/admin-customisations.js.map +1 -0
- package/dist/src/node/core/admin-customisations.mjs +25 -0
- package/dist/src/node/core/admin-customisations.mjs.map +1 -0
- package/dist/{chunks/aliases-B2TXon3T.js → src/node/core/aliases.js} +3 -42
- package/dist/src/node/core/aliases.js.map +1 -0
- package/dist/{chunks/aliases-BsT_zzr4.mjs → src/node/core/aliases.mjs} +4 -41
- package/dist/src/node/core/aliases.mjs.map +1 -0
- package/dist/src/node/core/config.js +18 -0
- package/dist/src/node/core/config.js.map +1 -0
- package/dist/src/node/core/config.mjs +16 -0
- package/dist/src/node/core/config.mjs.map +1 -0
- package/dist/src/node/core/dependencies.js +186 -0
- package/dist/src/node/core/dependencies.js.map +1 -0
- package/dist/src/node/core/dependencies.mjs +183 -0
- package/dist/src/node/core/dependencies.mjs.map +1 -0
- package/dist/src/node/core/env.js +32 -0
- package/dist/src/node/core/env.js.map +1 -0
- package/dist/src/node/core/env.mjs +29 -0
- package/dist/src/node/core/env.mjs.map +1 -0
- package/dist/src/node/core/errors.js +51 -0
- package/dist/src/node/core/errors.js.map +1 -0
- package/dist/src/node/core/errors.mjs +48 -0
- package/dist/src/node/core/errors.mjs.map +1 -0
- package/dist/src/node/core/files.js +68 -0
- package/dist/src/node/core/files.js.map +1 -0
- package/dist/src/node/core/files.mjs +63 -0
- package/dist/src/node/core/files.mjs.map +1 -0
- package/dist/src/node/core/managers.js +27 -0
- package/dist/src/node/core/managers.js.map +1 -0
- package/dist/src/node/core/managers.mjs +25 -0
- package/dist/src/node/core/managers.mjs.map +1 -0
- package/dist/src/node/core/monorepo.js +30 -0
- package/dist/src/node/core/monorepo.js.map +1 -0
- package/dist/src/node/core/monorepo.mjs +28 -0
- package/dist/src/node/core/monorepo.mjs.map +1 -0
- package/dist/src/node/core/plugins.js +140 -0
- package/dist/src/node/core/plugins.js.map +1 -0
- package/dist/src/node/core/plugins.mjs +137 -0
- package/dist/src/node/core/plugins.mjs.map +1 -0
- package/dist/src/node/core/timer.js +33 -0
- package/dist/src/node/core/timer.js.map +1 -0
- package/dist/src/node/core/timer.mjs +30 -0
- package/dist/src/node/core/timer.mjs.map +1 -0
- package/dist/src/node/create-build-context.js +111 -0
- package/dist/src/node/create-build-context.js.map +1 -0
- package/dist/src/node/create-build-context.mjs +109 -0
- package/dist/src/node/create-build-context.mjs.map +1 -0
- package/dist/src/node/develop.js +312 -0
- package/dist/src/node/develop.js.map +1 -0
- package/dist/src/node/develop.mjs +291 -0
- package/dist/src/node/develop.mjs.map +1 -0
- package/dist/src/node/staticFiles.js +81 -0
- package/dist/src/node/staticFiles.js.map +1 -0
- package/dist/src/node/staticFiles.mjs +78 -0
- package/dist/src/node/staticFiles.mjs.map +1 -0
- package/dist/src/node/vite/build.js +14 -0
- package/dist/src/node/vite/build.js.map +1 -0
- package/dist/src/node/vite/build.mjs +12 -0
- package/dist/src/node/vite/build.mjs.map +1 -0
- package/dist/{chunks/config-CsJ2EtSs.js → src/node/vite/config.js} +12 -50
- package/dist/src/node/vite/config.js.map +1 -0
- package/dist/{chunks/config-BqQdQJh_.mjs → src/node/vite/config.mjs} +6 -44
- package/dist/src/node/vite/config.mjs.map +1 -0
- package/dist/src/node/vite/plugins.js +46 -0
- package/dist/src/node/vite/plugins.js.map +1 -0
- package/dist/src/node/vite/plugins.mjs +44 -0
- package/dist/src/node/vite/plugins.mjs.map +1 -0
- package/dist/{chunks/watch-DzwyHBm4.js → src/node/vite/watch.js} +2 -45
- package/dist/src/node/vite/watch.js.map +1 -0
- package/dist/{chunks/watch-BDsNoG4h.mjs → src/node/vite/watch.mjs} +2 -45
- package/dist/src/node/vite/watch.mjs.map +1 -0
- package/dist/src/node/webpack/build.js +37 -0
- package/dist/src/node/webpack/build.js.map +1 -0
- package/dist/src/node/webpack/build.mjs +35 -0
- package/dist/src/node/webpack/build.mjs.map +1 -0
- package/dist/{chunks/config-B2BETQ-W.js → src/node/webpack/config.js} +10 -8
- package/dist/src/node/webpack/config.js.map +1 -0
- package/dist/{chunks/config-DHibCzCW.mjs → src/node/webpack/config.mjs} +5 -3
- package/dist/src/node/webpack/config.mjs.map +1 -0
- package/dist/{chunks/watch-BKW3b7Rj.js → src/node/webpack/watch.js} +2 -51
- package/dist/src/node/webpack/watch.js.map +1 -0
- package/dist/{chunks/watch-DQJ0HV0l.mjs → src/node/webpack/watch.mjs} +2 -51
- package/dist/src/node/webpack/watch.mjs.map +1 -0
- package/package.json +22 -22
- package/dist/chunks/aliases-B2TXon3T.js.map +0 -1
- package/dist/chunks/aliases-BsT_zzr4.mjs.map +0 -1
- package/dist/chunks/build-BQMdiYL1.mjs +0 -57
- package/dist/chunks/build-BQMdiYL1.mjs.map +0 -1
- package/dist/chunks/build-FJLfahVt.mjs +0 -85
- package/dist/chunks/build-FJLfahVt.mjs.map +0 -1
- package/dist/chunks/build-RZ8_oqFy.js +0 -59
- package/dist/chunks/build-RZ8_oqFy.js.map +0 -1
- package/dist/chunks/build-XY97xrwm.js +0 -87
- package/dist/chunks/build-XY97xrwm.js.map +0 -1
- package/dist/chunks/config-B2BETQ-W.js.map +0 -1
- package/dist/chunks/config-BqQdQJh_.mjs.map +0 -1
- package/dist/chunks/config-CsJ2EtSs.js.map +0 -1
- package/dist/chunks/config-DHibCzCW.mjs.map +0 -1
- package/dist/chunks/index-BJFfd72y.js +0 -3185
- package/dist/chunks/index-BJFfd72y.js.map +0 -1
- package/dist/chunks/index-DL_emYoN.mjs +0 -3160
- package/dist/chunks/index-DL_emYoN.mjs.map +0 -1
- package/dist/chunks/watch-BDsNoG4h.mjs.map +0 -1
- package/dist/chunks/watch-BKW3b7Rj.js.map +0 -1
- package/dist/chunks/watch-DQJ0HV0l.mjs.map +0 -1
- package/dist/chunks/watch-DzwyHBm4.js.map +0 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
5
|
+
import { runAction } from '../../utils/helpers.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Will restore configurations. It reads from a file or stdin
|
|
9
|
+
*/ const action = async ({ file: filePath, strategy = 'replace' })=>{
|
|
10
|
+
const input = filePath ? fs.readFileSync(filePath) : await readStdin();
|
|
11
|
+
const appContext = await compileStrapi();
|
|
12
|
+
const app = await createStrapi(appContext).load();
|
|
13
|
+
let dataToImport;
|
|
14
|
+
try {
|
|
15
|
+
dataToImport = JSON.parse(_.toString(input));
|
|
16
|
+
} catch (error) {
|
|
17
|
+
if (error instanceof Error) {
|
|
18
|
+
throw new Error(`Invalid input data: ${error.message}. Expected a valid JSON array.`);
|
|
19
|
+
}
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(dataToImport)) {
|
|
23
|
+
throw new Error(`Invalid input data. Expected a valid JSON array.`);
|
|
24
|
+
}
|
|
25
|
+
if (!app.db) {
|
|
26
|
+
throw new Error('Cannot import configuration without a database connection.');
|
|
27
|
+
}
|
|
28
|
+
const importer = createImporter(app.db, strategy);
|
|
29
|
+
for (const config of dataToImport){
|
|
30
|
+
await importer.import(config);
|
|
31
|
+
}
|
|
32
|
+
console.log(`Successfully imported configuration with ${strategy} strategy. Statistics: ${importer.printStatistics()}.`);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
};
|
|
35
|
+
const readStdin = ()=>{
|
|
36
|
+
const { stdin } = process;
|
|
37
|
+
let result = '';
|
|
38
|
+
if (stdin.isTTY) return Promise.resolve(result);
|
|
39
|
+
return new Promise((resolve, reject)=>{
|
|
40
|
+
stdin.setEncoding('utf8');
|
|
41
|
+
stdin.on('readable', ()=>{
|
|
42
|
+
let chunk;
|
|
43
|
+
// eslint-disable-next-line no-cond-assign
|
|
44
|
+
while(chunk = stdin.read()){
|
|
45
|
+
result += chunk;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
stdin.on('end', ()=>{
|
|
49
|
+
resolve(result);
|
|
50
|
+
});
|
|
51
|
+
stdin.on('error', reject);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const createImporter = (db, strategy)=>{
|
|
55
|
+
switch(strategy){
|
|
56
|
+
case 'replace':
|
|
57
|
+
return createReplaceImporter(db);
|
|
58
|
+
case 'merge':
|
|
59
|
+
return createMergeImporter(db);
|
|
60
|
+
case 'keep':
|
|
61
|
+
return createKeepImporter(db);
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`No importer available for strategy "${strategy}"`);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Replace importer. Will replace the keys that already exist and create the new ones
|
|
68
|
+
*/ const createReplaceImporter = (db)=>{
|
|
69
|
+
const stats = {
|
|
70
|
+
created: 0,
|
|
71
|
+
replaced: 0
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
printStatistics () {
|
|
75
|
+
return `${stats.created} created, ${stats.replaced} replaced`;
|
|
76
|
+
},
|
|
77
|
+
async import (conf) {
|
|
78
|
+
const matching = await db.query('strapi::core-store').count({
|
|
79
|
+
where: {
|
|
80
|
+
key: conf.key
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
if (matching > 0) {
|
|
84
|
+
stats.replaced += 1;
|
|
85
|
+
await db.query('strapi::core-store').update({
|
|
86
|
+
where: {
|
|
87
|
+
key: conf.key
|
|
88
|
+
},
|
|
89
|
+
data: conf
|
|
90
|
+
});
|
|
91
|
+
} else {
|
|
92
|
+
stats.created += 1;
|
|
93
|
+
await db.query('strapi::core-store').create({
|
|
94
|
+
data: conf
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Merge importer. Will merge the keys that already exist with their new value and create the new ones
|
|
102
|
+
*/ const createMergeImporter = (db)=>{
|
|
103
|
+
const stats = {
|
|
104
|
+
created: 0,
|
|
105
|
+
merged: 0
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
printStatistics () {
|
|
109
|
+
return `${stats.created} created, ${stats.merged} merged`;
|
|
110
|
+
},
|
|
111
|
+
async import (conf) {
|
|
112
|
+
const existingConf = await db.query('strapi::core-store').findOne({
|
|
113
|
+
where: {
|
|
114
|
+
key: conf.key
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (existingConf) {
|
|
118
|
+
stats.merged += 1;
|
|
119
|
+
await db.query('strapi::core-store').update({
|
|
120
|
+
where: {
|
|
121
|
+
key: conf.key
|
|
122
|
+
},
|
|
123
|
+
data: _.merge(existingConf, conf)
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
stats.created += 1;
|
|
127
|
+
await db.query('strapi::core-store').create({
|
|
128
|
+
data: conf
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Merge importer. Will keep the keys that already exist without changing them and create the new ones
|
|
136
|
+
*/ const createKeepImporter = (db)=>{
|
|
137
|
+
const stats = {
|
|
138
|
+
created: 0,
|
|
139
|
+
untouched: 0
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
printStatistics () {
|
|
143
|
+
return `${stats.created} created, ${stats.untouched} untouched`;
|
|
144
|
+
},
|
|
145
|
+
async import (conf) {
|
|
146
|
+
const matching = await db.query('strapi::core-store').count({
|
|
147
|
+
where: {
|
|
148
|
+
key: conf.key
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (matching > 0) {
|
|
152
|
+
stats.untouched += 1;
|
|
153
|
+
// if configuration already exists do not overwrite it
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
stats.created += 1;
|
|
157
|
+
await db.query('strapi::core-store').create({
|
|
158
|
+
data: conf
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* `$ strapi configuration:restore`
|
|
165
|
+
*/ const command = ()=>{
|
|
166
|
+
return createCommand('configuration:restore').alias('config:restore').description('Restore configurations of your application').option('-f, --file <file>', 'Input file, default input is stdin').option('-s, --strategy <strategy>', 'Strategy name, one of: "replace", "merge", "keep"').action(runAction('configuration:restore', action));
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
export { action, command };
|
|
170
|
+
//# sourceMappingURL=restore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restore.mjs","sources":["../../../../../src/cli/commands/configuration/restore.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport fs from 'fs';\nimport _ from 'lodash';\nimport { createStrapi, compileStrapi } from '@strapi/core';\nimport type { Database } from '@strapi/database';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ntype Strategy = 'replace' | 'merge' | 'keep';\n\ninterface CmdOptions {\n file?: string;\n strategy?: Strategy;\n}\n\n/**\n * Will restore configurations. It reads from a file or stdin\n */\nconst action = async ({ file: filePath, strategy = 'replace' }: CmdOptions) => {\n const input = filePath ? fs.readFileSync(filePath) : await readStdin();\n\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n let dataToImport;\n try {\n dataToImport = JSON.parse(_.toString(input));\n } catch (error) {\n if (error instanceof Error) {\n throw new Error(`Invalid input data: ${error.message}. Expected a valid JSON array.`);\n }\n\n throw error;\n }\n\n if (!Array.isArray(dataToImport)) {\n throw new Error(`Invalid input data. Expected a valid JSON array.`);\n }\n\n if (!app.db) {\n throw new Error('Cannot import configuration without a database connection.');\n }\n\n const importer = createImporter(app.db, strategy);\n\n for (const config of dataToImport) {\n await importer.import(config);\n }\n\n console.log(\n `Successfully imported configuration with ${strategy} strategy. Statistics: ${importer.printStatistics()}.`\n );\n\n process.exit(0);\n};\n\nconst readStdin = () => {\n const { stdin } = process;\n let result = '';\n\n if (stdin.isTTY) return Promise.resolve(result);\n\n return new Promise((resolve, reject) => {\n stdin.setEncoding('utf8');\n stdin.on('readable', () => {\n let chunk;\n // eslint-disable-next-line no-cond-assign\n while ((chunk = stdin.read())) {\n result += chunk;\n }\n });\n\n stdin.on('end', () => {\n resolve(result);\n });\n\n stdin.on('error', reject);\n });\n};\n\nconst createImporter = (db: Database, strategy?: Strategy) => {\n switch (strategy) {\n case 'replace':\n return createReplaceImporter(db);\n case 'merge':\n return createMergeImporter(db);\n case 'keep':\n return createKeepImporter(db);\n default:\n throw new Error(`No importer available for strategy \"${strategy}\"`);\n }\n};\n\n/**\n * Replace importer. Will replace the keys that already exist and create the new ones\n */\nconst createReplaceImporter = (db: Database) => {\n const stats = {\n created: 0,\n replaced: 0,\n };\n\n return {\n printStatistics() {\n return `${stats.created} created, ${stats.replaced} replaced`;\n },\n\n async import(conf: Record<string, unknown>) {\n const matching = await db.query('strapi::core-store').count({ where: { key: conf.key } });\n if (matching > 0) {\n stats.replaced += 1;\n await db.query('strapi::core-store').update({\n where: { key: conf.key },\n data: conf,\n });\n } else {\n stats.created += 1;\n await db.query('strapi::core-store').create({ data: conf });\n }\n },\n };\n};\n\n/**\n * Merge importer. Will merge the keys that already exist with their new value and create the new ones\n */\nconst createMergeImporter = (db: Database) => {\n const stats = {\n created: 0,\n merged: 0,\n };\n\n return {\n printStatistics() {\n return `${stats.created} created, ${stats.merged} merged`;\n },\n\n async import(conf: Record<string, unknown>) {\n const existingConf = await db\n .query('strapi::core-store')\n .findOne({ where: { key: conf.key } });\n\n if (existingConf) {\n stats.merged += 1;\n await db.query('strapi::core-store').update({\n where: { key: conf.key },\n data: _.merge(existingConf, conf),\n });\n } else {\n stats.created += 1;\n await db.query('strapi::core-store').create({ data: conf });\n }\n },\n };\n};\n\n/**\n * Merge importer. Will keep the keys that already exist without changing them and create the new ones\n */\nconst createKeepImporter = (db: Database) => {\n const stats = {\n created: 0,\n untouched: 0,\n };\n\n return {\n printStatistics() {\n return `${stats.created} created, ${stats.untouched} untouched`;\n },\n\n async import(conf: Record<string, unknown>) {\n const matching = await db.query('strapi::core-store').count({ where: { key: conf.key } });\n if (matching > 0) {\n stats.untouched += 1;\n // if configuration already exists do not overwrite it\n return;\n }\n\n stats.created += 1;\n await db.query('strapi::core-store').create({ data: conf });\n },\n };\n};\n\n/**\n * `$ strapi configuration:restore`\n */\nconst command: StrapiCommand = () => {\n return createCommand('configuration:restore')\n .alias('config:restore')\n .description('Restore configurations of your application')\n .option('-f, --file <file>', 'Input file, default input is stdin')\n .option('-s, --strategy <strategy>', 'Strategy name, one of: \"replace\", \"merge\", \"keep\"')\n .action(runAction('configuration:restore', action));\n};\n\nexport { action, command };\n"],"names":["action","file","filePath","strategy","input","fs","readFileSync","readStdin","appContext","compileStrapi","app","createStrapi","load","dataToImport","JSON","parse","_","toString","error","Error","message","Array","isArray","db","importer","createImporter","config","import","console","log","printStatistics","process","exit","stdin","result","isTTY","Promise","resolve","reject","setEncoding","on","chunk","read","createReplaceImporter","createMergeImporter","createKeepImporter","stats","created","replaced","conf","matching","query","count","where","key","update","data","create","merged","existingConf","findOne","merge","untouched","command","createCommand","alias","description","option","runAction"],"mappings":";;;;;;AAgBA;;IAGA,MAAMA,SAAS,OAAO,EAAEC,MAAMC,QAAQ,EAAEC,QAAW,GAAA,SAAS,EAAc,GAAA;AACxE,IAAA,MAAMC,QAAQF,QAAWG,GAAAA,EAAAA,CAAGC,YAAY,CAACJ,YAAY,MAAMK,SAAAA,EAAAA;AAE3D,IAAA,MAAMC,aAAa,MAAMC,aAAAA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MC,OAAO,IAAI,CAAA;AACjB,YAAA,MAAMxB,EAAG4B,CAAAA,KAAK,CAAC,oBAAA,CAAA,CAAsBM,MAAM,CAAC;gBAAED,IAAMP,EAAAA;AAAK,aAAA,CAAA;AAC3D;AACF,KAAA;AACF,CAAA;AAEA;;AAEC,UACKc,OAAyB,GAAA,IAAA;AAC7B,IAAA,OAAOC,cAAc,uBAClBC,CAAAA,CAAAA,KAAK,CAAC,gBACNC,CAAAA,CAAAA,WAAW,CAAC,4CACZC,CAAAA,CAAAA,MAAM,CAAC,mBAAqB,EAAA,oCAAA,CAAA,CAC5BA,MAAM,CAAC,2BAAA,EAA6B,qDACpCnE,MAAM,CAACoE,UAAU,uBAAyBpE,EAAAA,MAAAA,CAAAA,CAAAA;AAC/C;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var REPL = require('repl');
|
|
4
|
+
var commander = require('commander');
|
|
5
|
+
var core = require('@strapi/core');
|
|
6
|
+
var helpers = require('../utils/helpers.js');
|
|
7
|
+
|
|
8
|
+
const action = async ()=>{
|
|
9
|
+
const appContext = await core.compileStrapi();
|
|
10
|
+
const app = await core.createStrapi(appContext).load();
|
|
11
|
+
app.start().then(()=>{
|
|
12
|
+
const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template
|
|
13
|
+
repl.on('exit', (err)=>{
|
|
14
|
+
if (err) {
|
|
15
|
+
app.log.error(err);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
app.server.destroy();
|
|
19
|
+
process.exit(0);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* `$ strapi console`
|
|
25
|
+
*/ const command = ()=>{
|
|
26
|
+
return commander.createCommand('console').description('Open the Strapi framework console').action(helpers.runAction('console', action));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.action = action;
|
|
30
|
+
exports.command = command;
|
|
31
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sources":["../../../../src/cli/commands/console.ts"],"sourcesContent":["import REPL from 'repl';\nimport { createCommand } from 'commander';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n app.start().then(() => {\n const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template\n\n repl.on('exit', (err: Error) => {\n if (err) {\n app.log.error(err);\n process.exit(1);\n }\n\n app.server.destroy();\n process.exit(0);\n });\n });\n};\n\n/**\n * `$ strapi console`\n */\nconst command: StrapiCommand = () => {\n return createCommand('console')\n .description('Open the Strapi framework console')\n .action(runAction('console', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","load","start","then","repl","REPL","config","info","name","on","err","log","error","process","exit","server","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;;AAOA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,kBAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,iBAAaH,CAAAA,UAAAA,CAAAA,CAAYI,IAAI,EAAA;IAE/CF,GAAIG,CAAAA,KAAK,EAAGC,CAAAA,IAAI,CAAC,IAAA;AACf,QAAA,MAAMC,IAAOC,GAAAA,IAAAA,CAAKH,KAAK,CAACH,GAAIO,CAAAA,MAAM,CAACC,IAAI,CAACC,IAAI,GAAG,KAAA,IAAS;QAExDJ,IAAKK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,GAAAA,GAAAA;AACf,YAAA,IAAIA,GAAK,EAAA;gBACPX,GAAIY,CAAAA,GAAG,CAACC,KAAK,CAACF,GAAAA,CAAAA;AACdG,gBAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;YAEAf,GAAIgB,CAAAA,MAAM,CAACC,OAAO,EAAA;AAClBH,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,SAAA,CAAA;AACF,KAAA,CAAA;AACF;AAEA;;AAEC,UACKG,OAAyB,GAAA,IAAA;IAC7B,OAAOC,uBAAAA,CAAc,WAClBC,WAAW,CAAC,qCACZvB,MAAM,CAACwB,kBAAU,SAAWxB,EAAAA,MAAAA,CAAAA,CAAAA;AACjC;;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import REPL from 'repl';
|
|
2
|
+
import { createCommand } from 'commander';
|
|
3
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
4
|
+
import { runAction } from '../utils/helpers.mjs';
|
|
5
|
+
|
|
6
|
+
const action = async ()=>{
|
|
7
|
+
const appContext = await compileStrapi();
|
|
8
|
+
const app = await createStrapi(appContext).load();
|
|
9
|
+
app.start().then(()=>{
|
|
10
|
+
const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template
|
|
11
|
+
repl.on('exit', (err)=>{
|
|
12
|
+
if (err) {
|
|
13
|
+
app.log.error(err);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
app.server.destroy();
|
|
17
|
+
process.exit(0);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `$ strapi console`
|
|
23
|
+
*/ const command = ()=>{
|
|
24
|
+
return createCommand('console').description('Open the Strapi framework console').action(runAction('console', action));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { action, command };
|
|
28
|
+
//# sourceMappingURL=console.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.mjs","sources":["../../../../src/cli/commands/console.ts"],"sourcesContent":["import REPL from 'repl';\nimport { createCommand } from 'commander';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../types';\nimport { runAction } from '../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n app.start().then(() => {\n const repl = REPL.start(app.config.info.name + ' > ' || 'strapi > '); // eslint-disable-line prefer-template\n\n repl.on('exit', (err: Error) => {\n if (err) {\n app.log.error(err);\n process.exit(1);\n }\n\n app.server.destroy();\n process.exit(0);\n });\n });\n};\n\n/**\n * `$ strapi console`\n */\nconst command: StrapiCommand = () => {\n return createCommand('console')\n .description('Open the Strapi framework console')\n .action(runAction('console', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","load","start","then","repl","REPL","config","info","name","on","err","log","error","process","exit","server","destroy","command","createCommand","description","runAction"],"mappings":";;;;;AAOA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,YAAaH,CAAAA,UAAAA,CAAAA,CAAYI,IAAI,EAAA;IAE/CF,GAAIG,CAAAA,KAAK,EAAGC,CAAAA,IAAI,CAAC,IAAA;AACf,QAAA,MAAMC,IAAOC,GAAAA,IAAAA,CAAKH,KAAK,CAACH,GAAIO,CAAAA,MAAM,CAACC,IAAI,CAACC,IAAI,GAAG,KAAA,IAAS;QAExDJ,IAAKK,CAAAA,EAAE,CAAC,MAAA,EAAQ,CAACC,GAAAA,GAAAA;AACf,YAAA,IAAIA,GAAK,EAAA;gBACPX,GAAIY,CAAAA,GAAG,CAACC,KAAK,CAACF,GAAAA,CAAAA;AACdG,gBAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf;YAEAf,GAAIgB,CAAAA,MAAM,CAACC,OAAO,EAAA;AAClBH,YAAAA,OAAAA,CAAQC,IAAI,CAAC,CAAA,CAAA;AACf,SAAA,CAAA;AACF,KAAA,CAAA;AACF;AAEA;;AAEC,UACKG,OAAyB,GAAA,IAAA;IAC7B,OAAOC,aAAAA,CAAc,WAClBC,WAAW,CAAC,qCACZvB,MAAM,CAACwB,UAAU,SAAWxB,EAAAA,MAAAA,CAAAA,CAAAA;AACjC;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var CLITable = require('cli-table3');
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var core = require('@strapi/core');
|
|
7
|
+
var helpers = require('../../utils/helpers.js');
|
|
8
|
+
|
|
9
|
+
const action = async ()=>{
|
|
10
|
+
const appContext = await core.compileStrapi();
|
|
11
|
+
const app = await core.createStrapi(appContext).register();
|
|
12
|
+
const list = app.get('content-types').keys();
|
|
13
|
+
const infoTable = new CLITable({
|
|
14
|
+
head: [
|
|
15
|
+
chalk.blue('Name')
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
list.forEach((name)=>infoTable.push([
|
|
19
|
+
name
|
|
20
|
+
]));
|
|
21
|
+
console.log(infoTable.toString());
|
|
22
|
+
await app.destroy();
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `$ strapi content-types:list`
|
|
26
|
+
*/ const command = ()=>{
|
|
27
|
+
return commander.createCommand('content-types:list').description('List all the application content-types').action(helpers.runAction('content-types:list', action));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.action = action;
|
|
31
|
+
exports.command = command;
|
|
32
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../src/cli/commands/content-types/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('content-types').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi content-types:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('content-types:list')\n .description('List all the application content-types')\n .action(runAction('content-types:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;;;AASA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,kBAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,iBAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,iBAAiBC,IAAI,EAAA;IAE1C,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,uBAAAA,CAAc,sBAClBC,WAAW,CAAC,0CACZvB,MAAM,CAACwB,kBAAU,oBAAsBxB,EAAAA,MAAAA,CAAAA,CAAAA;AAC5C;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import CLITable from 'cli-table3';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
5
|
+
import { runAction } from '../../utils/helpers.mjs';
|
|
6
|
+
|
|
7
|
+
const action = async ()=>{
|
|
8
|
+
const appContext = await compileStrapi();
|
|
9
|
+
const app = await createStrapi(appContext).register();
|
|
10
|
+
const list = app.get('content-types').keys();
|
|
11
|
+
const infoTable = new CLITable({
|
|
12
|
+
head: [
|
|
13
|
+
chalk.blue('Name')
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
list.forEach((name)=>infoTable.push([
|
|
17
|
+
name
|
|
18
|
+
]));
|
|
19
|
+
console.log(infoTable.toString());
|
|
20
|
+
await app.destroy();
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `$ strapi content-types:list`
|
|
24
|
+
*/ const command = ()=>{
|
|
25
|
+
return createCommand('content-types:list').description('List all the application content-types').action(runAction('content-types:list', action));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { action, command };
|
|
29
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../../../src/cli/commands/content-types/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('content-types').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi content-types:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('content-types:list')\n .description('List all the application content-types')\n .action(runAction('content-types:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;AASA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,YAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,iBAAiBC,IAAI,EAAA;IAE1C,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,aAAAA,CAAc,sBAClBC,WAAW,CAAC,0CACZvB,MAAM,CAACwB,UAAU,oBAAsBxB,EAAAA,MAAAA,CAAAA,CAAAA;AAC5C;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var CLITable = require('cli-table3');
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var core = require('@strapi/core');
|
|
7
|
+
var helpers = require('../../utils/helpers.js');
|
|
8
|
+
|
|
9
|
+
const action = async ()=>{
|
|
10
|
+
const appContext = await core.compileStrapi();
|
|
11
|
+
const app = await core.createStrapi(appContext).register();
|
|
12
|
+
const list = app.get('controllers').keys();
|
|
13
|
+
const infoTable = new CLITable({
|
|
14
|
+
head: [
|
|
15
|
+
chalk.blue('Name')
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
list.forEach((name)=>infoTable.push([
|
|
19
|
+
name
|
|
20
|
+
]));
|
|
21
|
+
console.log(infoTable.toString());
|
|
22
|
+
await app.destroy();
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `$ strapi controllers:list`
|
|
26
|
+
*/ const command = ()=>{
|
|
27
|
+
return commander.createCommand('controllers:list').description('List all the application controllers').action(helpers.runAction('controllers:list', action));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.action = action;
|
|
31
|
+
exports.command = command;
|
|
32
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sources":["../../../../../src/cli/commands/controllers/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('controllers').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi controllers:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('controllers:list')\n .description('List all the application controllers')\n .action(runAction('controllers:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;;;AASA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,kBAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,iBAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,eAAeC,IAAI,EAAA;IAExC,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,uBAAAA,CAAc,oBAClBC,WAAW,CAAC,wCACZvB,MAAM,CAACwB,kBAAU,kBAAoBxB,EAAAA,MAAAA,CAAAA,CAAAA;AAC1C;;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import CLITable from 'cli-table3';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
5
|
+
import { runAction } from '../../utils/helpers.mjs';
|
|
6
|
+
|
|
7
|
+
const action = async ()=>{
|
|
8
|
+
const appContext = await compileStrapi();
|
|
9
|
+
const app = await createStrapi(appContext).register();
|
|
10
|
+
const list = app.get('controllers').keys();
|
|
11
|
+
const infoTable = new CLITable({
|
|
12
|
+
head: [
|
|
13
|
+
chalk.blue('Name')
|
|
14
|
+
]
|
|
15
|
+
});
|
|
16
|
+
list.forEach((name)=>infoTable.push([
|
|
17
|
+
name
|
|
18
|
+
]));
|
|
19
|
+
console.log(infoTable.toString());
|
|
20
|
+
await app.destroy();
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `$ strapi controllers:list`
|
|
24
|
+
*/ const command = ()=>{
|
|
25
|
+
return createCommand('controllers:list').description('List all the application controllers').action(runAction('controllers:list', action));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { action, command };
|
|
29
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../../../src/cli/commands/controllers/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\n\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\nconst action = async () => {\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).register();\n\n const list = app.get('controllers').keys();\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name: string) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi controllers:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('controllers:list')\n .description('List all the application controllers')\n .action(runAction('controllers:list', action));\n};\n\nexport { action, command };\n"],"names":["action","appContext","compileStrapi","app","createStrapi","register","list","get","keys","infoTable","CLITable","head","chalk","blue","forEach","name","push","console","log","toString","destroy","command","createCommand","description","runAction"],"mappings":";;;;;;AASA,MAAMA,MAAS,GAAA,UAAA;AACb,IAAA,MAAMC,aAAa,MAAMC,aAAAA,EAAAA;AACzB,IAAA,MAAMC,GAAM,GAAA,MAAMC,YAAaH,CAAAA,UAAAA,CAAAA,CAAYI,QAAQ,EAAA;AAEnD,IAAA,MAAMC,IAAOH,GAAAA,GAAAA,CAAII,GAAG,CAAC,eAAeC,IAAI,EAAA;IAExC,MAAMC,SAAAA,GAAY,IAAIC,QAAS,CAAA;QAC7BC,IAAM,EAAA;AAACC,YAAAA,KAAAA,CAAMC,IAAI,CAAC,MAAA;AAAQ;AAC5B,KAAA,CAAA;AAEAP,IAAAA,IAAAA,CAAKQ,OAAO,CAAC,CAACC,IAAiBN,GAAAA,SAAAA,CAAUO,IAAI,CAAC;AAACD,YAAAA;AAAK,SAAA,CAAA,CAAA;IAEpDE,OAAQC,CAAAA,GAAG,CAACT,SAAAA,CAAUU,QAAQ,EAAA,CAAA;AAE9B,IAAA,MAAMhB,IAAIiB,OAAO,EAAA;AACnB;AAEA;;AAEC,UACKC,OAAyB,GAAA,IAAA;IAC7B,OAAOC,aAAAA,CAAc,oBAClBC,WAAW,CAAC,wCACZvB,MAAM,CAACwB,UAAU,kBAAoBxB,EAAAA,MAAAA,CAAAA,CAAAA;AAC1C;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var cluster = require('node:cluster');
|
|
5
|
+
var develop = require('../../node/develop.js');
|
|
6
|
+
var errors = require('../../node/core/errors.js');
|
|
7
|
+
|
|
8
|
+
const action = async (options)=>{
|
|
9
|
+
try {
|
|
10
|
+
if (cluster.isPrimary) {
|
|
11
|
+
if (options.bundler === 'webpack') {
|
|
12
|
+
options.logger.warn('[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
await develop.develop(options);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
errors.handleUnexpectedError(err);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* `$ strapi develop`
|
|
22
|
+
*/ const command = ({ ctx })=>{
|
|
23
|
+
return commander.createCommand('develop').alias('dev').option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite').option('-d, --debug', 'Enable debugging mode with verbose logs', false).option('--silent', "Don't log anything", false).option('--polling', 'Watch for file changes in network directories', false).option('--watch-admin', 'Watch the admin panel for hot changes', true).option('--no-watch-admin', 'Do not watch the admin panel for hot changes').option('--open', 'Open the admin in your browser', true).description('Start your Strapi application in development mode').action(async (options)=>{
|
|
24
|
+
return action({
|
|
25
|
+
...options,
|
|
26
|
+
...ctx
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.command = command;
|
|
32
|
+
//# sourceMappingURL=develop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"develop.js","sources":["../../../../src/cli/commands/develop.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport cluster from 'node:cluster';\nimport type { StrapiCommand } from '../types';\nimport { develop as nodeDevelop, DevelopOptions } from '../../node/develop';\nimport { handleUnexpectedError } from '../../node/core/errors';\n\ntype DevelopCLIOptions = DevelopOptions;\n\nconst action = async (options: DevelopCLIOptions) => {\n try {\n if (cluster.isPrimary) {\n if (options.bundler === 'webpack') {\n options.logger.warn(\n '[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.'\n );\n }\n }\n\n await nodeDevelop(options);\n } catch (err) {\n handleUnexpectedError(err);\n }\n};\n\n/**\n * `$ strapi develop`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('develop')\n .alias('dev')\n .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--polling', 'Watch for file changes in network directories', false)\n .option('--watch-admin', 'Watch the admin panel for hot changes', true)\n .option('--no-watch-admin', 'Do not watch the admin panel for hot changes')\n .option('--open', 'Open the admin in your browser', true)\n .description('Start your Strapi application in development mode')\n .action(async (options: DevelopCLIOptions) => {\n return action({ ...options, ...ctx });\n });\n};\n\nexport { command };\n"],"names":["action","options","cluster","isPrimary","bundler","logger","warn","nodeDevelop","err","handleUnexpectedError","command","ctx","createCommand","alias","option","description"],"mappings":";;;;;;;AAQA,MAAMA,SAAS,OAAOC,OAAAA,GAAAA;IACpB,IAAI;QACF,IAAIC,OAAAA,CAAQC,SAAS,EAAE;YACrB,IAAIF,OAAAA,CAAQG,OAAO,KAAK,SAAW,EAAA;gBACjCH,OAAQI,CAAAA,MAAM,CAACC,IAAI,CACjB,yFAAA,CAAA;AAEJ;AACF;AAEA,QAAA,MAAMC,eAAYN,CAAAA,OAAAA,CAAAA;AACpB,KAAA,CAAE,OAAOO,GAAK,EAAA;QACZC,4BAAsBD,CAAAA,GAAAA,CAAAA;AACxB;AACF,CAAA;AAEA;;AAEC,IACKE,MAAAA,OAAAA,GAAyB,CAAC,EAAEC,GAAG,EAAE,GAAA;IACrC,OAAOC,uBAAAA,CAAc,WAClBC,KAAK,CAAC,OACNC,MAAM,CAAC,uBAAuB,kCAAoC,EAAA,MAAA,CAAA,CAClEA,MAAM,CAAC,aAAA,EAAe,2CAA2C,KACjEA,CAAAA,CAAAA,MAAM,CAAC,UAAY,EAAA,oBAAA,EAAsB,OACzCA,MAAM,CAAC,aAAa,+CAAiD,EAAA,KAAA,CAAA,CACrEA,MAAM,CAAC,eAAA,EAAiB,yCAAyC,IACjEA,CAAAA,CAAAA,MAAM,CAAC,kBAAoB,EAAA,8CAAA,CAAA,CAC3BA,MAAM,CAAC,QAAA,EAAU,kCAAkC,IACnDC,CAAAA,CAAAA,WAAW,CAAC,mDACZf,CAAAA,CAAAA,MAAM,CAAC,OAAOC,OAAAA,GAAAA;AACb,QAAA,OAAOD,MAAO,CAAA;AAAE,YAAA,GAAGC,OAAO;AAAE,YAAA,GAAGU;AAAI,SAAA,CAAA;AACrC,KAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import cluster from 'node:cluster';
|
|
3
|
+
import { develop } from '../../node/develop.mjs';
|
|
4
|
+
import { handleUnexpectedError } from '../../node/core/errors.mjs';
|
|
5
|
+
|
|
6
|
+
const action = async (options)=>{
|
|
7
|
+
try {
|
|
8
|
+
if (cluster.isPrimary) {
|
|
9
|
+
if (options.bundler === 'webpack') {
|
|
10
|
+
options.logger.warn('[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
await develop(options);
|
|
14
|
+
} catch (err) {
|
|
15
|
+
handleUnexpectedError(err);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* `$ strapi develop`
|
|
20
|
+
*/ const command = ({ ctx })=>{
|
|
21
|
+
return createCommand('develop').alias('dev').option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite').option('-d, --debug', 'Enable debugging mode with verbose logs', false).option('--silent', "Don't log anything", false).option('--polling', 'Watch for file changes in network directories', false).option('--watch-admin', 'Watch the admin panel for hot changes', true).option('--no-watch-admin', 'Do not watch the admin panel for hot changes').option('--open', 'Open the admin in your browser', true).description('Start your Strapi application in development mode').action(async (options)=>{
|
|
22
|
+
return action({
|
|
23
|
+
...options,
|
|
24
|
+
...ctx
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { command };
|
|
30
|
+
//# sourceMappingURL=develop.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"develop.mjs","sources":["../../../../src/cli/commands/develop.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport cluster from 'node:cluster';\nimport type { StrapiCommand } from '../types';\nimport { develop as nodeDevelop, DevelopOptions } from '../../node/develop';\nimport { handleUnexpectedError } from '../../node/core/errors';\n\ntype DevelopCLIOptions = DevelopOptions;\n\nconst action = async (options: DevelopCLIOptions) => {\n try {\n if (cluster.isPrimary) {\n if (options.bundler === 'webpack') {\n options.logger.warn(\n '[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite.'\n );\n }\n }\n\n await nodeDevelop(options);\n } catch (err) {\n handleUnexpectedError(err);\n }\n};\n\n/**\n * `$ strapi develop`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('develop')\n .alias('dev')\n .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .option('--polling', 'Watch for file changes in network directories', false)\n .option('--watch-admin', 'Watch the admin panel for hot changes', true)\n .option('--no-watch-admin', 'Do not watch the admin panel for hot changes')\n .option('--open', 'Open the admin in your browser', true)\n .description('Start your Strapi application in development mode')\n .action(async (options: DevelopCLIOptions) => {\n return action({ ...options, ...ctx });\n });\n};\n\nexport { command };\n"],"names":["action","options","cluster","isPrimary","bundler","logger","warn","nodeDevelop","err","handleUnexpectedError","command","ctx","createCommand","alias","option","description"],"mappings":";;;;;AAQA,MAAMA,SAAS,OAAOC,OAAAA,GAAAA;IACpB,IAAI;QACF,IAAIC,OAAAA,CAAQC,SAAS,EAAE;YACrB,IAAIF,OAAAA,CAAQG,OAAO,KAAK,SAAW,EAAA;gBACjCH,OAAQI,CAAAA,MAAM,CAACC,IAAI,CACjB,yFAAA,CAAA;AAEJ;AACF;AAEA,QAAA,MAAMC,OAAYN,CAAAA,OAAAA,CAAAA;AACpB,KAAA,CAAE,OAAOO,GAAK,EAAA;QACZC,qBAAsBD,CAAAA,GAAAA,CAAAA;AACxB;AACF,CAAA;AAEA;;AAEC,IACKE,MAAAA,OAAAA,GAAyB,CAAC,EAAEC,GAAG,EAAE,GAAA;IACrC,OAAOC,aAAAA,CAAc,WAClBC,KAAK,CAAC,OACNC,MAAM,CAAC,uBAAuB,kCAAoC,EAAA,MAAA,CAAA,CAClEA,MAAM,CAAC,aAAA,EAAe,2CAA2C,KACjEA,CAAAA,CAAAA,MAAM,CAAC,UAAY,EAAA,oBAAA,EAAsB,OACzCA,MAAM,CAAC,aAAa,+CAAiD,EAAA,KAAA,CAAA,CACrEA,MAAM,CAAC,eAAA,EAAiB,yCAAyC,IACjEA,CAAAA,CAAAA,MAAM,CAAC,kBAAoB,EAAA,8CAAA,CAAA,CAC3BA,MAAM,CAAC,QAAA,EAAU,kCAAkC,IACnDC,CAAAA,CAAAA,WAAW,CAAC,mDACZf,CAAAA,CAAAA,MAAM,CAAC,OAAOC,OAAAA,GAAAA;AACb,QAAA,OAAOD,MAAO,CAAA;AAAE,YAAA,GAAGC,OAAO;AAAE,YAAA,GAAGU;AAAI,SAAA,CAAA;AACrC,KAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
var fse = require('fs-extra');
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var dataTransfer$1 = require('@strapi/data-transfer');
|
|
7
|
+
var dataTransfer = require('../../utils/data-transfer.js');
|
|
8
|
+
var helpers = require('../../utils/helpers.js');
|
|
9
|
+
|
|
10
|
+
const { providers: { createLocalFileDestinationProvider } } = dataTransfer$1.file;
|
|
11
|
+
const { providers: { createLocalStrapiSourceProvider } } = dataTransfer$1.strapi;
|
|
12
|
+
const BYTES_IN_MB = 1024 * 1024;
|
|
13
|
+
/**
|
|
14
|
+
* Export command.
|
|
15
|
+
*
|
|
16
|
+
* It transfers data from a local Strapi instance to a file
|
|
17
|
+
*
|
|
18
|
+
* @param {ExportCommandOptions} opts
|
|
19
|
+
*/ var action = (async (opts)=>{
|
|
20
|
+
// Validate inputs from Commander
|
|
21
|
+
if (!fp.isObject(opts)) {
|
|
22
|
+
helpers.exitWith(1, 'Could not parse command arguments');
|
|
23
|
+
}
|
|
24
|
+
const strapi = await dataTransfer.createStrapiInstance();
|
|
25
|
+
const source = createSourceProvider(strapi);
|
|
26
|
+
const destination = createDestinationProvider(opts);
|
|
27
|
+
const engine = dataTransfer$1.engine.createTransferEngine(source, destination, {
|
|
28
|
+
versionStrategy: 'ignore',
|
|
29
|
+
schemaStrategy: 'ignore',
|
|
30
|
+
exclude: opts.exclude,
|
|
31
|
+
only: opts.only,
|
|
32
|
+
throttle: opts.throttle,
|
|
33
|
+
transforms: {
|
|
34
|
+
links: [
|
|
35
|
+
{
|
|
36
|
+
filter (link) {
|
|
37
|
+
return !dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(link.left.type) && !dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(link.right.type);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
entities: [
|
|
42
|
+
{
|
|
43
|
+
filter (entity) {
|
|
44
|
+
return !dataTransfer.DEFAULT_IGNORED_CONTENT_TYPES.includes(entity.type);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
engine.diagnostics.onDiagnostic(dataTransfer.formatDiagnostic('export', opts.verbose));
|
|
51
|
+
const progress = engine.progress.stream;
|
|
52
|
+
const { updateLoader } = dataTransfer.loadersFactory();
|
|
53
|
+
progress.on(`stage::start`, ({ stage, data })=>{
|
|
54
|
+
updateLoader(stage, data).start();
|
|
55
|
+
});
|
|
56
|
+
progress.on('stage::finish', ({ stage, data })=>{
|
|
57
|
+
updateLoader(stage, data).succeed();
|
|
58
|
+
});
|
|
59
|
+
progress.on('stage::progress', ({ stage, data })=>{
|
|
60
|
+
updateLoader(stage, data);
|
|
61
|
+
});
|
|
62
|
+
progress.on('transfer::start', async ()=>{
|
|
63
|
+
console.log(`Starting export...`);
|
|
64
|
+
await strapi.telemetry.send('didDEITSProcessStart', dataTransfer.getTransferTelemetryPayload(engine));
|
|
65
|
+
});
|
|
66
|
+
let results;
|
|
67
|
+
let outFile;
|
|
68
|
+
try {
|
|
69
|
+
// Abort transfer if user interrupts process
|
|
70
|
+
dataTransfer.setSignalHandler(()=>dataTransfer.abortTransfer({
|
|
71
|
+
engine,
|
|
72
|
+
strapi
|
|
73
|
+
}));
|
|
74
|
+
results = await engine.transfer();
|
|
75
|
+
outFile = results.destination?.file?.path ?? '';
|
|
76
|
+
const outFileExists = await fse.pathExists(outFile);
|
|
77
|
+
if (!outFileExists) {
|
|
78
|
+
throw new dataTransfer$1.engine.errors.TransferEngineTransferError(`Export file not created "${outFile}"`);
|
|
79
|
+
}
|
|
80
|
+
// Note: we need to await telemetry or else the process ends before it is sent
|
|
81
|
+
await strapi.telemetry.send('didDEITSProcessFinish', dataTransfer.getTransferTelemetryPayload(engine));
|
|
82
|
+
try {
|
|
83
|
+
const table = dataTransfer.buildTransferTable(results.engine);
|
|
84
|
+
console.log(table?.toString());
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error('There was an error displaying the results of the transfer.');
|
|
87
|
+
}
|
|
88
|
+
console.log(`Export archive is in ${chalk.green(outFile)}`);
|
|
89
|
+
helpers.exitWith(0, dataTransfer.exitMessageText('export'));
|
|
90
|
+
} catch {
|
|
91
|
+
await strapi.telemetry.send('didDEITSProcessFail', dataTransfer.getTransferTelemetryPayload(engine));
|
|
92
|
+
helpers.exitWith(1, dataTransfer.exitMessageText('export', true));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* It creates a local strapi destination provider
|
|
97
|
+
*/ const createSourceProvider = (strapi)=>{
|
|
98
|
+
return createLocalStrapiSourceProvider({
|
|
99
|
+
async getStrapi () {
|
|
100
|
+
return strapi;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* It creates a local file destination provider based on the given options
|
|
106
|
+
*/ const createDestinationProvider = (opts)=>{
|
|
107
|
+
const { file, compress, encrypt, key, maxSizeJsonl } = opts;
|
|
108
|
+
const filepath = fp.isString(file) && file.length > 0 ? file : dataTransfer.getDefaultExportName();
|
|
109
|
+
const maxSizeJsonlInMb = fp.isFinite(fp.toNumber(maxSizeJsonl)) ? fp.toNumber(maxSizeJsonl) * BYTES_IN_MB : undefined;
|
|
110
|
+
return createLocalFileDestinationProvider({
|
|
111
|
+
file: {
|
|
112
|
+
path: filepath,
|
|
113
|
+
maxSizeJsonl: maxSizeJsonlInMb
|
|
114
|
+
},
|
|
115
|
+
encryption: {
|
|
116
|
+
enabled: encrypt ?? false,
|
|
117
|
+
key: encrypt ? key : undefined
|
|
118
|
+
},
|
|
119
|
+
compression: {
|
|
120
|
+
enabled: compress ?? false
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
module.exports = action;
|
|
126
|
+
//# sourceMappingURL=action.js.map
|