@strapi/strapi 4.16.2 → 4.18.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/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +2 -1
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +2 -1
- package/dist/Strapi.mjs.map +1 -1
- package/dist/admin.d.ts +2 -2
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs.map +1 -1
- package/dist/commands/actions/plugin/build-command/action.d.ts +2 -1
- package/dist/commands/actions/plugin/build-command/action.d.ts.map +1 -1
- package/dist/commands/actions/plugin/build-command/action.js +3 -6
- package/dist/commands/actions/plugin/build-command/action.js.map +1 -1
- package/dist/commands/actions/plugin/build-command/command.js +2 -2
- package/dist/commands/actions/plugin/build-command/command.js.map +1 -1
- package/dist/commands/actions/plugin/init/action.d.ts +7 -0
- package/dist/commands/actions/plugin/init/action.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/action.js +418 -0
- package/dist/commands/actions/plugin/init/action.js.map +1 -0
- package/dist/commands/actions/plugin/init/command.d.ts +7 -0
- package/dist/commands/actions/plugin/init/command.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/command.js +9 -0
- package/dist/commands/actions/plugin/init/command.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/admin.d.ts +5 -0
- package/dist/commands/actions/plugin/init/files/admin.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/admin.js +283 -0
- package/dist/commands/actions/plugin/init/files/admin.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/editorConfig.d.ts +4 -0
- package/dist/commands/actions/plugin/init/files/editorConfig.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/editorConfig.js +26 -0
- package/dist/commands/actions/plugin/init/files/editorConfig.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/eslint.d.ts +4 -0
- package/dist/commands/actions/plugin/init/files/eslint.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/eslint.js +11 -0
- package/dist/commands/actions/plugin/init/files/eslint.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/gitIgnore.d.ts +4 -0
- package/dist/commands/actions/plugin/init/files/gitIgnore.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/gitIgnore.js +34 -0
- package/dist/commands/actions/plugin/init/files/gitIgnore.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/prettier.d.ts +5 -0
- package/dist/commands/actions/plugin/init/files/prettier.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/prettier.js +25 -0
- package/dist/commands/actions/plugin/init/files/prettier.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/server.d.ts +5 -0
- package/dist/commands/actions/plugin/init/files/server.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/server.js +360 -0
- package/dist/commands/actions/plugin/init/files/server.js.map +1 -0
- package/dist/commands/actions/plugin/init/files/typescript.d.ts +9 -0
- package/dist/commands/actions/plugin/init/files/typescript.d.ts.map +1 -0
- package/dist/commands/actions/plugin/init/files/typescript.js +66 -0
- package/dist/commands/actions/plugin/init/files/typescript.js.map +1 -0
- package/dist/commands/actions/plugin/link-watch/action.d.ts +6 -0
- package/dist/commands/actions/plugin/link-watch/action.d.ts.map +1 -0
- package/dist/commands/actions/plugin/link-watch/action.js +86 -0
- package/dist/commands/actions/plugin/link-watch/action.js.map +1 -0
- package/dist/commands/actions/plugin/link-watch/command.d.ts +7 -0
- package/dist/commands/actions/plugin/link-watch/command.d.ts.map +1 -0
- package/dist/commands/actions/plugin/link-watch/command.js +8 -0
- package/dist/commands/actions/plugin/link-watch/command.js.map +1 -0
- package/dist/commands/actions/plugin/verify/action.d.ts +7 -0
- package/dist/commands/actions/plugin/verify/action.d.ts.map +1 -0
- package/dist/commands/actions/plugin/verify/action.js +34 -0
- package/dist/commands/actions/plugin/verify/action.js.map +1 -0
- package/dist/commands/actions/plugin/verify/command.d.ts +7 -0
- package/dist/commands/actions/plugin/verify/command.d.ts.map +1 -0
- package/dist/commands/actions/plugin/verify/command.js +8 -0
- package/dist/commands/actions/plugin/verify/command.js.map +1 -0
- package/dist/commands/actions/plugin/watch/action.d.ts +2 -2
- package/dist/commands/actions/plugin/watch/action.d.ts.map +1 -1
- package/dist/commands/actions/plugin/watch/action.js +4 -7
- package/dist/commands/actions/plugin/watch/action.js.map +1 -1
- package/dist/commands/actions/plugin/watch/command.d.ts +1 -1
- package/dist/commands/actions/plugin/watch/command.js +2 -2
- package/dist/commands/actions/plugin/watch/command.js.map +1 -1
- package/dist/commands/actions/watch-admin/action.d.ts +2 -2
- package/dist/commands/actions/watch-admin/action.d.ts.map +1 -1
- package/dist/commands/actions/watch-admin/action.js +1 -1
- package/dist/commands/actions/watch-admin/action.js.map +1 -1
- package/dist/commands/actions/watch-admin/command.js +2 -2
- package/dist/commands/actions/watch-admin/command.js.map +1 -1
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +8 -2
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/utils/logger.js.map +1 -1
- package/dist/commands/utils/pkg.d.ts +2 -0
- package/dist/commands/utils/pkg.d.ts.map +1 -1
- package/dist/commands/utils/pkg.js +1 -0
- package/dist/commands/utils/pkg.js.map +1 -1
- package/dist/factories.js +2 -2
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +2 -2
- package/dist/factories.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +10 -0
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +10 -0
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/utils/startup-logger.js.map +1 -1
- package/package.json +27 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/verify/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAOd,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const helpers = require("../../../utils/helpers.js");
|
|
3
|
+
const action = require("./action.js");
|
|
4
|
+
const command = ({ command: command2, ctx }) => {
|
|
5
|
+
command2.command("plugin:verify").description("Verify the output of your plugin before publishing it.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => helpers.runAction("plugin:verify", action)(...args, ctx));
|
|
6
|
+
};
|
|
7
|
+
module.exports = command;
|
|
8
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sources":["../../../../../src/commands/actions/plugin/verify/command.ts"],"sourcesContent":["import type { StrapiCommand } from '../../../types';\nimport { runAction } from '../../../utils/helpers';\nimport action from './action';\n\n/**\n * `$ strapi plugin:verify`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:verify')\n .description('Verify the output of your plugin before publishing it.')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .action((...args) => runAction('plugin:verify', action)(...args, ctx));\n};\n\nexport default command;\n"],"names":["command","runAction"],"mappings":";;;AAOA,MAAM,UAAyB,CAAC,EAAE,SAAAA,UAAS,UAAU;AACnDA,WACG,QAAQ,eAAe,EACvB,YAAY,wDAAwD,EACpE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAASC,QAAAA,UAAU,iBAAiB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACzE;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WatchCLIOptions } from '@strapi/pack-up';
|
|
2
|
+
import { CLIContext } from '../../../types';
|
|
2
3
|
interface ActionOptions extends WatchCLIOptions {
|
|
3
|
-
force?: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: ({
|
|
5
|
+
declare const _default: (opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => Promise<void>;
|
|
6
6
|
export default _default;
|
|
7
7
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/watch/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,eAAe,EAAS,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../src/commands/actions/plugin/watch/action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,eAAe,EAAS,MAAM,iBAAiB,CAAC;AAGvE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,UAAU,aAAc,SAAQ,eAAe;CAAG;+BAEtB,aAAa,QAAQ,OAAO,mBAAmB,UAAU;AAArF,wBAuFE"}
|
|
@@ -3,17 +3,14 @@ const boxen = require("boxen");
|
|
|
3
3
|
const chalk = require("chalk");
|
|
4
4
|
const packUp = require("@strapi/pack-up");
|
|
5
5
|
const helpers = require("../../../utils/helpers.js");
|
|
6
|
-
const logger = require("../../../utils/logger.js");
|
|
7
6
|
const pkg = require("../../../utils/pkg.js");
|
|
8
7
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
8
|
const boxen__default = /* @__PURE__ */ _interopDefault(boxen);
|
|
10
9
|
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
11
|
-
const action = async ({
|
|
12
|
-
const logger$1 = logger.createLogger({ debug: opts.debug, silent: opts.silent, timestamp: false });
|
|
10
|
+
const action = async (opts, _cmd, { cwd, logger }) => {
|
|
13
11
|
try {
|
|
14
|
-
await helpers.notifyExperimentalCommand("plugin:watch", { force });
|
|
15
|
-
const
|
|
16
|
-
const pkg$1 = await pkg.loadPkg({ cwd, logger: logger$1 });
|
|
12
|
+
await helpers.notifyExperimentalCommand("plugin:watch", { force: true });
|
|
13
|
+
const pkg$1 = await pkg.loadPkg({ cwd, logger });
|
|
17
14
|
const pkgJson = await pkg.validatePkg({ pkg: pkg$1 });
|
|
18
15
|
if (!pkgJson.exports["./strapi-admin"] && !pkgJson.exports["./strapi-server"]) {
|
|
19
16
|
throw new Error(
|
|
@@ -65,7 +62,7 @@ const action = async ({ force, ...opts }) => {
|
|
|
65
62
|
...opts
|
|
66
63
|
});
|
|
67
64
|
} catch (err) {
|
|
68
|
-
logger
|
|
65
|
+
logger.error(
|
|
69
66
|
"There seems to be an unexpected error, try again with --debug for more information \n"
|
|
70
67
|
);
|
|
71
68
|
if (err instanceof Error && err.stack) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sources":["../../../../../src/commands/actions/plugin/watch/action.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { ConfigBundle, WatchCLIOptions, watch } from '@strapi/pack-up';\nimport { notifyExperimentalCommand } from '../../../utils/helpers';\nimport {
|
|
1
|
+
{"version":3,"file":"action.js","sources":["../../../../../src/commands/actions/plugin/watch/action.ts"],"sourcesContent":["import boxen from 'boxen';\nimport chalk from 'chalk';\nimport { ConfigBundle, WatchCLIOptions, watch } from '@strapi/pack-up';\nimport { notifyExperimentalCommand } from '../../../utils/helpers';\nimport { Export, loadPkg, validatePkg } from '../../../utils/pkg';\nimport { CLIContext } from '../../../types';\n\ninterface ActionOptions extends WatchCLIOptions {}\n\nexport default async (opts: ActionOptions, _cmd: unknown, { cwd, logger }: CLIContext) => {\n try {\n /**\n * Notify users this is an experimental command.\n */\n await notifyExperimentalCommand('plugin:watch', { force: true });\n\n const pkg = await loadPkg({ cwd, logger });\n const pkgJson = await validatePkg({ pkg });\n\n if (!pkgJson.exports['./strapi-admin'] && !pkgJson.exports['./strapi-server']) {\n throw new Error(\n 'You need to have either a strapi-admin or strapi-server export in your package.json'\n );\n }\n\n const bundles: ConfigBundle[] = [];\n\n if (pkgJson.exports['./strapi-admin']) {\n const exp = pkgJson.exports['./strapi-admin'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'web',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './admin/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n if (pkgJson.exports['./strapi-server']) {\n const exp = pkgJson.exports['./strapi-server'] as Export;\n\n const bundle: ConfigBundle = {\n source: exp.source,\n import: exp.import,\n require: exp.require,\n runtime: 'node',\n };\n\n if (exp.types) {\n bundle.types = exp.types;\n // TODO: should this be sliced from the source path...?\n bundle.tsconfig = './server/tsconfig.build.json';\n }\n\n bundles.push(bundle);\n }\n\n await watch({\n cwd,\n configFile: false,\n config: {\n bundles,\n dist: './dist',\n /**\n * ignore the exports map of a plugin, because we're streamlining the\n * process and ensuring the server package and admin package are built\n * with the correct runtime and their individual tsconfigs\n */\n exports: {},\n },\n ...opts,\n });\n } catch (err) {\n logger.error(\n 'There seems to be an unexpected error, try again with --debug for more information \\n'\n );\n if (err instanceof Error && err.stack) {\n console.log(\n chalk.red(\n boxen(err.stack, {\n padding: 1,\n align: 'left',\n })\n )\n );\n }\n process.exit(1);\n }\n};\n"],"names":["notifyExperimentalCommand","pkg","loadPkg","validatePkg","watch","chalk","boxen"],"mappings":";;;;;;;;;AASA,MAAe,SAAA,OAAO,MAAqB,MAAe,EAAE,KAAK,aAAyB;AACpF,MAAA;AAIF,UAAMA,QAA0B,0BAAA,gBAAgB,EAAE,OAAO,KAAM,CAAA;AAE/D,UAAMC,QAAM,MAAMC,IAAA,QAAQ,EAAE,KAAK,OAAQ,CAAA;AACzC,UAAM,UAAU,MAAMC,IAAAA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AO;AAAA,UAAA,CACR;AAAA,QACH;AAAA,MAAA;AAAA,IAEJ;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const helpers = require("../../../utils/helpers.js");
|
|
3
3
|
const action = require("./action.js");
|
|
4
|
-
const command = ({ command: command2 }) => {
|
|
5
|
-
command2.command("plugin:watch").description("Watch & compile your strapi plugin for local development.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action(helpers.runAction("plugin:watch", action));
|
|
4
|
+
const command = ({ command: command2, ctx }) => {
|
|
5
|
+
command2.command("plugin:watch").description("Watch & compile your strapi plugin for local development.").option("-d, --debug", "Enable debugging mode with verbose logs", false).option("--silent", "Don't log anything", false).action((...args) => helpers.runAction("plugin:watch", action)(...args, ctx));
|
|
6
6
|
};
|
|
7
7
|
module.exports = command;
|
|
8
8
|
//# sourceMappingURL=command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sources":["../../../../../src/commands/actions/plugin/watch/command.ts"],"sourcesContent":["import type { StrapiCommand } from '../../../types';\nimport { runAction } from '../../../utils/helpers';\nimport action from './action';\n\n/**\n * `$ strapi plugin:
|
|
1
|
+
{"version":3,"file":"command.js","sources":["../../../../../src/commands/actions/plugin/watch/command.ts"],"sourcesContent":["import type { StrapiCommand } from '../../../types';\nimport { runAction } from '../../../utils/helpers';\nimport action from './action';\n\n/**\n * `$ strapi plugin:watch`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('plugin:watch')\n .description('Watch & compile your strapi plugin for local development.')\n .option('-d, --debug', 'Enable debugging mode with verbose logs', false)\n .option('--silent', \"Don't log anything\", false)\n .action((...args) => runAction('plugin:watch', action)(...args, ctx));\n};\n\nexport default command;\n"],"names":["command","runAction"],"mappings":";;;AAOA,MAAM,UAAyB,CAAC,EAAE,SAAAA,UAAS,UAAU;AACnDA,WACG,QAAQ,cAAc,EACtB,YAAY,2DAA2D,EACvE,OAAO,eAAe,2CAA2C,KAAK,EACtE,OAAO,YAAY,sBAAsB,KAAK,EAC9C,OAAO,IAAI,SAASC,QAAAA,UAAU,gBAAgB,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACxE;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CLIContext } from '../../types';
|
|
2
|
-
interface WatchAdminOptions
|
|
2
|
+
interface WatchAdminOptions {
|
|
3
3
|
browser: boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: ({ browser, logger }:
|
|
5
|
+
declare const _default: ({ browser }: WatchAdminOptions, _cmd: unknown, { logger }: CLIContext) => Promise<void>;
|
|
6
6
|
export default _default;
|
|
7
7
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/commands/actions/watch-admin/action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,UAAU,
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/commands/actions/watch-admin/action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB;sCAEkC,iBAAiB,QAAQ,OAAO,cAAc,UAAU;AAA3F,wBAME"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const admin = require("@strapi/admin");
|
|
3
|
-
const action = async ({ browser, logger }) => {
|
|
3
|
+
const action = async ({ browser }, _cmd, { logger }) => {
|
|
4
4
|
logger.warn("[@strapi/strapi]: watch-admin is deprecated, please use strapi develop instead");
|
|
5
5
|
await admin.watchAdmin({
|
|
6
6
|
browser
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sources":["../../../../src/commands/actions/watch-admin/action.ts"],"sourcesContent":["import { watchAdmin } from '@strapi/admin';\nimport { CLIContext } from '../../types';\n\ninterface WatchAdminOptions
|
|
1
|
+
{"version":3,"file":"action.js","sources":["../../../../src/commands/actions/watch-admin/action.ts"],"sourcesContent":["import { watchAdmin } from '@strapi/admin';\nimport { CLIContext } from '../../types';\n\ninterface WatchAdminOptions {\n browser: boolean;\n}\n\nexport default async ({ browser }: WatchAdminOptions, _cmd: unknown, { logger }: CLIContext) => {\n logger.warn('[@strapi/strapi]: watch-admin is deprecated, please use strapi develop instead');\n\n await watchAdmin({\n browser,\n });\n};\n"],"names":["watchAdmin"],"mappings":";;AAOA,MAAe,SAAA,OAAO,EAAE,WAA8B,MAAe,EAAE,aAAyB;AAC9F,SAAO,KAAK,gFAAgF;AAE5F,QAAMA,iBAAW;AAAA,IACf;AAAA,EAAA,CACD;AACH;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const helpers = require("../../utils/helpers.js");
|
|
3
3
|
const action = require("./action.js");
|
|
4
|
-
const command = ({ command: command2 }) => {
|
|
5
|
-
command2.command("watch-admin").option("--browser <name>", "Open the browser", true).description("Start the admin development server").action(helpers.runAction("watch-admin", action));
|
|
4
|
+
const command = ({ command: command2, ctx }) => {
|
|
5
|
+
command2.command("watch-admin").option("--browser <name>", "Open the browser", true).description("Start the admin development server").action((...args) => helpers.runAction("watch-admin", action)(...args, ctx));
|
|
6
6
|
};
|
|
7
7
|
module.exports = command;
|
|
8
8
|
//# sourceMappingURL=command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sources":["../../../../src/commands/actions/watch-admin/command.ts"],"sourcesContent":["import type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport action from './action';\n/**\n * `$ strapi watch-admin`\n */\nconst command: StrapiCommand = ({ command }) => {\n command\n .command('watch-admin')\n .option('--browser <name>', 'Open the browser', true)\n .description('Start the admin development server')\n .action(runAction('watch-admin', action));\n};\nexport default command;\n"],"names":["command","runAction"],"mappings":";;;AAMA,MAAM,UAAyB,CAAC,EAAE,SAAAA,
|
|
1
|
+
{"version":3,"file":"command.js","sources":["../../../../src/commands/actions/watch-admin/command.ts"],"sourcesContent":["import type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport action from './action';\n/**\n * `$ strapi watch-admin`\n */\nconst command: StrapiCommand = ({ command, ctx }) => {\n command\n .command('watch-admin')\n .option('--browser <name>', 'Open the browser', true)\n .description('Start the admin development server')\n .action((...args) => runAction('watch-admin', action)(...args, ctx));\n};\nexport default command;\n"],"names":["command","runAction"],"mappings":";;;AAMA,MAAM,UAAyB,CAAC,EAAE,SAAAA,UAAS,UAAU;AACnDA,WACG,QAAQ,aAAa,EACrB,OAAO,oBAAoB,oBAAoB,IAAI,EACnD,YAAY,oCAAoC,EAChD,OAAO,IAAI,SAASC,QAAAA,UAAU,eAAe,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC;AACvE;;"}
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -29,7 +29,10 @@ declare const strapiCommands: {
|
|
|
29
29
|
* Plugins
|
|
30
30
|
*/
|
|
31
31
|
readonly buildPluginCommand: import("./types").StrapiCommand;
|
|
32
|
+
readonly initPluginCommand: import("./types").StrapiCommand;
|
|
33
|
+
readonly linkWatchPluginCommand: import("./types").StrapiCommand;
|
|
32
34
|
readonly watchPluginCommand: import("./types").StrapiCommand;
|
|
35
|
+
readonly verifyPluginCommand: import("./types").StrapiCommand;
|
|
33
36
|
};
|
|
34
37
|
declare const buildStrapiCommand: (argv: string[], command?: Command) => Promise<Command>;
|
|
35
38
|
declare const runStrapiCommand: (argv?: string[], command?: Command) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsCpC,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;IA0BlB;;OAEG;;;;;;CAMK,CAAC;AAEX,QAAA,MAAM,kBAAkB,SAAgB,MAAM,EAAE,wCAoD/C,CAAC;AAEF,QAAA,MAAM,gBAAgB,uDAGrB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -49,7 +49,10 @@ const command$m = require("./actions/uninstall/command.js");
|
|
|
49
49
|
const command$n = require("./actions/version/command.js");
|
|
50
50
|
const command$o = require("./actions/watch-admin/command.js");
|
|
51
51
|
const command$p = require("./actions/plugin/build-command/command.js");
|
|
52
|
-
const command$q = require("./actions/plugin/
|
|
52
|
+
const command$q = require("./actions/plugin/init/command.js");
|
|
53
|
+
const command$r = require("./actions/plugin/link-watch/command.js");
|
|
54
|
+
const command$s = require("./actions/plugin/watch/command.js");
|
|
55
|
+
const command$t = require("./actions/plugin/verify/command.js");
|
|
53
56
|
const logger = require("./utils/logger.js");
|
|
54
57
|
const tsconfig = require("./utils/tsconfig.js");
|
|
55
58
|
const strapiCommands = {
|
|
@@ -82,7 +85,10 @@ const strapiCommands = {
|
|
|
82
85
|
* Plugins
|
|
83
86
|
*/
|
|
84
87
|
buildPluginCommand: command$p,
|
|
85
|
-
|
|
88
|
+
initPluginCommand: command$q,
|
|
89
|
+
linkWatchPluginCommand: command$r,
|
|
90
|
+
watchPluginCommand: command$s,
|
|
91
|
+
verifyPluginCommand: command$t
|
|
86
92
|
};
|
|
87
93
|
const buildStrapiCommand = async (argv, command2 = new commander.Command()) => {
|
|
88
94
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/commands/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport createAdminUser from './actions/admin/create-user/command';\nimport resetAdminUserPassword from './actions/admin/reset-user-password/command';\nimport listComponents from './actions/components/list/command';\nimport configurationDump from './actions/configuration/dump/command';\nimport configurationRestore from './actions/configuration/restore/command';\nimport consoleCommand from './actions/console/command';\nimport listContentTypes from './actions/content-types/list/command';\nimport listControllers from './actions/controllers/list/command';\nimport generateCommand from './actions/generate/command';\nimport listHooks from './actions/hooks/list/command';\nimport installCommand from './actions/install/command';\nimport listMiddlewares from './actions/middlewares/list/command';\nimport newCommand from './actions/new/command';\nimport listPolicies from './actions/policies/list/command';\nimport reportCommand from './actions/report/command';\nimport listRoutes from './actions/routes/list/command';\nimport listServices from './actions/services/list/command';\nimport startCommand from './actions/start/command';\nimport disableTelemetry from './actions/telemetry/disable/command';\nimport enableTelemetry from './actions/telemetry/enable/command';\nimport generateTemplates from './actions/templates/generate/command';\nimport generateTsTypes from './actions/ts/generate-types/command';\nimport uninstallCommand from './actions/uninstall/command';\nimport versionCommand from './actions/version/command';\nimport watchAdminCommand from './actions/watch-admin/command';\n\nimport buildPluginCommand from './actions/plugin/build-command/command';\nimport watchPluginCommand from './actions/plugin/watch/command';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\n\nconst strapiCommands = {\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n installCommand,\n listMiddlewares,\n newCommand,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n uninstallCommand,\n versionCommand,\n watchAdminCommand,\n /**\n * Plugins\n */\n buildPluginCommand,\n watchPluginCommand,\n} as const;\n\nconst buildStrapiCommand = async (argv: string[], command = new Command()) => {\n try {\n // NOTE: this is a hack to allow loading dts commands without make dts a dependency of strapi and thus avoiding circular dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const dtsCommands = require(require.resolve('@strapi/data-transfer')).commands;\n Object.assign(strapiCommands, dtsCommands);\n // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require\n const adminCommands = require(require.resolve('@strapi/admin/cli')).commands;\n Object.assign(strapiCommands, adminCommands);\n } catch (e) {\n // noop\n }\n\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n const keys = Object.keys(strapiCommands) as (keyof typeof strapiCommands)[];\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n const tsconfig = loadTsConfig({\n cwd,\n path: 'tsconfig.json',\n logger,\n });\n\n const ctx = {\n cwd,\n logger,\n tsconfig,\n } satisfies CLIContext;\n\n // Load all commands\n keys.forEach((name) => {\n try {\n // Add this command to the Commander command object\n strapiCommands[name]({ command, argv, ctx });\n } catch (e) {\n console.error(`Failed to load command ${name}`, e);\n }\n });\n\n return command;\n};\n\nconst runStrapiCommand = async (argv = process.argv, command = new Command()) => {\n const commands = await buildStrapiCommand(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runStrapiCommand, buildStrapiCommand, strapiCommands };\n"],"names":["createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","installCommand","listMiddlewares","newCommand","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","uninstallCommand","versionCommand","watchAdminCommand","buildPluginCommand","watchPluginCommand","command","Command","logger","createLogger","tsconfig","loadTsConfig"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/commands/index.ts"],"sourcesContent":["import { Command } from 'commander';\n\nimport createAdminUser from './actions/admin/create-user/command';\nimport resetAdminUserPassword from './actions/admin/reset-user-password/command';\nimport listComponents from './actions/components/list/command';\nimport configurationDump from './actions/configuration/dump/command';\nimport configurationRestore from './actions/configuration/restore/command';\nimport consoleCommand from './actions/console/command';\nimport listContentTypes from './actions/content-types/list/command';\nimport listControllers from './actions/controllers/list/command';\nimport generateCommand from './actions/generate/command';\nimport listHooks from './actions/hooks/list/command';\nimport installCommand from './actions/install/command';\nimport listMiddlewares from './actions/middlewares/list/command';\nimport newCommand from './actions/new/command';\nimport listPolicies from './actions/policies/list/command';\nimport reportCommand from './actions/report/command';\nimport listRoutes from './actions/routes/list/command';\nimport listServices from './actions/services/list/command';\nimport startCommand from './actions/start/command';\nimport disableTelemetry from './actions/telemetry/disable/command';\nimport enableTelemetry from './actions/telemetry/enable/command';\nimport generateTemplates from './actions/templates/generate/command';\nimport generateTsTypes from './actions/ts/generate-types/command';\nimport uninstallCommand from './actions/uninstall/command';\nimport versionCommand from './actions/version/command';\nimport watchAdminCommand from './actions/watch-admin/command';\n\nimport buildPluginCommand from './actions/plugin/build-command/command';\nimport initPluginCommand from './actions/plugin/init/command';\nimport linkWatchPluginCommand from './actions/plugin/link-watch/command';\nimport watchPluginCommand from './actions/plugin/watch/command';\nimport verifyPluginCommand from './actions/plugin/verify/command';\n\nimport { createLogger } from './utils/logger';\nimport { loadTsConfig } from './utils/tsconfig';\nimport { CLIContext } from './types';\n\nconst strapiCommands = {\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n installCommand,\n listMiddlewares,\n newCommand,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n uninstallCommand,\n versionCommand,\n watchAdminCommand,\n /**\n * Plugins\n */\n buildPluginCommand,\n initPluginCommand,\n linkWatchPluginCommand,\n watchPluginCommand,\n verifyPluginCommand,\n} as const;\n\nconst buildStrapiCommand = async (argv: string[], command = new Command()) => {\n try {\n // NOTE: this is a hack to allow loading dts commands without make dts a dependency of strapi and thus avoiding circular dependencies\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const dtsCommands = require(require.resolve('@strapi/data-transfer')).commands;\n Object.assign(strapiCommands, dtsCommands);\n // eslint-disable-next-line @typescript-eslint/no-var-requires, node/no-missing-require\n const adminCommands = require(require.resolve('@strapi/admin/cli')).commands;\n Object.assign(strapiCommands, adminCommands);\n } catch (e) {\n // noop\n }\n\n // Initial program setup\n command.storeOptionsAsProperties(false).allowUnknownOption(true);\n\n // Help command\n command.helpOption('-h, --help', 'Display help for command');\n command.addHelpCommand('help [command]', 'Display help for command');\n\n const keys = Object.keys(strapiCommands) as (keyof typeof strapiCommands)[];\n\n const cwd = process.cwd();\n\n const hasDebug = argv.includes('--debug');\n const hasSilent = argv.includes('--silent');\n\n const logger = createLogger({ debug: hasDebug, silent: hasSilent, timestamp: false });\n\n const tsconfig = loadTsConfig({\n cwd,\n path: 'tsconfig.json',\n logger,\n });\n\n const ctx = {\n cwd,\n logger,\n tsconfig,\n } satisfies CLIContext;\n\n // Load all commands\n keys.forEach((name) => {\n try {\n // Add this command to the Commander command object\n strapiCommands[name]({ command, argv, ctx });\n } catch (e) {\n console.error(`Failed to load command ${name}`, e);\n }\n });\n\n return command;\n};\n\nconst runStrapiCommand = async (argv = process.argv, command = new Command()) => {\n const commands = await buildStrapiCommand(argv, command);\n await commands.parseAsync(argv);\n};\n\nexport { runStrapiCommand, buildStrapiCommand, strapiCommands };\n"],"names":["createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","installCommand","listMiddlewares","newCommand","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","uninstallCommand","versionCommand","watchAdminCommand","buildPluginCommand","initPluginCommand","linkWatchPluginCommand","watchPluginCommand","verifyPluginCommand","command","Command","logger","createLogger","tsconfig","loadTsConfig"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,iBAAiB;AAAA,EAAA,iBACrBA;AAAAA,EAAA,wBACAC;AAAAA,EAAA,gBACAC;AAAAA,EAAA,mBACAC;AAAAA,EAAA,sBACAC;AAAAA,EAAA,gBACAC;AAAAA,EAAA,kBACAC;AAAAA,EAAA,iBACAC;AAAAA,EAAA,iBACAC;AAAAA,EAAA,WACAC;AAAAA,EAAA,gBACAC;AAAAA,EAAA,iBACAC;AAAAA,EAAA,YACAC;AAAAA,EAAA,cACAC;AAAAA,EAAA,eACAC;AAAAA,EAAA,YACAC;AAAAA,EAAA,cACAC;AAAAA,EAAA,cACAC;AAAAA,EAAA,kBACAC;AAAAA,EAAA,iBACAC;AAAAA,EAAA,mBACAC;AAAAA,EAAA,iBACAC;AAAAA,EAAA,kBACAC;AAAAA,EAAA,gBACAC;AAAAA,EAAA,mBACAC;AAAAA;AAAAA;AAAAA;AAAAA,EAAA,oBAIAC;AAAAA,EAAA,mBACAC;AAAAA,EAAA,wBACAC;AAAAA,EAAA,oBACAC;AAAAA,EAAA,qBACAC;AACF;AAEA,MAAM,qBAAqB,OAAO,MAAgBC,WAAU,IAAIC,wBAAc;AACxE,MAAA;AAGF,UAAM,cAAc,QAAQ,gBAAgB,uBAAuB,CAAC,EAAE;AAC/D,WAAA,OAAO,gBAAgB,WAAW;AAEzC,UAAM,gBAAgB,QAAQ,gBAAgB,mBAAmB,CAAC,EAAE;AAC7D,WAAA,OAAO,gBAAgB,aAAa;AAAA,WACpC,GAAG;AAAA,EAEZ;AAGA,EAAAD,SAAQ,yBAAyB,KAAK,EAAE,mBAAmB,IAAI;AAGvD,EAAAA,SAAA,WAAW,cAAc,0BAA0B;AACnD,EAAAA,SAAA,eAAe,kBAAkB,0BAA0B;AAE7D,QAAA,OAAO,OAAO,KAAK,cAAc;AAEjC,QAAA,MAAM,QAAQ;AAEd,QAAA,WAAW,KAAK,SAAS,SAAS;AAClC,QAAA,YAAY,KAAK,SAAS,UAAU;AAEpC,QAAAE,WAASC,oBAAa,EAAE,OAAO,UAAU,QAAQ,WAAW,WAAW,MAAA,CAAO;AAEpF,QAAMC,aAAWC,SAAAA,aAAa;AAAA,IAC5B;AAAA,IACA,MAAM;AAAA,IAAA,QACNH;AAAAA,EAAA,CACD;AAED,QAAM,MAAM;AAAA,IACV;AAAA,IAAA,QACAA;AAAAA,IAAA,UACAE;AAAAA,EAAA;AAIG,OAAA,QAAQ,CAAC,SAAS;AACjB,QAAA;AAEF,qBAAe,IAAI,EAAE,EAAE,SAAAJ,UAAS,MAAM,KAAK;AAAA,aACpC,GAAG;AACV,cAAQ,MAAM,0BAA0B,IAAI,IAAI,CAAC;AAAA,IACnD;AAAA,EAAA,CACD;AAEM,SAAAA;AACT;AAEM,MAAA,mBAAmB,OAAO,OAAO,QAAQ,MAAMA,WAAU,IAAIC,UAAAA,cAAc;AAC/E,QAAM,WAAW,MAAM,mBAAmB,MAAMD,QAAO;AACjD,QAAA,SAAS,WAAW,IAAI;AAChC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../../../src/commands/utils/logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport ora from 'ora';\n\nexport interface LoggerOptions {\n silent?: boolean;\n debug?: boolean;\n timestamp?: boolean;\n}\n\nexport interface Logger {\n warnings: number;\n errors: number;\n debug: (...args: unknown[]) => void;\n info: (...args: unknown[]) => void;\n warn: (...args: unknown[]) => void;\n error: (...args: unknown[]) => void;\n log: (...args: unknown[]) => void;\n spinner: (text: string) => Pick<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;\n}\n\nconst createLogger = (options: LoggerOptions = {}): Logger => {\n const { silent = false, debug = false, timestamp = true } = options;\n\n const state = { errors: 0, warning: 0 };\n\n return {\n get warnings() {\n return state.warning;\n },\n\n get errors() {\n return state.errors;\n },\n\n debug(...args) {\n if (silent || !debug) {\n return;\n }\n\n console.log(\n chalk.cyan(`[DEBUG]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n info(...args) {\n if (silent) {\n return;\n }\n\n console.info(\n chalk.blue(`[INFO]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n log(...args) {\n if (silent) {\n return;\n }\n\n console.info(chalk.blue(`${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`), ...args);\n },\n\n warn(...args) {\n state.warning += 1;\n\n if (silent) {\n return;\n }\n\n console.warn(\n chalk.yellow(`[WARN]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n error(...args) {\n state.errors += 1;\n\n if (silent) {\n return;\n }\n\n console.error(\n chalk.red(`[ERROR]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n // @ts-expect-error – returning a subpart of ora is fine because the types tell us what is what.\n spinner(text: string) {\n if (silent) {\n return {\n succeed() {\n return this;\n },\n fail() {\n return this;\n },\n start() {\n return this;\n },\n text: '',\n };\n }\n\n return ora(text);\n },\n };\n};\n\nexport { createLogger };\n"],"names":["chalk","ora"],"mappings":";;;;;;;AAoBA,MAAM,eAAe,CAAC,UAAyB,OAAe;AAC5D,QAAM,EAAE,SAAS,OAAO,QAAQ,OAAO,YAAY,KAAS,IAAA;AAE5D,QAAM,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAAE;AAE/B,SAAA;AAAA,IACL,IAAI,WAAW;AACb,aAAO,MAAM;AAAA,IACf;AAAA,IAEA,IAAI,SAAS;AACX,aAAO,MAAM;AAAA,IACf;AAAA,IAEA,SAAS,MAAM;AACT,UAAA,UAAU,CAAC,OAAO;AACpB;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,KAAK,UAAU,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QACzE,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA,IAEA,QAAQ,MAAM;AACZ,UAAI,QAAQ;AACV;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,KAAK,SAAS,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QACxE,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA,IAEA,OAAO,MAAM;AACX,UAAI,QAAQ;AACV;AAAA,MACF;AAEA,cAAQ,KAAKA,uBAAM,KAAK,GAAG,YAAY,MAAU,oBAAA,
|
|
1
|
+
{"version":3,"file":"logger.js","sources":["../../../src/commands/utils/logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport ora from 'ora';\n\nexport interface LoggerOptions {\n silent?: boolean;\n debug?: boolean;\n timestamp?: boolean;\n}\n\nexport interface Logger {\n warnings: number;\n errors: number;\n debug: (...args: unknown[]) => void;\n info: (...args: unknown[]) => void;\n warn: (...args: unknown[]) => void;\n error: (...args: unknown[]) => void;\n log: (...args: unknown[]) => void;\n spinner: (text: string) => Pick<ora.Ora, 'succeed' | 'fail' | 'start' | 'text'>;\n}\n\nconst createLogger = (options: LoggerOptions = {}): Logger => {\n const { silent = false, debug = false, timestamp = true } = options;\n\n const state = { errors: 0, warning: 0 };\n\n return {\n get warnings() {\n return state.warning;\n },\n\n get errors() {\n return state.errors;\n },\n\n debug(...args) {\n if (silent || !debug) {\n return;\n }\n\n console.log(\n chalk.cyan(`[DEBUG]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n info(...args) {\n if (silent) {\n return;\n }\n\n console.info(\n chalk.blue(`[INFO]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n log(...args) {\n if (silent) {\n return;\n }\n\n console.info(chalk.blue(`${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`), ...args);\n },\n\n warn(...args) {\n state.warning += 1;\n\n if (silent) {\n return;\n }\n\n console.warn(\n chalk.yellow(`[WARN]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n error(...args) {\n state.errors += 1;\n\n if (silent) {\n return;\n }\n\n console.error(\n chalk.red(`[ERROR]${timestamp ? `\\t[${new Date().toISOString()}]` : ''}`),\n ...args\n );\n },\n\n // @ts-expect-error – returning a subpart of ora is fine because the types tell us what is what.\n spinner(text: string) {\n if (silent) {\n return {\n succeed() {\n return this;\n },\n fail() {\n return this;\n },\n start() {\n return this;\n },\n text: '',\n };\n }\n\n return ora(text);\n },\n };\n};\n\nexport { createLogger };\n"],"names":["chalk","ora"],"mappings":";;;;;;;AAoBA,MAAM,eAAe,CAAC,UAAyB,OAAe;AAC5D,QAAM,EAAE,SAAS,OAAO,QAAQ,OAAO,YAAY,KAAS,IAAA;AAE5D,QAAM,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAAE;AAE/B,SAAA;AAAA,IACL,IAAI,WAAW;AACb,aAAO,MAAM;AAAA,IACf;AAAA,IAEA,IAAI,SAAS;AACX,aAAO,MAAM;AAAA,IACf;AAAA,IAEA,SAAS,MAAM;AACT,UAAA,UAAU,CAAC,OAAO;AACpB;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,KAAK,UAAU,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QACzE,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA,IAEA,QAAQ,MAAM;AACZ,UAAI,QAAQ;AACV;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,KAAK,SAAS,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QACxE,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA,IAEA,OAAO,MAAM;AACX,UAAI,QAAQ;AACV;AAAA,MACF;AAEA,cAAQ,KAAKA,uBAAM,KAAK,GAAG,YAAY,MAAU,oBAAA,KAAA,GAAO,YAAa,CAAA,MAAM,EAAE,EAAE,GAAG,GAAG,IAAI;AAAA,IAC3F;AAAA,IAEA,QAAQ,MAAM;AACZ,YAAM,WAAW;AAEjB,UAAI,QAAQ;AACV;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,OAAO,SAAS,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QAC1E,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA,IAEA,SAAS,MAAM;AACb,YAAM,UAAU;AAEhB,UAAI,QAAQ;AACV;AAAA,MACF;AAEQ,cAAA;AAAA,QACNA,eAAAA,QAAM,IAAI,UAAU,YAAY,MAAM,oBAAI,KAAK,GAAE,YAAa,CAAA,MAAM,EAAE,EAAE;AAAA,QACxE,GAAG;AAAA,MAAA;AAAA,IAEP;AAAA;AAAA,IAGA,QAAQ,MAAc;AACpB,UAAI,QAAQ;AACH,eAAA;AAAA,UACL,UAAU;AACD,mBAAA;AAAA,UACT;AAAA,UACA,OAAO;AACE,mBAAA;AAAA,UACT;AAAA,UACA,QAAQ;AACC,mBAAA;AAAA,UACT;AAAA,UACA,MAAM;AAAA,QAAA;AAAA,MAEV;AAEA,aAAOC,aAAAA,QAAI,IAAI;AAAA,IACjB;AAAA,EAAA;AAEJ;;"}
|
|
@@ -9,6 +9,7 @@ interface Export {
|
|
|
9
9
|
default: string;
|
|
10
10
|
}
|
|
11
11
|
declare const packageJsonSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
12
|
+
name: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
|
|
12
13
|
exports: import("yup/lib/Lazy").default<import("yup/lib/object").OptionalObjectSchema<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
|
|
13
14
|
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
|
|
14
15
|
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
|
|
@@ -53,6 +54,7 @@ declare const packageJsonSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
|
53
54
|
default: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
|
|
54
55
|
}>>>>>, any>;
|
|
55
56
|
}, Record<string, any>, import("yup/lib/object").TypeOfShape<{
|
|
57
|
+
name: import("yup/lib/string").RequiredStringSchema<string | undefined, Record<string, any>>;
|
|
56
58
|
exports: import("yup/lib/Lazy").default<import("yup/lib/object").OptionalObjectSchema<Record<string, yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string> | yup.default<{
|
|
57
59
|
types: yup.default<import("yup/lib/types").Maybe<string | undefined>, import("yup/lib/object").AnyObject, string | undefined>;
|
|
58
60
|
source: yup.default<import("yup/lib/types").Maybe<string>, import("yup/lib/object").AnyObject, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/pkg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,UAAU,MAAM;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"pkg.d.ts","sourceRoot":"","sources":["../../../src/commands/utils/pkg.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,UAAU,MAAM;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BrB,CAAC;AAEH;;;;GAIG;AACH,QAAA,MAAM,OAAO;SAAkC,MAAM;YAAU,MAAM;MAAK,QAAQ,MAAM,CAcvF,CAAC;AAEF,KAAK,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEzD;;;GAGG;AACH,QAAA,MAAM,WAAW;SAA0B,MAAM;MAAK,QAAQ,WAAW,CA+CxE,CAAC;AAEF,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -30,6 +30,7 @@ const pkgUp__default = /* @__PURE__ */ _interopDefault(pkgUp);
|
|
|
30
30
|
const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
|
|
31
31
|
const chalk__default = /* @__PURE__ */ _interopDefault(chalk);
|
|
32
32
|
const packageJsonSchema = yup__namespace.object({
|
|
33
|
+
name: yup__namespace.string().required(),
|
|
33
34
|
exports: yup__namespace.lazy(
|
|
34
35
|
(value) => yup__namespace.object(
|
|
35
36
|
typeof value === "object" ? Object.entries(value).reduce((acc, [key, value2]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkg.js","sources":["../../../src/commands/utils/pkg.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport os from 'os';\nimport pkgUp from 'pkg-up';\nimport * as yup from 'yup';\nimport chalk from 'chalk';\nimport { Logger } from './logger';\n\ninterface Export {\n types?: string;\n source: string;\n module?: string;\n import?: string;\n require?: string;\n default: string;\n}\n\nconst packageJsonSchema = yup.object({\n exports: yup.lazy((value) =>\n yup\n .object(\n typeof value === 'object'\n ? Object.entries(value).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n acc[key] = yup\n .object({\n types: yup.string().optional(),\n source: yup.string().required(),\n module: yup.string().optional(),\n import: yup.string().required(),\n require: yup.string().required(),\n default: yup.string().required(),\n })\n .noUnknown(true);\n } else {\n acc[key] = yup\n .string()\n .matches(/^\\.\\/.*\\.json$/)\n .required();\n }\n\n return acc;\n }, {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>)\n : undefined\n )\n .optional()\n ),\n});\n\n/**\n * @description being a task to load the package.json starting from the current working directory\n * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,\n * the process will throw with an appropriate error message.\n */\nconst loadPkg = async ({ cwd, logger }: { cwd: string; logger: Logger }): Promise<object> => {\n const pkgPath = await pkgUp({ cwd });\n\n if (!pkgPath) {\n throw new Error('Could not find a package.json in the current directory');\n }\n\n const buffer = await fs.readFile(pkgPath);\n\n const pkg = JSON.parse(buffer.toString());\n\n logger.debug('Loaded package.json:', os.EOL, pkg);\n\n return pkg;\n};\n\ntype PackageJson = yup.Asserts<typeof packageJsonSchema>;\n\n/**\n * @description validate the package.json against a standardised schema using `yup`.\n * If the validation fails, the process will throw with an appropriate error message.\n */\nconst validatePkg = async ({ pkg }: { pkg: object }): Promise<PackageJson> => {\n try {\n const validatedPkg = await packageJsonSchema.validate(pkg, {\n strict: true,\n });\n\n return validatedPkg;\n } catch (err) {\n if (err instanceof yup.ValidationError) {\n switch (err.type) {\n case 'required':\n if (err.path) {\n throw new Error(\n `'${err.path}' in 'package.json' is required as type '${chalk.magenta(\n yup.reach(packageJsonSchema, err.path).type\n )}'`\n );\n }\n break;\n /**\n * This will only be thrown if there are keys in the export map\n * that we don't expect so we can therefore make some assumptions\n */\n case 'noUnknown':\n if (err.path && err.params && 'unknown' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(\n err.params.unknown\n )}, for compatability only the following keys are allowed: ${chalk.magenta(\n \"['types', 'source', 'import', 'require', 'default']\"\n )}`\n );\n }\n break;\n default:\n if (err.path && err.params && 'type' in err.params && 'value' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' must be of type '${chalk.magenta(\n err.params.type\n )}' (recieved '${chalk.magenta(typeof err.params.value)}')`\n );\n }\n }\n }\n\n throw err;\n }\n};\n\nexport type { PackageJson, Export };\nexport { loadPkg, validatePkg };\n"],"names":["yup","value","pkgUp","fs","os","chalk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,oBAAoBA,eAAI,OAAO;AAAA,EACnC,SAASA,eAAI;AAAA,IAAK,CAAC,UACjBA,eACG;AAAA,MACC,OAAO,UAAU,WACb,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAKC,MAAK,MAAM;AAC9C,YAAA,OAAOA,WAAU,UAAU;AACzB,cAAA,GAAG,IAAID,eACR,OAAO;AAAA,YACN,OAAOA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC7B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,SAASA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC/B,SAASA,eAAI,OAAO,EAAE,SAAS;AAAA,UAAA,CAChC,EACA,UAAU,IAAI;AAAA,QAAA,OACZ;AACD,cAAA,GAAG,IAAIA,eACR,SACA,QAAQ,gBAAgB,EACxB;QACL;AAEO,eAAA;AAAA,MAAA,GACN,CAAA,CAAiE,IACpE;AAAA,MAEL,SAAS;AAAA,EACd;AACF,CAAC;AAOD,M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BA,eAAM,QAAA,QAAQ,OAAO,IAAI,OAAO,KAAK,CAAC;AAAA,YAAA;AAAA,UAE3D;AAAA,MACJ;AAAA,IACF;AAEM,UAAA;AAAA,EACR;AACF;;;"}
|
|
1
|
+
{"version":3,"file":"pkg.js","sources":["../../../src/commands/utils/pkg.ts"],"sourcesContent":["import fs from 'fs/promises';\nimport os from 'os';\nimport pkgUp from 'pkg-up';\nimport * as yup from 'yup';\nimport chalk from 'chalk';\nimport { Logger } from './logger';\n\ninterface Export {\n types?: string;\n source: string;\n module?: string;\n import?: string;\n require?: string;\n default: string;\n}\n\nconst packageJsonSchema = yup.object({\n name: yup.string().required(),\n exports: yup.lazy((value) =>\n yup\n .object(\n typeof value === 'object'\n ? Object.entries(value).reduce((acc, [key, value]) => {\n if (typeof value === 'object') {\n acc[key] = yup\n .object({\n types: yup.string().optional(),\n source: yup.string().required(),\n module: yup.string().optional(),\n import: yup.string().required(),\n require: yup.string().required(),\n default: yup.string().required(),\n })\n .noUnknown(true);\n } else {\n acc[key] = yup\n .string()\n .matches(/^\\.\\/.*\\.json$/)\n .required();\n }\n\n return acc;\n }, {} as Record<string, yup.SchemaOf<string> | yup.SchemaOf<Export>>)\n : undefined\n )\n .optional()\n ),\n});\n\n/**\n * @description being a task to load the package.json starting from the current working directory\n * using a shallow find for the package.json and `fs` to read the file. If no package.json is found,\n * the process will throw with an appropriate error message.\n */\nconst loadPkg = async ({ cwd, logger }: { cwd: string; logger: Logger }): Promise<object> => {\n const pkgPath = await pkgUp({ cwd });\n\n if (!pkgPath) {\n throw new Error('Could not find a package.json in the current directory');\n }\n\n const buffer = await fs.readFile(pkgPath);\n\n const pkg = JSON.parse(buffer.toString());\n\n logger.debug('Loaded package.json:', os.EOL, pkg);\n\n return pkg;\n};\n\ntype PackageJson = yup.Asserts<typeof packageJsonSchema>;\n\n/**\n * @description validate the package.json against a standardised schema using `yup`.\n * If the validation fails, the process will throw with an appropriate error message.\n */\nconst validatePkg = async ({ pkg }: { pkg: object }): Promise<PackageJson> => {\n try {\n const validatedPkg = await packageJsonSchema.validate(pkg, {\n strict: true,\n });\n\n return validatedPkg;\n } catch (err) {\n if (err instanceof yup.ValidationError) {\n switch (err.type) {\n case 'required':\n if (err.path) {\n throw new Error(\n `'${err.path}' in 'package.json' is required as type '${chalk.magenta(\n yup.reach(packageJsonSchema, err.path).type\n )}'`\n );\n }\n break;\n /**\n * This will only be thrown if there are keys in the export map\n * that we don't expect so we can therefore make some assumptions\n */\n case 'noUnknown':\n if (err.path && err.params && 'unknown' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' contains the unknown key ${chalk.magenta(\n err.params.unknown\n )}, for compatability only the following keys are allowed: ${chalk.magenta(\n \"['types', 'source', 'import', 'require', 'default']\"\n )}`\n );\n }\n break;\n default:\n if (err.path && err.params && 'type' in err.params && 'value' in err.params) {\n throw new Error(\n `'${err.path}' in 'package.json' must be of type '${chalk.magenta(\n err.params.type\n )}' (recieved '${chalk.magenta(typeof err.params.value)}')`\n );\n }\n }\n }\n\n throw err;\n }\n};\n\nexport type { PackageJson, Export };\nexport { loadPkg, validatePkg };\n"],"names":["yup","value","pkgUp","fs","os","chalk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,MAAM,oBAAoBA,eAAI,OAAO;AAAA,EACnC,MAAMA,eAAI,OAAO,EAAE,SAAS;AAAA,EAC5B,SAASA,eAAI;AAAA,IAAK,CAAC,UACjBA,eACG;AAAA,MACC,OAAO,UAAU,WACb,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAKC,MAAK,MAAM;AAC9C,YAAA,OAAOA,WAAU,UAAU;AACzB,cAAA,GAAG,IAAID,eACR,OAAO;AAAA,YACN,OAAOA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC7B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EAAE,SAAS;AAAA,YAC9B,QAAQA,eAAI,OAAO,EA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AAAA,cAAA,CACZ,4DAA4DA,eAAAA,QAAM;AAAA,gBACjE;AAAA,cAAA,CACD;AAAA,YAAA;AAAA,UAEL;AACA;AAAA,QACF;AACM,cAAA,IAAI,QAAQ,IAAI,UAAU,UAAU,IAAI,UAAU,WAAW,IAAI,QAAQ;AAC3E,kBAAM,IAAI;AAAA,cACR,IAAI,IAAI,IAAI,wCAAwCA,eAAM,QAAA;AAAA,gBACxD,IAAI,OAAO;AAAA,cAAA,CACZ,gBAAgBA,eAAM,QAAA,QAAQ,OAAO,IAAI,OAAO,KAAK,CAAC;AAAA,YAAA;AAAA,UAE3D;AAAA,MACJ;AAAA,IACF;AAEM,UAAA;AAAA,EACR;AACF;;;"}
|
package/dist/factories.js
CHANGED
|
@@ -27,8 +27,8 @@ const createCoreController = (uid, cfg) => {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
Object.setPrototypeOf(userCtrl, baseController);
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
30
|
+
const isCustom = typeof cfg !== "undefined";
|
|
31
|
+
if (isCustom) {
|
|
32
32
|
Object.defineProperty(userCtrl, symbols.CustomController, {
|
|
33
33
|
writable: false,
|
|
34
34
|
configurable: false,
|
package/dist/factories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\n// Content type is proxied to allow for dynamic content type updates\nconst getContentTypeProxy = (strapi: Strapi, uid: Common.UID.ContentType) => {\n return new Proxy(strapi.contentType(uid), {\n get(target, prop) {\n const contentType = strapi.contentType(uid);\n if (prop in contentType) {\n return contentType[prop as keyof typeof contentType];\n }\n },\n });\n};\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const
|
|
1
|
+
{"version":3,"file":"factories.js","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\n// Content type is proxied to allow for dynamic content type updates\nconst getContentTypeProxy = (strapi: Strapi, uid: Common.UID.ContentType) => {\n return new Proxy(strapi.contentType(uid), {\n get(target, prop) {\n const contentType = strapi.contentType(uid);\n if (prop in contentType) {\n return contentType[prop as keyof typeof contentType];\n }\n },\n });\n};\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends Common.UID.ContentType,\n TService extends CoreApi.Service.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Service.Extendable<TUID> & TService>>\n) {\n return ({ strapi }: { strapi: Strapi }): TService & CoreApi.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends Common.UID.ContentType>(\n uid: T,\n cfg?: CoreApi.Router.RouterConfig<T>\n): CoreApi.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: CoreApi.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Common.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","createController","createService","createRoutes","pipe","routes","omit","pick"],"mappings":";;;;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAKA,MAAM,sBAAsB,CAACA,SAAgB,QAAgC;AAC3E,SAAO,IAAI,MAAMA,QAAO,YAAY,GAAG,GAAG;AAAA,IACxC,IAAI,QAAQ,MAAM;AACV,YAAA,cAAcA,QAAO,YAAY,GAAG;AAC1C,UAAI,QAAQ,aAAa;AACvB,eAAO,YAAY,IAAgC;AAAA,MACrD;AAAA,IACF;AAAA,EAAA,CACD;AACH;AAEM,MAAA,uBAAuB,CAI3B,KACA,QACG;AACH,SAAO,CAAC,EAAE,QAAAA,cAAqF;AACvF,UAAA,iBAAiBC,uBAAiB,EAAE,aAAa,oBAAoBD,SAAQ,GAAG,GAAG;AAEnF,UAAA,WAAW,OAAO,QAAQ,aAAa,IAAI,EAAE,QAAAA,QAAQ,CAAA,IAAI,OAAQ;AAEvE,eAAW,cAAc,OAAO,KAAK,cAAc,GAAyC;AACtF,UAAA,SAAS,UAAU,MAAM,QAAW;AAC7B,iBAAA,UAAU,IAAI,eAAe,UAAU;AAAA,MAClD;AAAA,IACF;AAEO,WAAA,eAAe,UAAU,cAAc;AAExC,UAAA,WAAW,OAAO,QAAQ;AAChC,QAAI,UAAU;AACL,aAAA,eAAe,UAAU,QAAQ,kBAAkB;AAAA,QACxD,UAAU;AAAA,QACV,cAAc;AAAA,QACd,YAAY;AAAA,MAAA,CACb;AAAA,IACH;AAEO,WAAA;AAAA,EAAA;AAEX;AAEA,SAAS,kBAIP,KACA,KACA;AACA,SAAO,CAAC,EAAE,QAAAA,cAA+E;AACjF,UAAA,cAAcE,sBAAc,EAAE,aAAa,oBAAoBF,SAAQ,GAAG,GAAG;AAE7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Controller);
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
28
|
+
const isCustom = typeof cfg !== "undefined";
|
|
29
|
+
if (isCustom) {
|
|
30
30
|
Object.defineProperty(userCtrl, symbols.CustomController, {
|
|
31
31
|
writable: false,
|
|
32
32
|
configurable: false,
|
package/dist/factories.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\n// Content type is proxied to allow for dynamic content type updates\nconst getContentTypeProxy = (strapi: Strapi, uid: Common.UID.ContentType) => {\n return new Proxy(strapi.contentType(uid), {\n get(target, prop) {\n const contentType = strapi.contentType(uid);\n if (prop in contentType) {\n return contentType[prop as keyof typeof contentType];\n }\n },\n });\n};\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const
|
|
1
|
+
{"version":3,"file":"factories.mjs","sources":["../src/factories.ts"],"sourcesContent":["import { pipe, omit, pick } from 'lodash/fp';\nimport type { Strapi, Common, CoreApi, Utils } from '@strapi/types';\n\nimport { createController } from './core-api/controller';\nimport { createService } from './core-api/service';\nimport { createRoutes } from './core-api/routes';\n\nconst symbols = {\n CustomController: Symbol('StrapiCustomCoreController'),\n} as const;\n\ntype WithStrapiCallback<T> = T | (<S extends { strapi: Strapi }>(params: S) => T);\n\n// Content type is proxied to allow for dynamic content type updates\nconst getContentTypeProxy = (strapi: Strapi, uid: Common.UID.ContentType) => {\n return new Proxy(strapi.contentType(uid), {\n get(target, prop) {\n const contentType = strapi.contentType(uid);\n if (prop in contentType) {\n return contentType[prop as keyof typeof contentType];\n }\n },\n });\n};\n\nconst createCoreController = <\n TUID extends Common.UID.ContentType,\n TController extends CoreApi.Controller.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Controller.Extendable<TUID> & TController>>\n) => {\n return ({ strapi }: { strapi: Strapi }): TController & CoreApi.Controller.ContentType<TUID> => {\n const baseController = createController({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userCtrl = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseController) as Array<keyof typeof baseController>) {\n if (userCtrl[methodName] === undefined) {\n userCtrl[methodName] = baseController[methodName];\n }\n }\n\n Object.setPrototypeOf(userCtrl, baseController);\n\n const isCustom = typeof cfg !== 'undefined';\n if (isCustom) {\n Object.defineProperty(userCtrl, symbols.CustomController, {\n writable: false,\n configurable: false,\n enumerable: false,\n });\n }\n\n return userCtrl;\n };\n};\n\nfunction createCoreService<\n TUID extends Common.UID.ContentType,\n TService extends CoreApi.Service.Extendable<TUID>\n>(\n uid: TUID,\n cfg?: WithStrapiCallback<Utils.PartialWithThis<CoreApi.Service.Extendable<TUID> & TService>>\n) {\n return ({ strapi }: { strapi: Strapi }): TService & CoreApi.Service.ContentType<TUID> => {\n const baseService = createService({ contentType: getContentTypeProxy(strapi, uid) });\n\n const userService = typeof cfg === 'function' ? cfg({ strapi }) : cfg ?? ({} as any);\n\n for (const methodName of Object.keys(baseService) as Array<keyof typeof baseService>) {\n if (userService[methodName] === undefined) {\n userService[methodName] = baseService[methodName];\n }\n }\n\n Object.setPrototypeOf(userService, baseService);\n return userService;\n };\n}\n\nfunction createCoreRouter<T extends Common.UID.ContentType>(\n uid: T,\n cfg?: CoreApi.Router.RouterConfig<T>\n): CoreApi.Router.Router {\n const { prefix, config = {}, only, except, type = 'content-api' } = cfg ?? {};\n let routes: CoreApi.Router.Route[];\n\n return {\n type,\n prefix,\n get routes() {\n if (!routes) {\n const contentType = strapi.contentType(uid);\n\n const defaultRoutes = createRoutes({ contentType });\n const keys = Object.keys(defaultRoutes) as Array<keyof typeof defaultRoutes>;\n\n keys.forEach((routeName) => {\n const defaultRoute = defaultRoutes[routeName];\n\n Object.assign(defaultRoute.config, config[routeName] || {});\n });\n\n const selectedRoutes = pipe(\n (routes) => (except ? omit(except, routes) : routes),\n (routes) => (only ? pick(only, routes) : routes)\n )(defaultRoutes);\n\n routes = Object.values(selectedRoutes);\n }\n\n return routes;\n },\n };\n}\n\nconst isCustomController = <T extends Common.Controller>(controller: T): boolean => {\n return symbols.CustomController in controller;\n};\n\nexport { createCoreController, createCoreService, createCoreRouter, isCustomController };\n"],"names":["strapi","routes"],"mappings":";;;;AAOA,MAAM,UAAU;AAAA,EACd,kBAAkB,OAAO,4BAA4B;AACvD;AAKA,MAAM,sBAAsB,CAACA,SAAgB,QAAgC;AAC3E,SAAO,IAAI,MAAMA,QAAO,YAAY,GAAG,GAAG;AAAA,IACxC,IAAI,QAAQ,MAAM;AACV,YAAA,cAAcA,QAAO,YAAY,GAAG;AAC1C,UAAI,QAAQ,aAAa;AACvB,eAAO,YAAY,IAAgC;AAAA,MACrD;AAAA,IACF;AAAA,EAAA,CACD;AACH;AAEM,MAAA,uBAAuB,CAI3B,KACA,QACG;AACH,SAAO,CAAC,EAAE,QAAAA,cAAqF;AACvF,UAAA,iBAAiB,iBA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aAAa;AAEjC,aAAA,QAAQ,CAAC,cAAc;AACpB,gBAAA,eAAe,cAAc,SAAS;AAE5C,iBAAO,OAAO,aAAa,QAAQ,OAAO,SAAS,KAAK,CAAA,CAAE;AAAA,QAAA,CAC3D;AAED,cAAM,iBAAiB;AAAA,UACrB,CAACC,YAAY,SAAS,KAAK,QAAQA,OAAM,IAAIA;AAAAA,UAC7C,CAACA,YAAY,OAAO,KAAK,MAAMA,OAAM,IAAIA;AAAAA,UACzC,aAAa;AAEN,iBAAA,OAAO,OAAO,cAAc;AAAA,MACvC;AAEO,aAAA;AAAA,IACT;AAAA,EAAA;AAEJ;AAEM,MAAA,qBAAqB,CAA8B,eAA2B;AAClF,SAAO,QAAQ,oBAAoB;AACrC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/middlewares/security.ts"],"names":[],"mappings":"AACA,OAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B3D,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAmCnD,CAAC"}
|
|
@@ -44,6 +44,16 @@ const security = (config, { strapi }) => (ctx, next) => {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
48
|
+
helmetConfig = _.merge(helmetConfig, {
|
|
49
|
+
contentSecurityPolicy: {
|
|
50
|
+
directives: {
|
|
51
|
+
"script-src": ["'self'", "'unsafe-inline'"],
|
|
52
|
+
"connect-src": ["'self'", "https:", "ws:"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
47
57
|
return helmet__default.default(helmetConfig)(ctx, next);
|
|
48
58
|
};
|
|
49
59
|
exports.security = security;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n if (strapi.plugin('graphql')) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n }\n\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaultsDeep","merge","helmet"],"mappings":";;;;;;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBA,EAAAA,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAElC,MAAA,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAAA,EACzC;AAEA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAeC,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,UAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,QAChE;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAOC,gBAAO,QAAA,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
|
|
1
|
+
{"version":3,"file":"security.js","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n if (strapi.plugin('graphql')) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n }\n\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n },\n },\n });\n }\n\n if (ctx.method === 'GET' && ['/admin'].some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":["defaultsDeep","merge","helmet"],"mappings":";;;;;;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuBA,EAAAA,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAElC,MAAA,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAAA,EACzC;AAEA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAeC,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,UAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,QAChE;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,MAAI,IAAI,WAAW,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAC9E,mBAAeA,QAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,iBAAiB;AAAA,UAC1C,eAAe,CAAC,UAAU,UAAU,KAAK;AAAA,QAC3C;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAOC,gBAAO,QAAA,YAAY,EAAE,KAAK,IAAI;AACvC;;"}
|
|
@@ -40,6 +40,16 @@ const security = (config, { strapi }) => (ctx, next) => {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
if (ctx.method === "GET" && ["/admin"].some((str) => ctx.path.startsWith(str))) {
|
|
44
|
+
helmetConfig = merge(helmetConfig, {
|
|
45
|
+
contentSecurityPolicy: {
|
|
46
|
+
directives: {
|
|
47
|
+
"script-src": ["'self'", "'unsafe-inline'"],
|
|
48
|
+
"connect-src": ["'self'", "https:", "ws:"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
43
53
|
return helmet(helmetConfig)(ctx, next);
|
|
44
54
|
};
|
|
45
55
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n if (strapi.plugin('graphql')) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n }\n\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"mappings":";;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuB,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAElC,MAAA,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAAA,EACzC;AAEA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG;AAChF,mBAAe,MAAM,cAAc;AAAA,MACjC,uBAAuB;AAAA,QACrB,YAAY;AAAA,UACV,cAAc,CAAC,UAAU,mBAAmB,kBAAkB;AAAA,UAC9D,WAAW,CAAC,UAAU,SAAS,oBAAoB,WAAW;AAAA,QAChE;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EACH;AAEA,SAAO,OAAO,YAAY,EAAE,KAAK,IAAI;AACvC;"}
|
|
1
|
+
{"version":3,"file":"security.mjs","sources":["../../src/middlewares/security.ts"],"sourcesContent":["import { defaultsDeep, merge } from 'lodash/fp';\nimport helmet, { KoaHelmet } from 'koa-helmet';\n\nimport type { Common } from '@strapi/types';\n\nexport type Config = NonNullable<Parameters<KoaHelmet>[0]>;\n\nconst defaults: Config = {\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n contentSecurityPolicy: {\n useDefaults: true,\n directives: {\n 'connect-src': [\"'self'\", 'https:'],\n 'img-src': [\"'self'\", 'data:', 'blob:', 'https://market-assets.strapi.io'],\n 'media-src': [\"'self'\", 'data:', 'blob:'],\n upgradeInsecureRequests: null,\n },\n },\n xssFilter: false,\n hsts: {\n maxAge: 31536000,\n includeSubDomains: true,\n },\n frameguard: {\n action: 'sameorigin',\n },\n};\n\nexport const security: Common.MiddlewareFactory<Config> =\n (config, { strapi }) =>\n (ctx, next) => {\n let helmetConfig: Config = defaultsDeep(defaults, config);\n\n const specialPaths = ['/documentation'];\n\n if (strapi.plugin('graphql')) {\n const { config: gqlConfig } = strapi.plugin('graphql');\n specialPaths.push(gqlConfig('endpoint'));\n }\n\n if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\", 'cdn.jsdelivr.net'],\n 'img-src': [\"'self'\", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],\n },\n },\n });\n }\n\n if (ctx.method === 'GET' && ['/admin'].some((str) => ctx.path.startsWith(str))) {\n helmetConfig = merge(helmetConfig, {\n contentSecurityPolicy: {\n directives: {\n 'script-src': [\"'self'\", \"'unsafe-inline'\"],\n 'connect-src': [\"'self'\", 'https:', 'ws:'],\n },\n },\n });\n }\n\n return helmet(helmetConfig)(ctx, next);\n };\n"],"names":[],"mappings":";;AAOA,MAAM,WAAmB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,IACrB,aAAa;AAAA,IACb,YAAY;AAAA,MACV,eAAe,CAAC,UAAU,QAAQ;AAAA,MAClC,WAAW,CAAC,UAAU,SAAS,SAAS,iCAAiC;AAAA,MACzE,aAAa,CAAC,UAAU,SAAS,OAAO;AAAA,MACxC,yBAAyB;AAAA,IAC3B;AAAA,EACF;AAAA,EACA,WAAW;AAAA,EACX,MAAM;AAAA,IACJ,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AAAA,EACA,YAAY;AAAA,IACV,QAAQ;AAAA,EACV;AACF;AAEa,MAAA,WACX,CAAC,QAAQ,EAAE,aACX,CAAC,KAAK,SAAS;AACT,MAAA,eAAuB,aAAa,UAAU,MAAM;AAElD,QAAA,eAAe,CAAC,gBAAgB;AAElC,MAAA,OAAO,OAAO,SAAS,GAAG;AAC5B,UAAM,EAAE,QAAQ,UAAA,IAAc,OAAO,OAAO,SAAS;AACxC,iBAAA,KAAK,UAAU,UAAU,CAAC;AAAA,EACzC;AAEA,MAAI,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,QAAQ,IAAI,KAAK,WAAW,GAAG,CAAC,GAAG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