@strapi/strapi 5.9.0 → 5.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-test.js +11 -8
- package/dist/admin-test.js.map +1 -1
- package/dist/admin-test.mjs +1 -1
- package/dist/admin-test.mjs.map +1 -1
- package/dist/admin.js +36 -42
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs +28 -35
- package/dist/admin.mjs.map +1 -1
- package/dist/chunks/aliases-Ca20Yntz.js +80 -0
- package/dist/chunks/aliases-Ca20Yntz.js.map +1 -0
- package/dist/chunks/aliases-DQ51KexN.mjs +76 -0
- package/dist/chunks/aliases-DQ51KexN.mjs.map +1 -0
- package/dist/chunks/build-3I6A92J1.js +59 -0
- package/dist/chunks/build-3I6A92J1.js.map +1 -0
- package/dist/chunks/build-BqigoS45.mjs +85 -0
- package/dist/chunks/build-BqigoS45.mjs.map +1 -0
- package/dist/chunks/build-CWUlYFQo.js +87 -0
- package/dist/chunks/build-CWUlYFQo.js.map +1 -0
- package/dist/chunks/build-gBR43Dth.mjs +57 -0
- package/dist/chunks/build-gBR43Dth.mjs.map +1 -0
- package/dist/chunks/config-5tFWkbOi.js +154 -0
- package/dist/chunks/config-5tFWkbOi.js.map +1 -0
- package/dist/chunks/config-BSlsDIVc.mjs +243 -0
- package/dist/chunks/config-BSlsDIVc.mjs.map +1 -0
- package/dist/chunks/config-CLeubzgx.mjs +150 -0
- package/dist/chunks/config-CLeubzgx.mjs.map +1 -0
- package/dist/chunks/config-CQ94iNYq.js +247 -0
- package/dist/chunks/config-CQ94iNYq.js.map +1 -0
- package/dist/chunks/index-DtHH3PFG.mjs +3160 -0
- package/dist/chunks/index-DtHH3PFG.mjs.map +1 -0
- package/dist/chunks/index-kv_K5f7_.js +3185 -0
- package/dist/chunks/index-kv_K5f7_.js.map +1 -0
- package/dist/chunks/watch-B7qfL21s.js +146 -0
- package/dist/chunks/watch-B7qfL21s.js.map +1 -0
- package/dist/chunks/watch-BBDpuCFC.js +133 -0
- package/dist/chunks/watch-BBDpuCFC.js.map +1 -0
- package/dist/chunks/watch-Bhd-75O5.mjs +131 -0
- package/dist/chunks/watch-Bhd-75O5.mjs.map +1 -0
- package/dist/chunks/watch-CJr1UoWF.mjs +144 -0
- package/dist/chunks/watch-CJr1UoWF.mjs.map +1 -0
- package/dist/cli/commands/plugin/init/files/typescript.d.ts +20 -7
- package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +1 -1
- package/dist/cli/commands/version.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.js +50 -0
- package/dist/cli.js.map +1 -0
- package/dist/cli.mjs +43 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/node/core/errors.d.ts.map +1 -1
- package/dist/node/create-build-context.d.ts +1 -1
- package/dist/node/create-build-context.d.ts.map +1 -1
- package/package.json +26 -26
- package/dist/cli/commands/admin/create-user.js +0 -91
- package/dist/cli/commands/admin/create-user.js.map +0 -1
- package/dist/cli/commands/admin/create-user.mjs +0 -88
- package/dist/cli/commands/admin/create-user.mjs.map +0 -1
- package/dist/cli/commands/admin/reset-user-password.js +0 -47
- package/dist/cli/commands/admin/reset-user-password.js.map +0 -1
- package/dist/cli/commands/admin/reset-user-password.mjs +0 -44
- package/dist/cli/commands/admin/reset-user-password.mjs.map +0 -1
- package/dist/cli/commands/build.js +0 -24
- package/dist/cli/commands/build.js.map +0 -1
- package/dist/cli/commands/build.mjs +0 -24
- package/dist/cli/commands/build.mjs.map +0 -1
- package/dist/cli/commands/components/list.js +0 -27
- package/dist/cli/commands/components/list.js.map +0 -1
- package/dist/cli/commands/components/list.mjs +0 -24
- package/dist/cli/commands/components/list.mjs.map +0 -1
- package/dist/cli/commands/configuration/dump.js +0 -43
- package/dist/cli/commands/configuration/dump.js.map +0 -1
- package/dist/cli/commands/configuration/dump.mjs +0 -41
- package/dist/cli/commands/configuration/dump.mjs.map +0 -1
- package/dist/cli/commands/configuration/restore.js +0 -142
- package/dist/cli/commands/configuration/restore.js.map +0 -1
- package/dist/cli/commands/configuration/restore.mjs +0 -139
- package/dist/cli/commands/configuration/restore.mjs.map +0 -1
- package/dist/cli/commands/console.js +0 -29
- package/dist/cli/commands/console.js.map +0 -1
- package/dist/cli/commands/console.mjs +0 -27
- package/dist/cli/commands/console.mjs.map +0 -1
- package/dist/cli/commands/content-types/list.js +0 -27
- package/dist/cli/commands/content-types/list.js.map +0 -1
- package/dist/cli/commands/content-types/list.mjs +0 -24
- package/dist/cli/commands/content-types/list.mjs.map +0 -1
- package/dist/cli/commands/controllers/list.js +0 -27
- package/dist/cli/commands/controllers/list.js.map +0 -1
- package/dist/cli/commands/controllers/list.mjs +0 -24
- package/dist/cli/commands/controllers/list.mjs.map +0 -1
- package/dist/cli/commands/develop.js +0 -29
- package/dist/cli/commands/develop.js.map +0 -1
- package/dist/cli/commands/develop.mjs +0 -27
- package/dist/cli/commands/develop.mjs.map +0 -1
- package/dist/cli/commands/export/action.js +0 -118
- package/dist/cli/commands/export/action.js.map +0 -1
- package/dist/cli/commands/export/action.mjs +0 -116
- package/dist/cli/commands/export/action.mjs.map +0 -1
- package/dist/cli/commands/export/command.js +0 -23
- package/dist/cli/commands/export/command.js.map +0 -1
- package/dist/cli/commands/export/command.mjs +0 -24
- package/dist/cli/commands/export/command.mjs.map +0 -1
- package/dist/cli/commands/generate.js +0 -35
- package/dist/cli/commands/generate.js.map +0 -1
- package/dist/cli/commands/generate.mjs +0 -13
- package/dist/cli/commands/generate.mjs.map +0 -1
- package/dist/cli/commands/hooks/list.js +0 -27
- package/dist/cli/commands/hooks/list.js.map +0 -1
- package/dist/cli/commands/hooks/list.mjs +0 -24
- package/dist/cli/commands/hooks/list.mjs.map +0 -1
- package/dist/cli/commands/import/action.js +0 -106
- package/dist/cli/commands/import/action.js.map +0 -1
- package/dist/cli/commands/import/action.mjs +0 -105
- package/dist/cli/commands/import/action.mjs.map +0 -1
- package/dist/cli/commands/import/command.js +0 -70
- package/dist/cli/commands/import/command.js.map +0 -1
- package/dist/cli/commands/import/command.mjs +0 -68
- package/dist/cli/commands/import/command.mjs.map +0 -1
- package/dist/cli/commands/index.js +0 -63
- package/dist/cli/commands/index.js.map +0 -1
- package/dist/cli/commands/index.mjs +0 -63
- package/dist/cli/commands/index.mjs.map +0 -1
- package/dist/cli/commands/middlewares/list.js +0 -27
- package/dist/cli/commands/middlewares/list.js.map +0 -1
- package/dist/cli/commands/middlewares/list.mjs +0 -24
- package/dist/cli/commands/middlewares/list.mjs.map +0 -1
- package/dist/cli/commands/policies/list.js +0 -27
- package/dist/cli/commands/policies/list.js.map +0 -1
- package/dist/cli/commands/policies/list.mjs +0 -24
- package/dist/cli/commands/policies/list.mjs.map +0 -1
- package/dist/cli/commands/report.js +0 -35
- package/dist/cli/commands/report.js.map +0 -1
- package/dist/cli/commands/report.mjs +0 -35
- package/dist/cli/commands/report.mjs.map +0 -1
- package/dist/cli/commands/routes/list.js +0 -31
- package/dist/cli/commands/routes/list.js.map +0 -1
- package/dist/cli/commands/routes/list.mjs +0 -28
- package/dist/cli/commands/routes/list.mjs.map +0 -1
- package/dist/cli/commands/services/list.js +0 -27
- package/dist/cli/commands/services/list.js.map +0 -1
- package/dist/cli/commands/services/list.mjs +0 -24
- package/dist/cli/commands/services/list.mjs.map +0 -1
- package/dist/cli/commands/start.js +0 -27
- package/dist/cli/commands/start.js.map +0 -1
- package/dist/cli/commands/start.mjs +0 -24
- package/dist/cli/commands/start.mjs.map +0 -1
- package/dist/cli/commands/telemetry/disable.js +0 -70
- package/dist/cli/commands/telemetry/disable.js.map +0 -1
- package/dist/cli/commands/telemetry/disable.mjs +0 -67
- package/dist/cli/commands/telemetry/disable.mjs.map +0 -1
- package/dist/cli/commands/telemetry/enable.js +0 -89
- package/dist/cli/commands/telemetry/enable.js.map +0 -1
- package/dist/cli/commands/telemetry/enable.mjs +0 -86
- package/dist/cli/commands/telemetry/enable.mjs.map +0 -1
- package/dist/cli/commands/templates/generate.js +0 -11
- package/dist/cli/commands/templates/generate.js.map +0 -1
- package/dist/cli/commands/templates/generate.mjs +0 -11
- package/dist/cli/commands/templates/generate.mjs.map +0 -1
- package/dist/cli/commands/transfer/action.js +0 -130
- package/dist/cli/commands/transfer/action.js.map +0 -1
- package/dist/cli/commands/transfer/action.mjs +0 -131
- package/dist/cli/commands/transfer/action.mjs.map +0 -1
- package/dist/cli/commands/transfer/command.js +0 -85
- package/dist/cli/commands/transfer/command.js.map +0 -1
- package/dist/cli/commands/transfer/command.mjs +0 -84
- package/dist/cli/commands/transfer/command.mjs.map +0 -1
- package/dist/cli/commands/ts/generate-types.js +0 -36
- package/dist/cli/commands/ts/generate-types.js.map +0 -1
- package/dist/cli/commands/ts/generate-types.mjs +0 -34
- package/dist/cli/commands/ts/generate-types.mjs.map +0 -1
- package/dist/cli/commands/version.js +0 -13
- package/dist/cli/commands/version.js.map +0 -1
- package/dist/cli/commands/version.mjs +0 -13
- package/dist/cli/commands/version.mjs.map +0 -1
- package/dist/cli/index.js +0 -79
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/index.mjs +0 -79
- package/dist/cli/index.mjs.map +0 -1
- package/dist/cli/utils/commander.js +0 -111
- package/dist/cli/utils/commander.js.map +0 -1
- package/dist/cli/utils/commander.mjs +0 -108
- package/dist/cli/utils/commander.mjs.map +0 -1
- package/dist/cli/utils/data-transfer.js +0 -354
- package/dist/cli/utils/data-transfer.js.map +0 -1
- package/dist/cli/utils/data-transfer.mjs +0 -350
- package/dist/cli/utils/data-transfer.mjs.map +0 -1
- package/dist/cli/utils/helpers.js +0 -102
- package/dist/cli/utils/helpers.js.map +0 -1
- package/dist/cli/utils/helpers.mjs +0 -100
- package/dist/cli/utils/helpers.mjs.map +0 -1
- package/dist/cli/utils/logger.js +0 -137
- package/dist/cli/utils/logger.js.map +0 -1
- package/dist/cli/utils/logger.mjs +0 -116
- package/dist/cli/utils/logger.mjs.map +0 -1
- package/dist/cli/utils/telemetry.js +0 -22
- package/dist/cli/utils/telemetry.js.map +0 -1
- package/dist/cli/utils/telemetry.mjs +0 -22
- package/dist/cli/utils/telemetry.mjs.map +0 -1
- package/dist/cli/utils/tsconfig.js +0 -26
- package/dist/cli/utils/tsconfig.js.map +0 -1
- package/dist/cli/utils/tsconfig.mjs +0 -23
- package/dist/cli/utils/tsconfig.mjs.map +0 -1
- package/dist/node/build.js +0 -76
- package/dist/node/build.js.map +0 -1
- package/dist/node/build.mjs +0 -58
- package/dist/node/build.mjs.map +0 -1
- package/dist/node/core/admin-customisations.js +0 -24
- package/dist/node/core/admin-customisations.js.map +0 -1
- package/dist/node/core/admin-customisations.mjs +0 -22
- package/dist/node/core/admin-customisations.mjs.map +0 -1
- package/dist/node/core/aliases.js +0 -33
- package/dist/node/core/aliases.js.map +0 -1
- package/dist/node/core/aliases.mjs +0 -31
- package/dist/node/core/aliases.mjs.map +0 -1
- package/dist/node/core/config.js +0 -18
- package/dist/node/core/config.js.map +0 -1
- package/dist/node/core/config.mjs +0 -16
- package/dist/node/core/config.mjs.map +0 -1
- package/dist/node/core/dependencies.js +0 -163
- package/dist/node/core/dependencies.js.map +0 -1
- package/dist/node/core/dependencies.mjs +0 -155
- package/dist/node/core/dependencies.mjs.map +0 -1
- package/dist/node/core/env.js +0 -26
- package/dist/node/core/env.js.map +0 -1
- package/dist/node/core/env.mjs +0 -23
- package/dist/node/core/env.mjs.map +0 -1
- package/dist/node/core/errors.js +0 -33
- package/dist/node/core/errors.js.map +0 -1
- package/dist/node/core/errors.mjs +0 -29
- package/dist/node/core/errors.mjs.map +0 -1
- package/dist/node/core/files.js +0 -45
- package/dist/node/core/files.js.map +0 -1
- package/dist/node/core/files.mjs +0 -43
- package/dist/node/core/files.mjs.map +0 -1
- package/dist/node/core/managers.js +0 -17
- package/dist/node/core/managers.js.map +0 -1
- package/dist/node/core/managers.mjs +0 -17
- package/dist/node/core/managers.mjs.map +0 -1
- package/dist/node/core/monorepo.js +0 -23
- package/dist/node/core/monorepo.js.map +0 -1
- package/dist/node/core/monorepo.mjs +0 -20
- package/dist/node/core/monorepo.mjs.map +0 -1
- package/dist/node/core/plugins.js +0 -116
- package/dist/node/core/plugins.js.map +0 -1
- package/dist/node/core/plugins.mjs +0 -111
- package/dist/node/core/plugins.mjs.map +0 -1
- package/dist/node/core/timer.js +0 -27
- package/dist/node/core/timer.js.map +0 -1
- package/dist/node/core/timer.mjs +0 -27
- package/dist/node/core/timer.mjs.map +0 -1
- package/dist/node/create-build-context.js +0 -101
- package/dist/node/create-build-context.js.map +0 -1
- package/dist/node/create-build-context.mjs +0 -96
- package/dist/node/create-build-context.mjs.map +0 -1
- package/dist/node/develop.js +0 -275
- package/dist/node/develop.js.map +0 -1
- package/dist/node/develop.mjs +0 -252
- package/dist/node/develop.mjs.map +0 -1
- package/dist/node/staticFiles.js +0 -102
- package/dist/node/staticFiles.js.map +0 -1
- package/dist/node/staticFiles.mjs +0 -76
- package/dist/node/staticFiles.mjs.map +0 -1
- package/dist/node/vite/build.js +0 -34
- package/dist/node/vite/build.js.map +0 -1
- package/dist/node/vite/build.mjs +0 -12
- package/dist/node/vite/build.mjs.map +0 -1
- package/dist/node/vite/config.js +0 -106
- package/dist/node/vite/config.js.map +0 -1
- package/dist/node/vite/config.mjs +0 -103
- package/dist/node/vite/config.mjs.map +0 -1
- package/dist/node/vite/plugins.js +0 -43
- package/dist/node/vite/plugins.js.map +0 -1
- package/dist/node/vite/plugins.mjs +0 -43
- package/dist/node/vite/plugins.mjs.map +0 -1
- package/dist/node/vite/watch.js +0 -111
- package/dist/node/vite/watch.js.map +0 -1
- package/dist/node/vite/watch.mjs +0 -85
- package/dist/node/vite/watch.mjs.map +0 -1
- package/dist/node/webpack/build.js +0 -41
- package/dist/node/webpack/build.js.map +0 -1
- package/dist/node/webpack/build.mjs +0 -39
- package/dist/node/webpack/build.mjs.map +0 -1
- package/dist/node/webpack/config.js +0 -259
- package/dist/node/webpack/config.js.map +0 -1
- package/dist/node/webpack/config.mjs +0 -228
- package/dist/node/webpack/config.mjs.map +0 -1
- package/dist/node/webpack/watch.js +0 -95
- package/dist/node/webpack/watch.js.map +0 -1
- package/dist/node/webpack/watch.mjs +0 -90
- package/dist/node/webpack/watch.mjs.map +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createCommand } from "commander";
|
|
2
|
-
import { build } from "../../node/build.mjs";
|
|
3
|
-
import { handleUnexpectedError } from "../../node/core/errors.mjs";
|
|
4
|
-
const action = async (options) => {
|
|
5
|
-
try {
|
|
6
|
-
if (options.bundler === "webpack") {
|
|
7
|
-
options.logger.warn(
|
|
8
|
-
"[@strapi/strapi]: Using webpack as a bundler is deprecated. You should migrate to vite."
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
await build(options);
|
|
12
|
-
} catch (err) {
|
|
13
|
-
handleUnexpectedError(err);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const command = ({ ctx }) => {
|
|
17
|
-
return createCommand("build").option("--bundler [bundler]", "Bundler to use (webpack or vite)", "vite").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--minify", "Minify the output", true).option("--silent", "Don't log anything", false).option("--sourcemap", "Produce sourcemaps", false).option("--stats", "Print build statistics to the console", false).description("Build the strapi admin app").action(async (options) => {
|
|
18
|
-
return action({ ...options, ...ctx });
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
command
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=build.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.mjs","sources":["../../../src/cli/commands/build.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport type { StrapiCommand } from '../types';\n\nimport { build as nodeBuild, BuildOptions } from '../../node/build';\nimport { handleUnexpectedError } from '../../node/core/errors';\n\ntype BuildCLIOptions = BuildOptions;\n\nconst action = async (options: BuildCLIOptions) => {\n try {\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 await nodeBuild(options);\n } catch (err) {\n handleUnexpectedError(err);\n }\n};\n\n/**\n * `$ strapi build`\n */\nconst command: StrapiCommand = ({ ctx }) => {\n return createCommand('build')\n .option('--bundler [bundler]', 'Bundler to use (webpack or vite)', 'vite')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--minify', 'Minify the output', true)\n .option('--silent', \"Don't log anything\", false)\n .option('--sourcemap', 'Produce sourcemaps', false)\n .option('--stats', 'Print build statistics to the console', false)\n .description('Build the strapi admin app')\n .action(async (options: BuildCLIOptions) => {\n return action({ ...options, ...ctx });\n });\n};\n\nexport { command };\n"],"names":["nodeBuild"],"mappings":";;;AAQA,MAAM,SAAS,OAAO,YAA6B;AAC7C,MAAA;AACE,QAAA,QAAQ,YAAY,WAAW;AACjC,cAAQ,OAAO;AAAA,QACb;AAAA,MACF;AAAA,IAAA;AAGF,UAAMA,MAAU,OAAO;AAAA,WAChB,KAAK;AACZ,0BAAsB,GAAG;AAAA,EAAA;AAE7B;AAKA,MAAM,UAAyB,CAAC,EAAE,UAAU;AAC1C,SAAO,cAAc,OAAO,EACzB,OAAO,uBAAuB,oCAAoC,MAAM,EACxE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,qBAAqB,IAAI,EAC5C,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,eAAe,sBAAsB,KAAK,EACjD,OAAO,WAAW,yCAAyC,KAAK,EAChE,YAAY,4BAA4B,EACxC,OAAO,OAAO,YAA6B;AAC1C,WAAO,OAAO,EAAE,GAAG,SAAS,GAAG,KAAK;AAAA,EAAA,CACrC;AACL;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const commander = require("commander");
|
|
4
|
-
const CLITable = require("cli-table3");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
|
-
const core = require("@strapi/core");
|
|
7
|
-
const helpers = require("../../utils/helpers.js");
|
|
8
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
-
const CLITable__default = /* @__PURE__ */ _interopDefault(CLITable);
|
|
10
|
-
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
11
|
-
const action = async () => {
|
|
12
|
-
const appContext = await core.compileStrapi();
|
|
13
|
-
const app = await core.createStrapi(appContext).register();
|
|
14
|
-
const list = Object.keys(app.components);
|
|
15
|
-
const infoTable = new CLITable__default.default({
|
|
16
|
-
head: [chalk__default.default.blue("Name")]
|
|
17
|
-
});
|
|
18
|
-
list.forEach((name) => infoTable.push([name]));
|
|
19
|
-
console.log(infoTable.toString());
|
|
20
|
-
await app.destroy();
|
|
21
|
-
};
|
|
22
|
-
const command = () => {
|
|
23
|
-
return commander.createCommand("components:list").description("List all the application components").action(helpers.runAction("components:list", action));
|
|
24
|
-
};
|
|
25
|
-
exports.action = action;
|
|
26
|
-
exports.command = command;
|
|
27
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sources":["../../../../src/cli/commands/components/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\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 = Object.keys(app.components);\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi components:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('components:list')\n .description('List all the application components')\n .action(runAction('components:list', action));\n};\n\nexport { action, command };\n"],"names":["compileStrapi","createStrapi","CLITable","chalk","createCommand","runAction"],"mappings":";;;;;;;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,mBAAc;AACvC,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,SAAS;AAEpD,QAAM,OAAO,OAAO,KAAK,IAAI,UAAU;AAEjC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAAA,QAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAS,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAErC,UAAA,IAAI,UAAU,UAAU;AAEhC,QAAM,IAAI,QAAQ;AACpB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,UAAA,cAAc,iBAAiB,EACnC,YAAY,qCAAqC,EACjD,OAAOC,QAAA,UAAU,mBAAmB,MAAM,CAAC;AAChD;;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
const action = async () => {
|
|
7
|
-
const appContext = await compileStrapi();
|
|
8
|
-
const app = await createStrapi(appContext).register();
|
|
9
|
-
const list = Object.keys(app.components);
|
|
10
|
-
const infoTable = new CLITable({
|
|
11
|
-
head: [chalk.blue("Name")]
|
|
12
|
-
});
|
|
13
|
-
list.forEach((name) => infoTable.push([name]));
|
|
14
|
-
console.log(infoTable.toString());
|
|
15
|
-
await app.destroy();
|
|
16
|
-
};
|
|
17
|
-
const command = () => {
|
|
18
|
-
return createCommand("components:list").description("List all the application components").action(runAction("components:list", action));
|
|
19
|
-
};
|
|
20
|
-
export {
|
|
21
|
-
action,
|
|
22
|
-
command
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=list.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.mjs","sources":["../../../../src/cli/commands/components/list.ts"],"sourcesContent":["import { createCommand } from 'commander';\nimport CLITable from 'cli-table3';\nimport chalk from 'chalk';\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 = Object.keys(app.components);\n\n const infoTable = new CLITable({\n head: [chalk.blue('Name')],\n });\n\n list.forEach((name) => infoTable.push([name]));\n\n console.log(infoTable.toString());\n\n await app.destroy();\n};\n\n/**\n * `$ strapi components:list`\n */\nconst command: StrapiCommand = () => {\n return createCommand('components:list')\n .description('List all the application components')\n .action(runAction('components:list', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;;AAQA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAM,cAAc;AACvC,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,SAAS;AAEpD,QAAM,OAAO,OAAO,KAAK,IAAI,UAAU;AAEjC,QAAA,YAAY,IAAI,SAAS;AAAA,IAC7B,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAS,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAErC,UAAA,IAAI,UAAU,UAAU;AAEhC,QAAM,IAAI,QAAQ;AACpB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,iBAAiB,EACnC,YAAY,qCAAqC,EACjD,OAAO,UAAU,mBAAmB,MAAM,CAAC;AAChD;"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const commander = require("commander");
|
|
5
|
-
const core = require("@strapi/core");
|
|
6
|
-
const helpers = require("../../utils/helpers.js");
|
|
7
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
|
-
const fs__default = /* @__PURE__ */ _interopDefault(fs);
|
|
9
|
-
const CHUNK_SIZE = 100;
|
|
10
|
-
const action = async ({ file: filePath, pretty }) => {
|
|
11
|
-
const output = filePath ? fs__default.default.createWriteStream(filePath) : process.stdout;
|
|
12
|
-
const appContext = await core.compileStrapi();
|
|
13
|
-
const app = await core.createStrapi(appContext).load();
|
|
14
|
-
const count = await app.query("strapi::core-store").count();
|
|
15
|
-
const exportData = [];
|
|
16
|
-
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
|
17
|
-
for (let page = 0; page < pageCount; page += 1) {
|
|
18
|
-
const results = await app.query("strapi::core-store").findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: "key" });
|
|
19
|
-
results.filter((result) => result.key.startsWith("plugin_")).forEach((result) => {
|
|
20
|
-
exportData.push({
|
|
21
|
-
key: result.key,
|
|
22
|
-
value: result.value,
|
|
23
|
-
type: result.type,
|
|
24
|
-
environment: result.environment,
|
|
25
|
-
tag: result.tag
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
const str = JSON.stringify(exportData, null, pretty ? 2 : void 0);
|
|
30
|
-
output.write(str);
|
|
31
|
-
output.write("\n");
|
|
32
|
-
output.end();
|
|
33
|
-
if (filePath) {
|
|
34
|
-
console.log(`Successfully exported ${exportData.length} configuration entries`);
|
|
35
|
-
}
|
|
36
|
-
process.exit(0);
|
|
37
|
-
};
|
|
38
|
-
const command = () => {
|
|
39
|
-
return commander.createCommand("configuration:dump").alias("config:dump").description("Dump configurations of your application").option("-f, --file <file>", "Output file, default output is stdout").option("-p, --pretty", "Format the output JSON with indentation and line breaks", false).action(helpers.runAction("configuration:dump", action));
|
|
40
|
-
};
|
|
41
|
-
exports.action = action;
|
|
42
|
-
exports.command = command;
|
|
43
|
-
//# sourceMappingURL=dump.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dump.js","sources":["../../../../src/cli/commands/configuration/dump.ts"],"sourcesContent":["import fs from 'fs';\nimport { createCommand } from 'commander';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ninterface CmdOptions {\n file?: string;\n pretty?: boolean;\n}\n\ninterface ExportItem {\n key: string;\n value: string;\n type: string;\n environment: string;\n tag: string;\n}\n\ninterface Output {\n write(str: string): void;\n end(): void;\n}\n\nconst CHUNK_SIZE = 100;\n\n/**\n * Will dump configurations to a file or stdout\n * @param {string} file filepath to use as output\n */\nconst action = async ({ file: filePath, pretty }: CmdOptions) => {\n const output: Output = filePath ? fs.createWriteStream(filePath) : process.stdout;\n\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n const count = await app.query('strapi::core-store').count();\n\n const exportData: ExportItem[] = [];\n\n const pageCount = Math.ceil(count / CHUNK_SIZE);\n\n for (let page = 0; page < pageCount; page += 1) {\n const results = await app\n .query('strapi::core-store')\n .findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });\n\n results\n .filter((result) => result.key.startsWith('plugin_'))\n .forEach((result) => {\n exportData.push({\n key: result.key,\n value: result.value,\n type: result.type,\n environment: result.environment,\n tag: result.tag,\n });\n });\n }\n\n const str = JSON.stringify(exportData, null, pretty ? 2 : undefined);\n\n output.write(str);\n output.write('\\n');\n output.end();\n\n // log success only when writting to file\n if (filePath) {\n console.log(`Successfully exported ${exportData.length} configuration entries`);\n }\n process.exit(0);\n};\n\n/**\n * `$ strapi configuration:dump`\n */\nconst command: StrapiCommand = () => {\n return createCommand('configuration:dump')\n .alias('config:dump')\n .description('Dump configurations of your application')\n .option('-f, --file <file>', 'Output file, default output is stdout')\n .option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)\n .action(runAction('config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EACnE,OAAO,gBAAgB,2DAA2D,KAAK,EACvF,OAAOC,QAAA,UAAU,sBAAsB,MAAM,CAAC;AACnD;;;"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { createCommand } from "commander";
|
|
3
|
-
import { compileStrapi, createStrapi } from "@strapi/core";
|
|
4
|
-
import { runAction } from "../../utils/helpers.mjs";
|
|
5
|
-
const CHUNK_SIZE = 100;
|
|
6
|
-
const action = async ({ file: filePath, pretty }) => {
|
|
7
|
-
const output = filePath ? fs.createWriteStream(filePath) : process.stdout;
|
|
8
|
-
const appContext = await compileStrapi();
|
|
9
|
-
const app = await createStrapi(appContext).load();
|
|
10
|
-
const count = await app.query("strapi::core-store").count();
|
|
11
|
-
const exportData = [];
|
|
12
|
-
const pageCount = Math.ceil(count / CHUNK_SIZE);
|
|
13
|
-
for (let page = 0; page < pageCount; page += 1) {
|
|
14
|
-
const results = await app.query("strapi::core-store").findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: "key" });
|
|
15
|
-
results.filter((result) => result.key.startsWith("plugin_")).forEach((result) => {
|
|
16
|
-
exportData.push({
|
|
17
|
-
key: result.key,
|
|
18
|
-
value: result.value,
|
|
19
|
-
type: result.type,
|
|
20
|
-
environment: result.environment,
|
|
21
|
-
tag: result.tag
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
const str = JSON.stringify(exportData, null, pretty ? 2 : void 0);
|
|
26
|
-
output.write(str);
|
|
27
|
-
output.write("\n");
|
|
28
|
-
output.end();
|
|
29
|
-
if (filePath) {
|
|
30
|
-
console.log(`Successfully exported ${exportData.length} configuration entries`);
|
|
31
|
-
}
|
|
32
|
-
process.exit(0);
|
|
33
|
-
};
|
|
34
|
-
const command = () => {
|
|
35
|
-
return createCommand("configuration:dump").alias("config:dump").description("Dump configurations of your application").option("-f, --file <file>", "Output file, default output is stdout").option("-p, --pretty", "Format the output JSON with indentation and line breaks", false).action(runAction("configuration:dump", action));
|
|
36
|
-
};
|
|
37
|
-
export {
|
|
38
|
-
action,
|
|
39
|
-
command
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=dump.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dump.mjs","sources":["../../../../src/cli/commands/configuration/dump.ts"],"sourcesContent":["import fs from 'fs';\nimport { createCommand } from 'commander';\nimport { createStrapi, compileStrapi } from '@strapi/core';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\n\ninterface CmdOptions {\n file?: string;\n pretty?: boolean;\n}\n\ninterface ExportItem {\n key: string;\n value: string;\n type: string;\n environment: string;\n tag: string;\n}\n\ninterface Output {\n write(str: string): void;\n end(): void;\n}\n\nconst CHUNK_SIZE = 100;\n\n/**\n * Will dump configurations to a file or stdout\n * @param {string} file filepath to use as output\n */\nconst action = async ({ file: filePath, pretty }: CmdOptions) => {\n const output: Output = filePath ? fs.createWriteStream(filePath) : process.stdout;\n\n const appContext = await compileStrapi();\n const app = await createStrapi(appContext).load();\n\n const count = await app.query('strapi::core-store').count();\n\n const exportData: ExportItem[] = [];\n\n const pageCount = Math.ceil(count / CHUNK_SIZE);\n\n for (let page = 0; page < pageCount; page += 1) {\n const results = await app\n .query('strapi::core-store')\n .findMany({ limit: CHUNK_SIZE, offset: page * CHUNK_SIZE, orderBy: 'key' });\n\n results\n .filter((result) => result.key.startsWith('plugin_'))\n .forEach((result) => {\n exportData.push({\n key: result.key,\n value: result.value,\n type: result.type,\n environment: result.environment,\n tag: result.tag,\n });\n });\n }\n\n const str = JSON.stringify(exportData, null, pretty ? 2 : undefined);\n\n output.write(str);\n output.write('\\n');\n output.end();\n\n // log success only when writting to file\n if (filePath) {\n console.log(`Successfully exported ${exportData.length} configuration entries`);\n }\n process.exit(0);\n};\n\n/**\n * `$ strapi configuration:dump`\n */\nconst command: StrapiCommand = () => {\n return createCommand('configuration:dump')\n .alias('config:dump')\n .description('Dump configurations of your application')\n .option('-f, --file <file>', 'Output file, default output is stdout')\n .option('-p, --pretty', 'Format the output JSON with indentation and line breaks', false)\n .action(runAction('configuration:dump', action));\n};\n\nexport { action, command };\n"],"names":[],"mappings":";;;;AAyBA,MAAM,aAAa;AAMnB,MAAM,SAAS,OAAO,EAAE,MAAM,UAAU,aAAyB;AAC/D,QAAM,SAAiB,WAAW,GAAG,kBAAkB,QAAQ,IAAI,QAAQ;AAErE,QAAA,aAAa,MAAM,cAAc;AACvC,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,KAAK;AAEhD,QAAM,QAAQ,MAAM,IAAI,MAAM,oBAAoB,EAAE,MAAM;AAE1D,QAAM,aAA2B,CAAC;AAElC,QAAM,YAAY,KAAK,KAAK,QAAQ,UAAU;AAE9C,WAAS,OAAO,GAAG,OAAO,WAAW,QAAQ,GAAG;AAC9C,UAAM,UAAU,MAAM,IACnB,MAAM,oBAAoB,EAC1B,SAAS,EAAE,OAAO,YAAY,QAAQ,OAAO,YAAY,SAAS,OAAO;AAGzE,YAAA,OAAO,CAAC,WAAW,OAAO,IAAI,WAAW,SAAS,CAAC,EACnD,QAAQ,CAAC,WAAW;AACnB,iBAAW,KAAK;AAAA,QACd,KAAK,OAAO;AAAA,QACZ,OAAO,OAAO;AAAA,QACd,MAAM,OAAO;AAAA,QACb,aAAa,OAAO;AAAA,QACpB,KAAK,OAAO;AAAA,MAAA,CACb;AAAA,IAAA,CACF;AAAA,EAAA;AAGL,QAAM,MAAM,KAAK,UAAU,YAAY,MAAM,SAAS,IAAI,MAAS;AAEnE,SAAO,MAAM,GAAG;AAChB,SAAO,MAAM,IAAI;AACjB,SAAO,IAAI;AAGX,MAAI,UAAU;AACZ,YAAQ,IAAI,yBAAyB,WAAW,MAAM,wBAAwB;AAAA,EAAA;AAEhF,UAAQ,KAAK,CAAC;AAChB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,oBAAoB,EACtC,MAAM,aAAa,EACnB,YAAY,yCAAyC,EACrD,OAAO,qBAAqB,uCAAuC,EACnE,OAAO,gBAAgB,2DAA2D,KAAK,EACvF,OAAO,UAAU,sBAAsB,MAAM,CAAC;AACnD;"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const commander = require("commander");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
const core = require("@strapi/core");
|
|
7
|
-
const helpers = require("../../utils/helpers.js");
|
|
8
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
-
const fs__default = /* @__PURE__ */ _interopDefault(fs);
|
|
10
|
-
const ___default = /* @__PURE__ */ _interopDefault(_);
|
|
11
|
-
const action = async ({ file: filePath, strategy = "replace" }) => {
|
|
12
|
-
const input = filePath ? fs__default.default.readFileSync(filePath) : await readStdin();
|
|
13
|
-
const appContext = await core.compileStrapi();
|
|
14
|
-
const app = await core.createStrapi(appContext).load();
|
|
15
|
-
let dataToImport;
|
|
16
|
-
try {
|
|
17
|
-
dataToImport = JSON.parse(___default.default.toString(input));
|
|
18
|
-
} catch (error) {
|
|
19
|
-
if (error instanceof Error) {
|
|
20
|
-
throw new Error(`Invalid input data: ${error.message}. Expected a valid JSON array.`);
|
|
21
|
-
}
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
if (!Array.isArray(dataToImport)) {
|
|
25
|
-
throw new Error(`Invalid input data. Expected a valid JSON array.`);
|
|
26
|
-
}
|
|
27
|
-
if (!app.db) {
|
|
28
|
-
throw new Error("Cannot import configuration without a database connection.");
|
|
29
|
-
}
|
|
30
|
-
const importer = createImporter(app.db, strategy);
|
|
31
|
-
for (const config of dataToImport) {
|
|
32
|
-
await importer.import(config);
|
|
33
|
-
}
|
|
34
|
-
console.log(
|
|
35
|
-
`Successfully imported configuration with ${strategy} strategy. Statistics: ${importer.printStatistics()}.`
|
|
36
|
-
);
|
|
37
|
-
process.exit(0);
|
|
38
|
-
};
|
|
39
|
-
const readStdin = () => {
|
|
40
|
-
const { stdin } = process;
|
|
41
|
-
let result = "";
|
|
42
|
-
if (stdin.isTTY) return Promise.resolve(result);
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
stdin.setEncoding("utf8");
|
|
45
|
-
stdin.on("readable", () => {
|
|
46
|
-
let chunk;
|
|
47
|
-
while (chunk = stdin.read()) {
|
|
48
|
-
result += chunk;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
stdin.on("end", () => {
|
|
52
|
-
resolve(result);
|
|
53
|
-
});
|
|
54
|
-
stdin.on("error", reject);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const createImporter = (db, strategy) => {
|
|
58
|
-
switch (strategy) {
|
|
59
|
-
case "replace":
|
|
60
|
-
return createReplaceImporter(db);
|
|
61
|
-
case "merge":
|
|
62
|
-
return createMergeImporter(db);
|
|
63
|
-
case "keep":
|
|
64
|
-
return createKeepImporter(db);
|
|
65
|
-
default:
|
|
66
|
-
throw new Error(`No importer available for strategy "${strategy}"`);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const createReplaceImporter = (db) => {
|
|
70
|
-
const stats = {
|
|
71
|
-
created: 0,
|
|
72
|
-
replaced: 0
|
|
73
|
-
};
|
|
74
|
-
return {
|
|
75
|
-
printStatistics() {
|
|
76
|
-
return `${stats.created} created, ${stats.replaced} replaced`;
|
|
77
|
-
},
|
|
78
|
-
async import(conf) {
|
|
79
|
-
const matching = await db.query("strapi::core-store").count({ where: { key: conf.key } });
|
|
80
|
-
if (matching > 0) {
|
|
81
|
-
stats.replaced += 1;
|
|
82
|
-
await db.query("strapi::core-store").update({
|
|
83
|
-
where: { key: conf.key },
|
|
84
|
-
data: conf
|
|
85
|
-
});
|
|
86
|
-
} else {
|
|
87
|
-
stats.created += 1;
|
|
88
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
const createMergeImporter = (db) => {
|
|
94
|
-
const stats = {
|
|
95
|
-
created: 0,
|
|
96
|
-
merged: 0
|
|
97
|
-
};
|
|
98
|
-
return {
|
|
99
|
-
printStatistics() {
|
|
100
|
-
return `${stats.created} created, ${stats.merged} merged`;
|
|
101
|
-
},
|
|
102
|
-
async import(conf) {
|
|
103
|
-
const existingConf = await db.query("strapi::core-store").findOne({ where: { key: conf.key } });
|
|
104
|
-
if (existingConf) {
|
|
105
|
-
stats.merged += 1;
|
|
106
|
-
await db.query("strapi::core-store").update({
|
|
107
|
-
where: { key: conf.key },
|
|
108
|
-
data: ___default.default.merge(existingConf, conf)
|
|
109
|
-
});
|
|
110
|
-
} else {
|
|
111
|
-
stats.created += 1;
|
|
112
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
const createKeepImporter = (db) => {
|
|
118
|
-
const stats = {
|
|
119
|
-
created: 0,
|
|
120
|
-
untouched: 0
|
|
121
|
-
};
|
|
122
|
-
return {
|
|
123
|
-
printStatistics() {
|
|
124
|
-
return `${stats.created} created, ${stats.untouched} untouched`;
|
|
125
|
-
},
|
|
126
|
-
async import(conf) {
|
|
127
|
-
const matching = await db.query("strapi::core-store").count({ where: { key: conf.key } });
|
|
128
|
-
if (matching > 0) {
|
|
129
|
-
stats.untouched += 1;
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
stats.created += 1;
|
|
133
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
const command = () => {
|
|
138
|
-
return commander.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(helpers.runAction("configuration:restore", action));
|
|
139
|
-
};
|
|
140
|
-
exports.action = action;
|
|
141
|
-
exports.command = command;
|
|
142
|
-
//# sourceMappingURL=restore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"restore.js","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":["fs","compileStrapi","createStrapi","_","createCommand","runAction"],"mappings":";;;;;;;;;;AAmBA,MAAM,SAAS,OAAO,EAAE,MAAM,UAAU,WAAW,gBAA4B;AAC7E,QAAM,QAAQ,WAAWA,YAAA,QAAG,aAAa,QAAQ,IAAI,MAAM,UAAU;AAE/D,QAAA,aAAa,MAAMC,mBAAc;AACvC,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,KAAK;AAE5C,MAAA;AACA,MAAA;AACF,mBAAe,KAAK,MAAMC,WAAE,QAAA,SAAS,KAAK,CAAC;AAAA,WACpC,OAAO;AACd,QAAI,iBAAiB,OAAO;AAC1B,YAAM,IAAI,MAAM,uBAAuB,MAAM,OAAO,gCAAgC;AAAA,IAAA;AAGhF,UAAA;AAAA,EAAA;AAGR,MAAI,CAAC,MAAM,QAAQ,YAAY,GAAG;AAC1B,UAAA,IAAI,MAAM,kDAAkD;AAAA,EAAA;AAGhE,MAAA,CAAC,IAAI,IAAI;AACL,UAAA,IAAI,MAAM,4DAA4D;AAAA,EAAA;AAG9E,QAAM,WAAW,eAAe,IAAI,IAAI,QAAQ;AAEhD,aAAW,UAAU,cAAc;AAC3B,UAAA,SAAS,OAAO,MAAM;AAAA,EAAA;AAGtB,UAAA;AAAA,IACN,4CAA4C,QAAQ,0BAA0B,SAAS,gBAAiB,CAAA;AAAA,EAC1G;AAEA,UAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,YAAY,MAAM;AAChB,QAAA,EAAE,UAAU;AAClB,MAAI,SAAS;AAEb,MAAI,MAAM,MAAc,QAAA,QAAQ,QAAQ,MAAM;AAE9C,SAAO,IAAI,QAA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D,EACvF,OAAOC,QAAA,UAAU,yBAAyB,MAAM,CAAC;AACtD;;;"}
|
|
@@ -1,139 +0,0 @@
|
|
|
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
|
-
const action = async ({ file: filePath, strategy = "replace" }) => {
|
|
7
|
-
const input = filePath ? fs.readFileSync(filePath) : await readStdin();
|
|
8
|
-
const appContext = await compileStrapi();
|
|
9
|
-
const app = await createStrapi(appContext).load();
|
|
10
|
-
let dataToImport;
|
|
11
|
-
try {
|
|
12
|
-
dataToImport = JSON.parse(_.toString(input));
|
|
13
|
-
} catch (error) {
|
|
14
|
-
if (error instanceof Error) {
|
|
15
|
-
throw new Error(`Invalid input data: ${error.message}. Expected a valid JSON array.`);
|
|
16
|
-
}
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
if (!Array.isArray(dataToImport)) {
|
|
20
|
-
throw new Error(`Invalid input data. Expected a valid JSON array.`);
|
|
21
|
-
}
|
|
22
|
-
if (!app.db) {
|
|
23
|
-
throw new Error("Cannot import configuration without a database connection.");
|
|
24
|
-
}
|
|
25
|
-
const importer = createImporter(app.db, strategy);
|
|
26
|
-
for (const config of dataToImport) {
|
|
27
|
-
await importer.import(config);
|
|
28
|
-
}
|
|
29
|
-
console.log(
|
|
30
|
-
`Successfully imported configuration with ${strategy} strategy. Statistics: ${importer.printStatistics()}.`
|
|
31
|
-
);
|
|
32
|
-
process.exit(0);
|
|
33
|
-
};
|
|
34
|
-
const readStdin = () => {
|
|
35
|
-
const { stdin } = process;
|
|
36
|
-
let result = "";
|
|
37
|
-
if (stdin.isTTY) return Promise.resolve(result);
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
stdin.setEncoding("utf8");
|
|
40
|
-
stdin.on("readable", () => {
|
|
41
|
-
let chunk;
|
|
42
|
-
while (chunk = stdin.read()) {
|
|
43
|
-
result += chunk;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
stdin.on("end", () => {
|
|
47
|
-
resolve(result);
|
|
48
|
-
});
|
|
49
|
-
stdin.on("error", reject);
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
const createImporter = (db, strategy) => {
|
|
53
|
-
switch (strategy) {
|
|
54
|
-
case "replace":
|
|
55
|
-
return createReplaceImporter(db);
|
|
56
|
-
case "merge":
|
|
57
|
-
return createMergeImporter(db);
|
|
58
|
-
case "keep":
|
|
59
|
-
return createKeepImporter(db);
|
|
60
|
-
default:
|
|
61
|
-
throw new Error(`No importer available for strategy "${strategy}"`);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const createReplaceImporter = (db) => {
|
|
65
|
-
const stats = {
|
|
66
|
-
created: 0,
|
|
67
|
-
replaced: 0
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
printStatistics() {
|
|
71
|
-
return `${stats.created} created, ${stats.replaced} replaced`;
|
|
72
|
-
},
|
|
73
|
-
async import(conf) {
|
|
74
|
-
const matching = await db.query("strapi::core-store").count({ where: { key: conf.key } });
|
|
75
|
-
if (matching > 0) {
|
|
76
|
-
stats.replaced += 1;
|
|
77
|
-
await db.query("strapi::core-store").update({
|
|
78
|
-
where: { key: conf.key },
|
|
79
|
-
data: conf
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
stats.created += 1;
|
|
83
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
const createMergeImporter = (db) => {
|
|
89
|
-
const stats = {
|
|
90
|
-
created: 0,
|
|
91
|
-
merged: 0
|
|
92
|
-
};
|
|
93
|
-
return {
|
|
94
|
-
printStatistics() {
|
|
95
|
-
return `${stats.created} created, ${stats.merged} merged`;
|
|
96
|
-
},
|
|
97
|
-
async import(conf) {
|
|
98
|
-
const existingConf = await db.query("strapi::core-store").findOne({ where: { key: conf.key } });
|
|
99
|
-
if (existingConf) {
|
|
100
|
-
stats.merged += 1;
|
|
101
|
-
await db.query("strapi::core-store").update({
|
|
102
|
-
where: { key: conf.key },
|
|
103
|
-
data: _.merge(existingConf, conf)
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
stats.created += 1;
|
|
107
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const createKeepImporter = (db) => {
|
|
113
|
-
const stats = {
|
|
114
|
-
created: 0,
|
|
115
|
-
untouched: 0
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
printStatistics() {
|
|
119
|
-
return `${stats.created} created, ${stats.untouched} untouched`;
|
|
120
|
-
},
|
|
121
|
-
async import(conf) {
|
|
122
|
-
const matching = await db.query("strapi::core-store").count({ where: { key: conf.key } });
|
|
123
|
-
if (matching > 0) {
|
|
124
|
-
stats.untouched += 1;
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
stats.created += 1;
|
|
128
|
-
await db.query("strapi::core-store").create({ data: conf });
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
const command = () => {
|
|
133
|
-
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));
|
|
134
|
-
};
|
|
135
|
-
export {
|
|
136
|
-
action,
|
|
137
|
-
command
|
|
138
|
-
};
|
|
139
|
-
//# sourceMappingURL=restore.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[],"mappings":";;;;;AAmBA,MAAM,SAAS,OAA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,oBAAoB,EAAE,OAAO;AAAA,UAC1C,OAAO,EAAE,KAAK,KAAK,IAAI;AAAA,UACvB,MAAM,EAAE,MAAM,cAAc,IAAI;AAAA,QAAA,CACjC;AAAA,MAAA,OACI;AACL,cAAM,WAAW;AACX,cAAA,GAAG,MAAM,oBAAoB,EAAE,OAAO,EAAE,MAAM,MAAM;AAAA,MAAA;AAAA,IAC5D;AAAA,EAEJ;AACF;AAKA,MAAM,qBAAqB,CAAC,OAAiB;AAC3C,QAAM,QAAQ;AAAA,IACZ,SAAS;AAAA,IACT,WAAW;AAAA,EACb;AAEO,SAAA;AAAA,IACL,kBAAkB;AAChB,aAAO,GAAG,MAAM,OAAO,aAAa,MAAM,SAAS;AAAA,IACrD;AAAA,IAEA,MAAM,OAAO,MAA+B;AAC1C,YAAM,WAAW,MAAM,GAAG,MAAM,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,KAAK,OAAO;AACxF,UAAI,WAAW,GAAG;AAChB,cAAM,aAAa;AAEnB;AAAA,MAAA;AAGF,YAAM,WAAW;AACX,YAAA,GAAG,MAAM,oBAAoB,EAAE,OAAO,EAAE,MAAM,MAAM;AAAA,IAAA;AAAA,EAE9D;AACF;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,uBAAuB,EACzC,MAAM,gBAAgB,EACtB,YAAY,4CAA4C,EACxD,OAAO,qBAAqB,oCAAoC,EAChE,OAAO,6BAA6B,mDAAmD,EACvF,OAAO,UAAU,yBAAyB,MAAM,CAAC;AACtD;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const REPL = require("repl");
|
|
4
|
-
const commander = require("commander");
|
|
5
|
-
const core = require("@strapi/core");
|
|
6
|
-
const helpers = require("../utils/helpers.js");
|
|
7
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
|
-
const REPL__default = /* @__PURE__ */ _interopDefault(REPL);
|
|
9
|
-
const action = async () => {
|
|
10
|
-
const appContext = await core.compileStrapi();
|
|
11
|
-
const app = await core.createStrapi(appContext).load();
|
|
12
|
-
app.start().then(() => {
|
|
13
|
-
const repl = REPL__default.default.start(app.config.info.name + " > " || "strapi > ");
|
|
14
|
-
repl.on("exit", (err) => {
|
|
15
|
-
if (err) {
|
|
16
|
-
app.log.error(err);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
app.server.destroy();
|
|
20
|
-
process.exit(0);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
const command = () => {
|
|
25
|
-
return commander.createCommand("console").description("Open the Strapi framework console").action(helpers.runAction("console", action));
|
|
26
|
-
};
|
|
27
|
-
exports.action = action;
|
|
28
|
-
exports.command = command;
|
|
29
|
-
//# sourceMappingURL=console.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":["compileStrapi","createStrapi","REPL","createCommand","runAction"],"mappings":";;;;;;;;AAOA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,mBAAc;AACvC,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,KAAK;AAE5C,MAAA,QAAQ,KAAK,MAAM;AACf,UAAA,OAAOC,sBAAK,MAAM,IAAI,OAAO,KAAK,OAAO,SAAS,WAAW;AAE9D,SAAA,GAAG,QAAQ,CAAC,QAAe;AAC9B,UAAI,KAAK;AACH,YAAA,IAAI,MAAM,GAAG;AACjB,gBAAQ,KAAK,CAAC;AAAA,MAAA;AAGhB,UAAI,OAAO,QAAQ;AACnB,cAAQ,KAAK,CAAC;AAAA,IAAA,CACf;AAAA,EAAA,CACF;AACH;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,UAAA,cAAc,SAAS,EAC3B,YAAY,mCAAmC,EAC/C,OAAOC,QAAA,UAAU,WAAW,MAAM,CAAC;AACxC;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
const action = async () => {
|
|
6
|
-
const appContext = await compileStrapi();
|
|
7
|
-
const app = await createStrapi(appContext).load();
|
|
8
|
-
app.start().then(() => {
|
|
9
|
-
const repl = REPL.start(app.config.info.name + " > " || "strapi > ");
|
|
10
|
-
repl.on("exit", (err) => {
|
|
11
|
-
if (err) {
|
|
12
|
-
app.log.error(err);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
app.server.destroy();
|
|
16
|
-
process.exit(0);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
const command = () => {
|
|
21
|
-
return createCommand("console").description("Open the Strapi framework console").action(runAction("console", action));
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
action,
|
|
25
|
-
command
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=console.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[],"mappings":";;;;AAOA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAM,cAAc;AACvC,QAAM,MAAM,MAAM,aAAa,UAAU,EAAE,KAAK;AAE5C,MAAA,QAAQ,KAAK,MAAM;AACf,UAAA,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,OAAO,SAAS,WAAW;AAE9D,SAAA,GAAG,QAAQ,CAAC,QAAe;AAC9B,UAAI,KAAK;AACH,YAAA,IAAI,MAAM,GAAG;AACjB,gBAAQ,KAAK,CAAC;AAAA,MAAA;AAGhB,UAAI,OAAO,QAAQ;AACnB,cAAQ,KAAK,CAAC;AAAA,IAAA,CACf;AAAA,EAAA,CACF;AACH;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAA,cAAc,SAAS,EAC3B,YAAY,mCAAmC,EAC/C,OAAO,UAAU,WAAW,MAAM,CAAC;AACxC;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const commander = require("commander");
|
|
4
|
-
const CLITable = require("cli-table3");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
|
-
const core = require("@strapi/core");
|
|
7
|
-
const helpers = require("../../utils/helpers.js");
|
|
8
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
-
const CLITable__default = /* @__PURE__ */ _interopDefault(CLITable);
|
|
10
|
-
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
11
|
-
const action = async () => {
|
|
12
|
-
const appContext = await core.compileStrapi();
|
|
13
|
-
const app = await core.createStrapi(appContext).register();
|
|
14
|
-
const list = app.get("content-types").keys();
|
|
15
|
-
const infoTable = new CLITable__default.default({
|
|
16
|
-
head: [chalk__default.default.blue("Name")]
|
|
17
|
-
});
|
|
18
|
-
list.forEach((name) => infoTable.push([name]));
|
|
19
|
-
console.log(infoTable.toString());
|
|
20
|
-
await app.destroy();
|
|
21
|
-
};
|
|
22
|
-
const command = () => {
|
|
23
|
-
return commander.createCommand("content-types:list").description("List all the application content-types").action(helpers.runAction("content-types:list", action));
|
|
24
|
-
};
|
|
25
|
-
exports.action = action;
|
|
26
|
-
exports.command = command;
|
|
27
|
-
//# sourceMappingURL=list.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":["compileStrapi","createStrapi","CLITable","chalk","createCommand","runAction"],"mappings":";;;;;;;;;;AASA,MAAM,SAAS,YAAY;AACnB,QAAA,aAAa,MAAMA,mBAAc;AACvC,QAAM,MAAM,MAAMC,KAAAA,aAAa,UAAU,EAAE,SAAS;AAEpD,QAAM,OAAO,IAAI,IAAI,eAAe,EAAE,KAAK;AAErC,QAAA,YAAY,IAAIC,0BAAS;AAAA,IAC7B,MAAM,CAACC,eAAAA,QAAM,KAAK,MAAM,CAAC;AAAA,EAAA,CAC1B;AAEI,OAAA,QAAQ,CAAC,SAAiB,UAAU,KAAK,CAAC,IAAI,CAAC,CAAC;AAE7C,UAAA,IAAI,UAAU,UAAU;AAEhC,QAAM,IAAI,QAAQ;AACpB;AAKA,MAAM,UAAyB,MAAM;AAC5B,SAAAC,UAAA,cAAc,oBAAoB,EACtC,YAAY,wCAAwC,EACpD,OAAOC,QAAA,UAAU,sBAAsB,MAAM,CAAC;AACnD;;;"}
|