@strapi/strapi 5.18.1 → 5.20.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/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/openapi/generate.d.ts +9 -0
- package/dist/cli/commands/openapi/generate.d.ts.map +1 -0
- package/dist/cli/commands/openapi/index.d.ts +7 -0
- package/dist/cli/commands/openapi/index.d.ts.map +1 -0
- package/dist/cli/utils/telemetry.d.ts.map +1 -1
- package/dist/node/core/env.d.ts +1 -0
- package/dist/node/core/env.d.ts.map +1 -1
- package/dist/node/create-build-context.d.ts.map +1 -1
- package/dist/node/vite/config.d.ts.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/cli/commands/index.js +2 -0
- package/dist/src/cli/commands/index.js.map +1 -1
- package/dist/src/cli/commands/index.mjs +2 -0
- package/dist/src/cli/commands/index.mjs.map +1 -1
- package/dist/src/cli/commands/openapi/generate.js +76 -0
- package/dist/src/cli/commands/openapi/generate.js.map +1 -0
- package/dist/src/cli/commands/openapi/generate.mjs +55 -0
- package/dist/src/cli/commands/openapi/generate.mjs.map +1 -0
- package/dist/src/cli/commands/openapi/index.js +17 -0
- package/dist/src/cli/commands/openapi/index.js.map +1 -0
- package/dist/src/cli/commands/openapi/index.mjs +15 -0
- package/dist/src/cli/commands/openapi/index.mjs.map +1 -0
- package/dist/src/cli/utils/telemetry.js +2 -1
- package/dist/src/cli/utils/telemetry.js.map +1 -1
- package/dist/src/cli/utils/telemetry.mjs +3 -2
- package/dist/src/cli/utils/telemetry.mjs.map +1 -1
- package/dist/src/node/core/env.js.map +1 -1
- package/dist/src/node/core/env.mjs.map +1 -1
- package/dist/src/node/create-build-context.js +2 -1
- package/dist/src/node/create-build-context.js.map +1 -1
- package/dist/src/node/create-build-context.mjs +2 -1
- package/dist/src/node/create-build-context.mjs.map +1 -1
- package/dist/src/node/vite/config.js +59 -1
- package/dist/src/node/vite/config.js.map +1 -1
- package/dist/src/node/vite/config.mjs +59 -1
- package/dist/src/node/vite/config.mjs.map +1 -1
- package/package.json +22 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,eAAO,MAAM,QAAQ,EAAE,aAAa,EAgCnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/openapi/generate.ts"],"names":[],"mappings":"AAWA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAaD;;GAEG;AACH,QAAA,MAAM,MAAM,YAAmB,cAAc,kBAY5C,CAAC;AA2CF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/openapi/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD;;GAEG;AACH,QAAA,MAAM,OAAO,EAAE,aAad,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/telemetry.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,UAAiB,MAAM,QAAQ,MAAM,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/telemetry.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,UAAiB,MAAM,QAAQ,MAAM,cAAc,GAAG,kBAkB3E,CAAC"}
|
package/dist/node/core/env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/node/core/env.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB,EAAE,MAAM,CAAC;IACjC,yBAAyB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/node/core/env.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB,EAAE,MAAM,CAAC;IACjC,yBAAyB,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,QAAA,MAAM,OAAO,QAAe,MAAM,kBAMjC,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,qBAAqB,eAAgB,UAAU,KAAG,OAAO,MAAM,EAAE,MAAM,CAW5E,CAAC;AAEF,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.d.ts","sourceRoot":"","sources":["../../src/node/create-build-context.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,UAAU,EAA+C,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,OAAO,EAAmB,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,UAAU,WAAW;IACnB,KAAK,CAAC,EA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3C,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,YAAY,CAAC,QAAQ,GAAG,OAAO,CAAE,SAAQ,WAAW;IAC5D;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACtD;;OAEG;IACH,OAAO,EAAE,WAAW,GAAG,QAAQ,CAAC;IAChC;;;OAGG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,UAAU,sBAAsB,CAAC,QAAQ,GAAG,OAAO,CAAE,SAAQ,UAAU;IACrE,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AASD,QAAA,MAAM,kBAAkB,8EAMrB,uBAAuB,QAAQ,CAAC,KAAG,QAAQ,aAAa,QAAQ,CAAC,CAyGnE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/node/vite/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/node/vite/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAqG5D,QAAA,MAAM,uBAAuB,QAAe,YAAY,KAAG,QAAQ,YAAY,CAuB9E,CAAC;AAEF,QAAA,MAAM,wBAAwB,QAAe,YAAY,KAAG,QAAQ,YAAY,CA0B/E,CAAC;AAMF,QAAA,MAAM,yBAAyB,WAAkB,YAAY,OAAO,YAAY,wBAQ/E,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC"}
|
package/dist/package.json.js
CHANGED
package/dist/package.json.mjs
CHANGED
|
@@ -24,6 +24,7 @@ var generate = require('./generate.js');
|
|
|
24
24
|
var report = require('./report.js');
|
|
25
25
|
var start = require('./start.js');
|
|
26
26
|
var version = require('./version.js');
|
|
27
|
+
var index = require('./openapi/index.js');
|
|
27
28
|
var command = require('./export/command.js');
|
|
28
29
|
var command$1 = require('./import/command.js');
|
|
29
30
|
var command$2 = require('./transfer/command.js');
|
|
@@ -55,6 +56,7 @@ const commands = [
|
|
|
55
56
|
command,
|
|
56
57
|
command$1,
|
|
57
58
|
command$2,
|
|
59
|
+
index.command,
|
|
58
60
|
/**
|
|
59
61
|
* Cloud
|
|
60
62
|
*/ cloudCli.buildStrapiCloudCommands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/cli/commands/index.ts"],"sourcesContent":["import { buildStrapiCloudCommands as cloudCommands } from '@strapi/cloud-cli';\n\nimport { command as createAdminUser } from './admin/create-user';\nimport { command as resetAdminUserPassword } from './admin/reset-user-password';\nimport { command as listComponents } from './components/list';\nimport { command as configurationDump } from './configuration/dump';\nimport { command as configurationRestore } from './configuration/restore';\nimport { command as listContentTypes } from './content-types/list';\nimport { command as listControllers } from './controllers/list';\nimport { command as listHooks } from './hooks/list';\nimport { command as listMiddlewares } from './middlewares/list';\nimport { command as listPolicies } from './policies/list';\nimport { command as listRoutes } from './routes/list';\nimport { command as listServices } from './services/list';\nimport { command as disableTelemetry } from './telemetry/disable';\nimport { command as enableTelemetry } from './telemetry/enable';\nimport { command as generateTemplates } from './templates/generate';\nimport { command as generateTsTypes } from './ts/generate-types';\nimport { command as buildCommand } from './build';\nimport { command as consoleCommand } from './console';\nimport { command as developCommand } from './develop';\nimport { command as generateCommand } from './generate';\nimport { command as reportCommand } from './report';\nimport { command as startCommand } from './start';\nimport { command as versionCommand } from './version';\nimport exportCommand from './export/command';\nimport importCommand from './import/command';\nimport transferCommand from './transfer/command';\n\nimport { StrapiCommand } from '../types';\n\nexport const commands: StrapiCommand[] = [\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n listMiddlewares,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n versionCommand,\n buildCommand,\n developCommand,\n exportCommand,\n importCommand,\n transferCommand,\n /**\n * Cloud\n */\n cloudCommands,\n];\n"],"names":["commands","createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","listMiddlewares","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","versionCommand","buildCommand","developCommand","exportCommand","importCommand","transferCommand","cloudCommands"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/cli/commands/index.ts"],"sourcesContent":["import { buildStrapiCloudCommands as cloudCommands } from '@strapi/cloud-cli';\n\nimport { command as createAdminUser } from './admin/create-user';\nimport { command as resetAdminUserPassword } from './admin/reset-user-password';\nimport { command as listComponents } from './components/list';\nimport { command as configurationDump } from './configuration/dump';\nimport { command as configurationRestore } from './configuration/restore';\nimport { command as listContentTypes } from './content-types/list';\nimport { command as listControllers } from './controllers/list';\nimport { command as listHooks } from './hooks/list';\nimport { command as listMiddlewares } from './middlewares/list';\nimport { command as listPolicies } from './policies/list';\nimport { command as listRoutes } from './routes/list';\nimport { command as listServices } from './services/list';\nimport { command as disableTelemetry } from './telemetry/disable';\nimport { command as enableTelemetry } from './telemetry/enable';\nimport { command as generateTemplates } from './templates/generate';\nimport { command as generateTsTypes } from './ts/generate-types';\nimport { command as buildCommand } from './build';\nimport { command as consoleCommand } from './console';\nimport { command as developCommand } from './develop';\nimport { command as generateCommand } from './generate';\nimport { command as reportCommand } from './report';\nimport { command as startCommand } from './start';\nimport { command as versionCommand } from './version';\nimport { command as openAPICommand } from './openapi';\nimport exportCommand from './export/command';\nimport importCommand from './import/command';\nimport transferCommand from './transfer/command';\n\nimport { StrapiCommand } from '../types';\n\nexport const commands: StrapiCommand[] = [\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n listMiddlewares,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n versionCommand,\n buildCommand,\n developCommand,\n exportCommand,\n importCommand,\n transferCommand,\n openAPICommand,\n /**\n * Cloud\n */\n cloudCommands,\n];\n"],"names":["commands","createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","listMiddlewares","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","versionCommand","buildCommand","developCommand","exportCommand","importCommand","transferCommand","openAPICommand","cloudCommands"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgCaA,QAA4B,GAAA;AACvCC,IAAAA,kBAAAA;AACAC,IAAAA,yBAAAA;AACAC,IAAAA,YAAAA;AACAC,IAAAA,YAAAA;AACAC,IAAAA,eAAAA;AACAC,IAAAA,eAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,gBAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,eAAAA;AACAC,IAAAA,cAAAA;AACAC,IAAAA,kBAAAA;AACAC,IAAAA,qBAAAA;AACAC,IAAAA,eAAAA;AACAC,IAAAA,aAAAA;AACAC,IAAAA,eAAAA;AACAC,IAAAA,OAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,aAAAA;AACA;;MAGAC;;;;;"}
|
|
@@ -22,6 +22,7 @@ import { command as command$8 } from './generate.mjs';
|
|
|
22
22
|
import { command as command$c } from './report.mjs';
|
|
23
23
|
import { command as command$f } from './start.mjs';
|
|
24
24
|
import { command as command$k } from './version.mjs';
|
|
25
|
+
import { command as command$q } from './openapi/index.mjs';
|
|
25
26
|
import command$n from './export/command.mjs';
|
|
26
27
|
import command$o from './import/command.mjs';
|
|
27
28
|
import command$p from './transfer/command.mjs';
|
|
@@ -53,6 +54,7 @@ const commands = [
|
|
|
53
54
|
command$n,
|
|
54
55
|
command$o,
|
|
55
56
|
command$p,
|
|
57
|
+
command$q,
|
|
56
58
|
/**
|
|
57
59
|
* Cloud
|
|
58
60
|
*/ buildStrapiCloudCommands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/cli/commands/index.ts"],"sourcesContent":["import { buildStrapiCloudCommands as cloudCommands } from '@strapi/cloud-cli';\n\nimport { command as createAdminUser } from './admin/create-user';\nimport { command as resetAdminUserPassword } from './admin/reset-user-password';\nimport { command as listComponents } from './components/list';\nimport { command as configurationDump } from './configuration/dump';\nimport { command as configurationRestore } from './configuration/restore';\nimport { command as listContentTypes } from './content-types/list';\nimport { command as listControllers } from './controllers/list';\nimport { command as listHooks } from './hooks/list';\nimport { command as listMiddlewares } from './middlewares/list';\nimport { command as listPolicies } from './policies/list';\nimport { command as listRoutes } from './routes/list';\nimport { command as listServices } from './services/list';\nimport { command as disableTelemetry } from './telemetry/disable';\nimport { command as enableTelemetry } from './telemetry/enable';\nimport { command as generateTemplates } from './templates/generate';\nimport { command as generateTsTypes } from './ts/generate-types';\nimport { command as buildCommand } from './build';\nimport { command as consoleCommand } from './console';\nimport { command as developCommand } from './develop';\nimport { command as generateCommand } from './generate';\nimport { command as reportCommand } from './report';\nimport { command as startCommand } from './start';\nimport { command as versionCommand } from './version';\nimport exportCommand from './export/command';\nimport importCommand from './import/command';\nimport transferCommand from './transfer/command';\n\nimport { StrapiCommand } from '../types';\n\nexport const commands: StrapiCommand[] = [\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n listMiddlewares,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n versionCommand,\n buildCommand,\n developCommand,\n exportCommand,\n importCommand,\n transferCommand,\n /**\n * Cloud\n */\n cloudCommands,\n];\n"],"names":["commands","createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","listMiddlewares","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","versionCommand","buildCommand","developCommand","exportCommand","importCommand","transferCommand","cloudCommands"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/cli/commands/index.ts"],"sourcesContent":["import { buildStrapiCloudCommands as cloudCommands } from '@strapi/cloud-cli';\n\nimport { command as createAdminUser } from './admin/create-user';\nimport { command as resetAdminUserPassword } from './admin/reset-user-password';\nimport { command as listComponents } from './components/list';\nimport { command as configurationDump } from './configuration/dump';\nimport { command as configurationRestore } from './configuration/restore';\nimport { command as listContentTypes } from './content-types/list';\nimport { command as listControllers } from './controllers/list';\nimport { command as listHooks } from './hooks/list';\nimport { command as listMiddlewares } from './middlewares/list';\nimport { command as listPolicies } from './policies/list';\nimport { command as listRoutes } from './routes/list';\nimport { command as listServices } from './services/list';\nimport { command as disableTelemetry } from './telemetry/disable';\nimport { command as enableTelemetry } from './telemetry/enable';\nimport { command as generateTemplates } from './templates/generate';\nimport { command as generateTsTypes } from './ts/generate-types';\nimport { command as buildCommand } from './build';\nimport { command as consoleCommand } from './console';\nimport { command as developCommand } from './develop';\nimport { command as generateCommand } from './generate';\nimport { command as reportCommand } from './report';\nimport { command as startCommand } from './start';\nimport { command as versionCommand } from './version';\nimport { command as openAPICommand } from './openapi';\nimport exportCommand from './export/command';\nimport importCommand from './import/command';\nimport transferCommand from './transfer/command';\n\nimport { StrapiCommand } from '../types';\n\nexport const commands: StrapiCommand[] = [\n createAdminUser,\n resetAdminUserPassword,\n listComponents,\n configurationDump,\n configurationRestore,\n consoleCommand,\n listContentTypes,\n listControllers,\n generateCommand,\n listHooks,\n listMiddlewares,\n listPolicies,\n reportCommand,\n listRoutes,\n listServices,\n startCommand,\n disableTelemetry,\n enableTelemetry,\n generateTemplates,\n generateTsTypes,\n versionCommand,\n buildCommand,\n developCommand,\n exportCommand,\n importCommand,\n transferCommand,\n openAPICommand,\n /**\n * Cloud\n */\n cloudCommands,\n];\n"],"names":["commands","createAdminUser","resetAdminUserPassword","listComponents","configurationDump","configurationRestore","consoleCommand","listContentTypes","listControllers","generateCommand","listHooks","listMiddlewares","listPolicies","reportCommand","listRoutes","listServices","startCommand","disableTelemetry","enableTelemetry","generateTemplates","generateTsTypes","versionCommand","buildCommand","developCommand","exportCommand","importCommand","transferCommand","openAPICommand","cloudCommands"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgCaA,QAA4B,GAAA;AACvCC,IAAAA,OAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACAC,IAAAA,SAAAA;AACA;;MAGAC;;;;;"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@strapi/core');
|
|
4
|
+
var openapi = require('@strapi/openapi');
|
|
5
|
+
var chalk = require('chalk');
|
|
6
|
+
var fse = require('fs-extra');
|
|
7
|
+
var path = require('path');
|
|
8
|
+
|
|
9
|
+
function _interopNamespaceDefault(e) {
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var openapi__namespace = /*#__PURE__*/_interopNamespaceDefault(openapi);
|
|
27
|
+
|
|
28
|
+
const DEFAULT_OUTPUT = path.join(process.cwd(), 'specification.json');
|
|
29
|
+
const EXPERIMENTAL_MSG = chalk.yellow(`
|
|
30
|
+
⚠️ The OpenAPI generation feature is currently experimental.
|
|
31
|
+
Its behavior and output might change in future releases without following semver.
|
|
32
|
+
Please report any issues you encounter on https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.yml.
|
|
33
|
+
`);
|
|
34
|
+
/**
|
|
35
|
+
* @experimental
|
|
36
|
+
*/ const action = async (options)=>{
|
|
37
|
+
console.warn(EXPERIMENTAL_MSG);
|
|
38
|
+
const filePath = options.output ?? DEFAULT_OUTPUT;
|
|
39
|
+
const app = await createStrapiApp();
|
|
40
|
+
const { document, durationMs } = openapi__namespace.generate(app, {
|
|
41
|
+
type: 'content-api'
|
|
42
|
+
});
|
|
43
|
+
writeDocumentToFile(document, filePath);
|
|
44
|
+
summarize(app, durationMs, filePath);
|
|
45
|
+
await teardownStrapiApp(app);
|
|
46
|
+
};
|
|
47
|
+
const createStrapiApp = async ()=>{
|
|
48
|
+
const appContext = await core.compileStrapi();
|
|
49
|
+
const app = core.createStrapi(appContext);
|
|
50
|
+
// Make sure to not log Strapi debug info
|
|
51
|
+
app.log.level = 'error';
|
|
52
|
+
// Load internals
|
|
53
|
+
await app.load();
|
|
54
|
+
// Make sure the routes are mounted before generating the specification
|
|
55
|
+
app.server.mount();
|
|
56
|
+
return app;
|
|
57
|
+
};
|
|
58
|
+
const writeDocumentToFile = (document, filePath)=>{
|
|
59
|
+
fse.outputFileSync(filePath, JSON.stringify(document, null, 2));
|
|
60
|
+
};
|
|
61
|
+
const teardownStrapiApp = async (app)=>{
|
|
62
|
+
await app.destroy();
|
|
63
|
+
};
|
|
64
|
+
const summarize = (app, durationMs, filePath)=>{
|
|
65
|
+
const cwd = process.cwd();
|
|
66
|
+
const relativeFilePath = path.relative(cwd, filePath);
|
|
67
|
+
const { name, version } = app.config.get('info');
|
|
68
|
+
const fName = chalk.cyan(name);
|
|
69
|
+
const fVersion = chalk.cyan(`v${version}`);
|
|
70
|
+
const fFile = chalk.magenta(relativeFilePath);
|
|
71
|
+
const fTime = chalk.green(`${durationMs}ms`);
|
|
72
|
+
console.log(chalk.bold(`Generated an OpenAPI specification for "${fName} ${fVersion}" at ${fFile} in ${fTime}`));
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.action = action;
|
|
76
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sources":["../../../../../src/cli/commands/openapi/generate.ts"],"sourcesContent":["import { compileStrapi, createStrapi } from '@strapi/core';\nimport * as openapi from '@strapi/openapi';\n\nimport type { Core } from '@strapi/types';\n\nimport chalk from 'chalk';\nimport fse from 'fs-extra';\nimport path from 'path';\n\nconst DEFAULT_OUTPUT = path.join(process.cwd(), 'specification.json');\n\ninterface CommandOptions {\n output?: string;\n}\n\ninterface StrapiInfoConfig {\n name: string;\n version: string;\n}\n\nconst EXPERIMENTAL_MSG = chalk.yellow(`\n⚠️ The OpenAPI generation feature is currently experimental.\n Its behavior and output might change in future releases without following semver.\n Please report any issues you encounter on https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.yml.\n`);\n\n/**\n * @experimental\n */\nconst action = async (options: CommandOptions) => {\n console.warn(EXPERIMENTAL_MSG);\n\n const filePath = options.output ?? DEFAULT_OUTPUT;\n const app = await createStrapiApp();\n\n const { document, durationMs } = openapi.generate(app, { type: 'content-api' });\n\n writeDocumentToFile(document, filePath);\n summarize(app, durationMs, filePath);\n\n await teardownStrapiApp(app);\n};\n\nconst createStrapiApp = async (): Promise<Core.Strapi> => {\n const appContext = await compileStrapi();\n const app = createStrapi(appContext);\n\n // Make sure to not log Strapi debug info\n app.log.level = 'error';\n\n // Load internals\n await app.load();\n\n // Make sure the routes are mounted before generating the specification\n app.server.mount();\n\n return app;\n};\n\nconst writeDocumentToFile = (document: unknown, filePath: string): void => {\n fse.outputFileSync(filePath, JSON.stringify(document, null, 2));\n};\n\nconst teardownStrapiApp = async (app: Core.Strapi) => {\n await app.destroy();\n};\n\nconst summarize = (app: Core.Strapi, durationMs: number, filePath: string): void => {\n const cwd = process.cwd();\n const relativeFilePath = path.relative(cwd, filePath);\n const { name, version } = app.config.get<StrapiInfoConfig>('info');\n\n const fName = chalk.cyan(name);\n const fVersion = chalk.cyan(`v${version}`);\n const fFile = chalk.magenta(relativeFilePath);\n const fTime = chalk.green(`${durationMs}ms`);\n\n console.log(\n chalk.bold(\n `Generated an OpenAPI specification for \"${fName} ${fVersion}\" at ${fFile} in ${fTime}`\n )\n );\n};\n\nexport { action };\n"],"names":["DEFAULT_OUTPUT","path","join","process","cwd","EXPERIMENTAL_MSG","chalk","yellow","action","options","console","warn","filePath","output","app","createStrapiApp","document","durationMs","openapi","generate","type","writeDocumentToFile","summarize","teardownStrapiApp","appContext","compileStrapi","createStrapi","log","level","load","server","mount","fse","outputFileSync","JSON","stringify","destroy","relativeFilePath","relative","name","version","config","get","fName","cyan","fVersion","fFile","magenta","fTime","green","bold"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAMA,iBAAiBC,IAAKC,CAAAA,IAAI,CAACC,OAAAA,CAAQC,GAAG,EAAI,EAAA,oBAAA,CAAA;AAWhD,MAAMC,gBAAmBC,GAAAA,KAAAA,CAAMC,MAAM,CAAC;;;;AAItC,CAAC,CAAA;AAED;;IAGA,MAAMC,SAAS,OAAOC,OAAAA,GAAAA;AACpBC,IAAAA,OAAAA,CAAQC,IAAI,CAACN,gBAAAA,CAAAA;IAEb,MAAMO,QAAAA,GAAWH,OAAQI,CAAAA,MAAM,IAAIb,cAAAA;AACnC,IAAA,MAAMc,MAAM,MAAMC,eAAAA,EAAAA;IAElB,MAAM,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGC,kBAAAA,CAAQC,QAAQ,CAACL,GAAK,EAAA;QAAEM,IA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MAAMM,QAAAA,GAAWvC,MAAMsC,IAAI,CAAC,CAAC,CAAC,EAAEJ,QAAQ,CAAC,CAAA;IACzC,MAAMM,KAAAA,GAAQxC,KAAMyC,CAAAA,OAAO,CAACV,gBAAAA,CAAAA;IAC5B,MAAMW,KAAAA,GAAQ1C,MAAM2C,KAAK,CAAC,CAAC,EAAEhC,UAAAA,CAAW,EAAE,CAAC,CAAA;AAE3CP,IAAAA,OAAAA,CAAQiB,GAAG,CACTrB,KAAAA,CAAM4C,IAAI,CACR,CAAC,wCAAwC,EAAEP,KAAAA,CAAM,CAAC,EAAEE,SAAS,KAAK,EAAEC,MAAM,IAAI,EAAEE,MAAM,CAAC,CAAA,CAAA;AAG7F,CAAA;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { compileStrapi, createStrapi } from '@strapi/core';
|
|
2
|
+
import * as openapi from '@strapi/openapi';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fse from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_OUTPUT = path.join(process.cwd(), 'specification.json');
|
|
8
|
+
const EXPERIMENTAL_MSG = chalk.yellow(`
|
|
9
|
+
⚠️ The OpenAPI generation feature is currently experimental.
|
|
10
|
+
Its behavior and output might change in future releases without following semver.
|
|
11
|
+
Please report any issues you encounter on https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.yml.
|
|
12
|
+
`);
|
|
13
|
+
/**
|
|
14
|
+
* @experimental
|
|
15
|
+
*/ const action = async (options)=>{
|
|
16
|
+
console.warn(EXPERIMENTAL_MSG);
|
|
17
|
+
const filePath = options.output ?? DEFAULT_OUTPUT;
|
|
18
|
+
const app = await createStrapiApp();
|
|
19
|
+
const { document, durationMs } = openapi.generate(app, {
|
|
20
|
+
type: 'content-api'
|
|
21
|
+
});
|
|
22
|
+
writeDocumentToFile(document, filePath);
|
|
23
|
+
summarize(app, durationMs, filePath);
|
|
24
|
+
await teardownStrapiApp(app);
|
|
25
|
+
};
|
|
26
|
+
const createStrapiApp = async ()=>{
|
|
27
|
+
const appContext = await compileStrapi();
|
|
28
|
+
const app = createStrapi(appContext);
|
|
29
|
+
// Make sure to not log Strapi debug info
|
|
30
|
+
app.log.level = 'error';
|
|
31
|
+
// Load internals
|
|
32
|
+
await app.load();
|
|
33
|
+
// Make sure the routes are mounted before generating the specification
|
|
34
|
+
app.server.mount();
|
|
35
|
+
return app;
|
|
36
|
+
};
|
|
37
|
+
const writeDocumentToFile = (document, filePath)=>{
|
|
38
|
+
fse.outputFileSync(filePath, JSON.stringify(document, null, 2));
|
|
39
|
+
};
|
|
40
|
+
const teardownStrapiApp = async (app)=>{
|
|
41
|
+
await app.destroy();
|
|
42
|
+
};
|
|
43
|
+
const summarize = (app, durationMs, filePath)=>{
|
|
44
|
+
const cwd = process.cwd();
|
|
45
|
+
const relativeFilePath = path.relative(cwd, filePath);
|
|
46
|
+
const { name, version } = app.config.get('info');
|
|
47
|
+
const fName = chalk.cyan(name);
|
|
48
|
+
const fVersion = chalk.cyan(`v${version}`);
|
|
49
|
+
const fFile = chalk.magenta(relativeFilePath);
|
|
50
|
+
const fTime = chalk.green(`${durationMs}ms`);
|
|
51
|
+
console.log(chalk.bold(`Generated an OpenAPI specification for "${fName} ${fVersion}" at ${fFile} in ${fTime}`));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { action };
|
|
55
|
+
//# sourceMappingURL=generate.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.mjs","sources":["../../../../../src/cli/commands/openapi/generate.ts"],"sourcesContent":["import { compileStrapi, createStrapi } from '@strapi/core';\nimport * as openapi from '@strapi/openapi';\n\nimport type { Core } from '@strapi/types';\n\nimport chalk from 'chalk';\nimport fse from 'fs-extra';\nimport path from 'path';\n\nconst DEFAULT_OUTPUT = path.join(process.cwd(), 'specification.json');\n\ninterface CommandOptions {\n output?: string;\n}\n\ninterface StrapiInfoConfig {\n name: string;\n version: string;\n}\n\nconst EXPERIMENTAL_MSG = chalk.yellow(`\n⚠️ The OpenAPI generation feature is currently experimental.\n Its behavior and output might change in future releases without following semver.\n Please report any issues you encounter on https://github.com/strapi/strapi/issues/new?template=BUG_REPORT.yml.\n`);\n\n/**\n * @experimental\n */\nconst action = async (options: CommandOptions) => {\n console.warn(EXPERIMENTAL_MSG);\n\n const filePath = options.output ?? DEFAULT_OUTPUT;\n const app = await createStrapiApp();\n\n const { document, durationMs } = openapi.generate(app, { type: 'content-api' });\n\n writeDocumentToFile(document, filePath);\n summarize(app, durationMs, filePath);\n\n await teardownStrapiApp(app);\n};\n\nconst createStrapiApp = async (): Promise<Core.Strapi> => {\n const appContext = await compileStrapi();\n const app = createStrapi(appContext);\n\n // Make sure to not log Strapi debug info\n app.log.level = 'error';\n\n // Load internals\n await app.load();\n\n // Make sure the routes are mounted before generating the specification\n app.server.mount();\n\n return app;\n};\n\nconst writeDocumentToFile = (document: unknown, filePath: string): void => {\n fse.outputFileSync(filePath, JSON.stringify(document, null, 2));\n};\n\nconst teardownStrapiApp = async (app: Core.Strapi) => {\n await app.destroy();\n};\n\nconst summarize = (app: Core.Strapi, durationMs: number, filePath: string): void => {\n const cwd = process.cwd();\n const relativeFilePath = path.relative(cwd, filePath);\n const { name, version } = app.config.get<StrapiInfoConfig>('info');\n\n const fName = chalk.cyan(name);\n const fVersion = chalk.cyan(`v${version}`);\n const fFile = chalk.magenta(relativeFilePath);\n const fTime = chalk.green(`${durationMs}ms`);\n\n console.log(\n chalk.bold(\n `Generated an OpenAPI specification for \"${fName} ${fVersion}\" at ${fFile} in ${fTime}`\n )\n );\n};\n\nexport { action };\n"],"names":["DEFAULT_OUTPUT","path","join","process","cwd","EXPERIMENTAL_MSG","chalk","yellow","action","options","console","warn","filePath","output","app","createStrapiApp","document","durationMs","openapi","generate","type","writeDocumentToFile","summarize","teardownStrapiApp","appContext","compileStrapi","createStrapi","log","level","load","server","mount","fse","outputFileSync","JSON","stringify","destro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ACnB,UAAU,IAAM,EAAA,CAAA,CAAA,CAAA;AAC9D,CAAA;AAEA,MAAMO,oBAAoB,OAAOT,GAAAA,GAAAA;AAC/B,IAAA,MAAMA,IAAIsB,OAAO,EAAA;AACnB,CAAA;AAEA,MAAMd,SAAAA,GAAY,CAACR,GAAAA,EAAkBG,UAAoBL,EAAAA,QAAAA,GAAAA;IACvD,MAAMR,GAAAA,GAAMD,QAAQC,GAAG,EAAA;AACvB,IAAA,MAAMiC,gBAAmBpC,GAAAA,IAAAA,CAAKqC,QAAQ,CAAClC,GAAKQ,EAAAA,QAAAA,CAAAA;IAC5C,MAAM,EAAE2B,IAAI,EAAEC,OAAO,EAAE,GAAG1B,GAAI2B,CAAAA,MAAM,CAACC,GAAG,CAAmB,MAAA,CAAA;IAE3D,MAAMC,KAAAA,GAAQrC,KAAMsC,CAAAA,IAAI,CAACL,IAAAA,CAAAA;IACzB,MAAMM,QAAAA,GAAWvC,MAAMsC,IAAI,CAAC,CAAC,CAAC,EAAEJ,QAAQ,CAAC,CAAA;IACzC,MAAMM,KAAAA,GAAQxC,KAAMyC,CAAAA,OAAO,CAACV,gBAAAA,CAAAA;IAC5B,MAAMW,KAAAA,GAAQ1C,MAAM2C,KAAK,CAAC,CAAC,EAAEhC,UAAAA,CAAW,EAAE,CAAC,CAAA;AAE3CP,IAAAA,OAAAA,CAAQiB,GAAG,CACTrB,KAAAA,CAAM4C,IAAI,CACR,CAAC,wCAAwC,EAAEP,KAAAA,CAAM,CAAC,EAAEE,SAAS,KAAK,EAAEC,MAAM,IAAI,EAAEE,MAAM,CAAC,CAAA,CAAA;AAG7F,CAAA;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var commander = require('commander');
|
|
4
|
+
var helpers = require('../../utils/helpers.js');
|
|
5
|
+
var generate = require('./generate.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `$ strapi openapi`
|
|
9
|
+
*/ const command = ()=>{
|
|
10
|
+
const openapi = commander.createCommand('openapi').description('Manage OpenAPI specifications for your Strapi application');
|
|
11
|
+
// `$ strapi openapi generate [-o, --output <path>]`
|
|
12
|
+
openapi.command('generate').description('Generate an OpenAPI specification for the current Strapi application').option('-o, --output <path>', 'Output file path for the OpenAPI specification').action(helpers.runAction('openapi:generate', generate.action));
|
|
13
|
+
return openapi;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.command = command;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/cli/commands/openapi/index.ts"],"sourcesContent":["import { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport { action as generate } from './generate';\n\n/**\n * `$ strapi openapi`\n */\nconst command: StrapiCommand = () => {\n const openapi = createCommand('openapi').description(\n 'Manage OpenAPI specifications for your Strapi application'\n );\n\n // `$ strapi openapi generate [-o, --output <path>]`\n openapi\n .command('generate')\n .description('Generate an OpenAPI specification for the current Strapi application')\n .option('-o, --output <path>', 'Output file path for the OpenAPI specification')\n .action(runAction('openapi:generate', generate));\n\n return openapi;\n};\n\nexport { command };\n"],"names":["command","openapi","createCommand","description","option","action","runAction","generate"],"mappings":";;;;;;AAMA;;AAEC,UACKA,OAAyB,GAAA,IAAA;AAC7B,IAAA,MAAMC,OAAUC,GAAAA,uBAAAA,CAAc,SAAWC,CAAAA,CAAAA,WAAW,CAClD,2DAAA,CAAA;;AAIFF,IAAAA,OAAAA,CACGD,OAAO,CAAC,UACRG,CAAAA,CAAAA,WAAW,CAAC,sEAAA,CAAA,CACZC,MAAM,CAAC,qBAAuB,EAAA,gDAAA,CAAA,CAC9BC,MAAM,CAACC,kBAAU,kBAAoBC,EAAAA,eAAAA,CAAAA,CAAAA;IAExC,OAAON,OAAAA;AACT;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createCommand } from 'commander';
|
|
2
|
+
import { runAction } from '../../utils/helpers.mjs';
|
|
3
|
+
import { action } from './generate.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `$ strapi openapi`
|
|
7
|
+
*/ const command = ()=>{
|
|
8
|
+
const openapi = createCommand('openapi').description('Manage OpenAPI specifications for your Strapi application');
|
|
9
|
+
// `$ strapi openapi generate [-o, --output <path>]`
|
|
10
|
+
openapi.command('generate').description('Generate an OpenAPI specification for the current Strapi application').option('-o, --output <path>', 'Output file path for the OpenAPI specification').action(runAction('openapi:generate', action));
|
|
11
|
+
return openapi;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { command };
|
|
15
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../../src/cli/commands/openapi/index.ts"],"sourcesContent":["import { createCommand } from 'commander';\n\nimport type { StrapiCommand } from '../../types';\nimport { runAction } from '../../utils/helpers';\nimport { action as generate } from './generate';\n\n/**\n * `$ strapi openapi`\n */\nconst command: StrapiCommand = () => {\n const openapi = createCommand('openapi').description(\n 'Manage OpenAPI specifications for your Strapi application'\n );\n\n // `$ strapi openapi generate [-o, --output <path>]`\n openapi\n .command('generate')\n .description('Generate an OpenAPI specification for the current Strapi application')\n .option('-o, --output <path>', 'Output file path for the OpenAPI specification')\n .action(runAction('openapi:generate', generate));\n\n return openapi;\n};\n\nexport { command };\n"],"names":["command","openapi","createCommand","description","option","action","runAction","generate"],"mappings":";;;;AAMA;;AAEC,UACKA,OAAyB,GAAA,IAAA;AAC7B,IAAA,MAAMC,OAAUC,GAAAA,aAAAA,CAAc,SAAWC,CAAAA,CAAAA,WAAW,CAClD,2DAAA,CAAA;;AAIFF,IAAAA,OAAAA,CACGD,OAAO,CAAC,UACRG,CAAAA,CAAAA,WAAW,CAAC,sEAAA,CAAA,CACZC,MAAM,CAAC,qBAAuB,EAAA,gDAAA,CAAA,CAC9BC,MAAM,CAACC,UAAU,kBAAoBC,EAAAA,MAAAA,CAAAA,CAAAA;IAExC,OAAON,OAAAA;AACT;;;;"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
var utils = require('@strapi/utils');
|
|
4
4
|
|
|
5
5
|
const sendEvent = async (event, uuid, installId)=>{
|
|
6
|
+
const analyticsUrl = utils.env('STRAPI_ANALYTICS_URL', 'https://analytics.strapi.io');
|
|
6
7
|
try {
|
|
7
|
-
await fetch(
|
|
8
|
+
await fetch(`${analyticsUrl}/api/v2/track`, {
|
|
8
9
|
method: 'POST',
|
|
9
10
|
body: JSON.stringify({
|
|
10
11
|
event,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sources":["../../../../src/cli/utils/telemetry.ts"],"sourcesContent":["import { generateInstallId } from '@strapi/utils';\n\nexport const sendEvent = async (event: string, uuid: string, installId?: any) => {\n
|
|
1
|
+
{"version":3,"file":"telemetry.js","sources":["../../../../src/cli/utils/telemetry.ts"],"sourcesContent":["import { generateInstallId, env } from '@strapi/utils';\n\nexport const sendEvent = async (event: string, uuid: string, installId?: any) => {\n const analyticsUrl = env('STRAPI_ANALYTICS_URL', 'https://analytics.strapi.io');\n try {\n await fetch(`${analyticsUrl}/api/v2/track`, {\n method: 'POST',\n body: JSON.stringify({\n event,\n deviceId: generateInstallId(uuid, installId),\n groupProperties: { projectId: uuid },\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'X-Strapi-Event': event,\n },\n });\n } catch (e) {\n // ...\n }\n};\n"],"names":["sendEvent","event","uuid","installId","analyticsUrl","env","fetch","method","body","JSON","stringify","deviceId","generateInstallId","groupProperties","projectId","headers","e"],"mappings":";;;;AAEaA,MAAAA,SAAAA,GAAY,OAAOC,KAAAA,EAAeC,IAAcC,EAAAA,SAAAA,GAAAA;IAC3D,MAAMC,YAAAA,GAAeC,UAAI,sBAAwB,EAAA,6BAAA,CAAA;IACjD,IAAI;AACF,QAAA,MAAMC,MAAM,CAAC,EAAEF,YAAa,CAAA,aAAa,CAAC,EAAE;YAC1CG,MAAQ,EAAA,MAAA;YACRC,IAAMC,EAAAA,IAAAA,CAAKC,SAAS,CAAC;AACnBT,gBAAAA,KAAAA;AACAU,gBAAAA,QAAAA,EAAUC,wBAAkBV,IAAMC,EAAAA,SAAAA,CAAAA;gBAClCU,eAAiB,EAAA;oBAAEC,SAAWZ,EAAAA;AAAK;AACrC,aAAA,CAAA;YACAa,OAAS,EAAA;gBACP,cAAgB,EAAA,kBAAA;gBAChB,gBAAkBd,EAAAA;AACpB;AACF,SAAA,CAAA;AACF,KAAA,CAAE,OAAOe,CAAG,EAAA;;AAEZ;AACF;;;;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { generateInstallId } from '@strapi/utils';
|
|
1
|
+
import { env, generateInstallId } from '@strapi/utils';
|
|
2
2
|
|
|
3
3
|
const sendEvent = async (event, uuid, installId)=>{
|
|
4
|
+
const analyticsUrl = env('STRAPI_ANALYTICS_URL', 'https://analytics.strapi.io');
|
|
4
5
|
try {
|
|
5
|
-
await fetch(
|
|
6
|
+
await fetch(`${analyticsUrl}/api/v2/track`, {
|
|
6
7
|
method: 'POST',
|
|
7
8
|
body: JSON.stringify({
|
|
8
9
|
event,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.mjs","sources":["../../../../src/cli/utils/telemetry.ts"],"sourcesContent":["import { generateInstallId } from '@strapi/utils';\n\nexport const sendEvent = async (event: string, uuid: string, installId?: any) => {\n
|
|
1
|
+
{"version":3,"file":"telemetry.mjs","sources":["../../../../src/cli/utils/telemetry.ts"],"sourcesContent":["import { generateInstallId, env } from '@strapi/utils';\n\nexport const sendEvent = async (event: string, uuid: string, installId?: any) => {\n const analyticsUrl = env('STRAPI_ANALYTICS_URL', 'https://analytics.strapi.io');\n try {\n await fetch(`${analyticsUrl}/api/v2/track`, {\n method: 'POST',\n body: JSON.stringify({\n event,\n deviceId: generateInstallId(uuid, installId),\n groupProperties: { projectId: uuid },\n }),\n headers: {\n 'Content-Type': 'application/json',\n 'X-Strapi-Event': event,\n },\n });\n } catch (e) {\n // ...\n }\n};\n"],"names":["sendEvent","event","uuid","installId","analyticsUrl","env","fetch","method","body","JSON","stringify","deviceId","generateInstallId","groupProperties","projectId","headers","e"],"mappings":";;AAEaA,MAAAA,SAAAA,GAAY,OAAOC,KAAAA,EAAeC,IAAcC,EAAAA,SAAAA,GAAAA;IAC3D,MAAMC,YAAAA,GAAeC,IAAI,sBAAwB,EAAA,6BAAA,CAAA;IACjD,IAAI;AACF,QAAA,MAAMC,MAAM,CAAC,EAAEF,YAAa,CAAA,aAAa,CAAC,EAAE;YAC1CG,MAAQ,EAAA,MAAA;YACRC,IAAMC,EAAAA,IAAAA,CAAKC,SAAS,CAAC;AACnBT,gBAAAA,KAAAA;AACAU,gBAAAA,QAAAA,EAAUC,kBAAkBV,IAAMC,EAAAA,SAAAA,CAAAA;gBAClCU,eAAiB,EAAA;oBAAEC,SAAWZ,EAAAA;AAAK;AACrC,aAAA,CAAA;YACAa,OAAS,EAAA;gBACP,cAAgB,EAAA,kBAAA;gBAChB,gBAAkBd,EAAAA;AACpB;AACF,SAAA,CAAA;AACF,KAAA,CAAE,OAAOe,CAAG,EAAA;;AAEZ;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sources":["../../../../src/node/core/env.ts"],"sourcesContent":["import path from 'node:path';\nimport dotenv from 'dotenv';\nimport { pathExists } from './files';\n\n/**\n * This is the base of _any_ env set for a strapi project,\n * to build a strapi admin panel we require these env variables.\n */\ninterface DefaultEnv {\n ADMIN_PATH: string;\n STRAPI_ADMIN_BACKEND_URL: string;\n STRAPI_TELEMETRY_DISABLED: string;\n}\n\n/**\n * @internal\n *\n * @description Load the .env file if it exists\n */\nconst loadEnv = async (cwd: string) => {\n const pathToEnv = path.resolve(cwd, '.env');\n\n if (await pathExists(pathToEnv)) {\n dotenv.config({ path: pathToEnv });\n }\n};\n\n/**\n * @internal\n *\n * @description Get all the environment variables that start with `STRAPI_ADMIN_`\n */\nconst getStrapiAdminEnvVars = (defaultEnv: DefaultEnv): Record<string, string> => {\n return Object.keys(process.env)\n .filter((key) => key.toUpperCase().startsWith('STRAPI_ADMIN_'))\n .reduce(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["loadEnv","cwd","pathToEnv","path","resolve","pathExists","dotenv","config","getStrapiAdminEnvVars","defaultEnv","Object","keys","process","env","filter","key","toUpperCase","startsWith","reduce","acc"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"env.js","sources":["../../../../src/node/core/env.ts"],"sourcesContent":["import path from 'node:path';\nimport dotenv from 'dotenv';\nimport { pathExists } from './files';\n\n/**\n * This is the base of _any_ env set for a strapi project,\n * to build a strapi admin panel we require these env variables.\n */\ninterface DefaultEnv {\n ADMIN_PATH: string;\n STRAPI_ADMIN_BACKEND_URL: string;\n STRAPI_TELEMETRY_DISABLED: string;\n STRAPI_ANALYTICS_URL?: string;\n}\n\n/**\n * @internal\n *\n * @description Load the .env file if it exists\n */\nconst loadEnv = async (cwd: string) => {\n const pathToEnv = path.resolve(cwd, '.env');\n\n if (await pathExists(pathToEnv)) {\n dotenv.config({ path: pathToEnv });\n }\n};\n\n/**\n * @internal\n *\n * @description Get all the environment variables that start with `STRAPI_ADMIN_`\n */\nconst getStrapiAdminEnvVars = (defaultEnv: DefaultEnv): Record<string, string> => {\n return Object.keys(process.env)\n .filter((key) => key.toUpperCase().startsWith('STRAPI_ADMIN_'))\n .reduce(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["loadEnv","cwd","pathToEnv","path","resolve","pathExists","dotenv","config","getStrapiAdminEnvVars","defaultEnv","Object","keys","process","env","filter","key","toUpperCase","startsWith","reduce","acc"],"mappings":";;;;;;AAeA;;;;IAKA,MAAMA,UAAU,OAAOC,GAAAA,GAAAA;AACrB,IAAA,MAAMC,SAAYC,GAAAA,IAAAA,CAAKC,OAAO,CAACH,GAAK,EAAA,MAAA,CAAA;IAEpC,IAAI,MAAMI,iBAAWH,SAAY,CAAA,EAAA;AAC/BI,QAAAA,MAAAA,CAAOC,MAAM,CAAC;YAAEJ,IAAMD,EAAAA;AAAU,SAAA,CAAA;AAClC;AACF;AAEA;;;;IAKA,MAAMM,wBAAwB,CAACC,UAAAA,GAAAA;AAC7B,IAAA,OAAOC,OAAOC,IAAI,CAACC,QAAQC,GAAG,CAAA,CAC3BC,MAAM,CAAC,CAACC,MAAQA,GAAIC,CAAAA,WAAW,GAAGC,UAAU,CAAC,kBAC7CC,MAAM,CACL,CAACC,GAAKJ,EAAAA,GAAAA,GAAAA;AACJI,QAAAA,GAAG,CAACJ,GAAI,CAAA,GAAGH,OAAQC,CAAAA,GAAG,CAACE,GAAI,CAAA;QAE3B,OAAOI,GAAAA;KAETV,EAAAA,UAAAA,CAAAA;AAEN;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","sources":["../../../../src/node/core/env.ts"],"sourcesContent":["import path from 'node:path';\nimport dotenv from 'dotenv';\nimport { pathExists } from './files';\n\n/**\n * This is the base of _any_ env set for a strapi project,\n * to build a strapi admin panel we require these env variables.\n */\ninterface DefaultEnv {\n ADMIN_PATH: string;\n STRAPI_ADMIN_BACKEND_URL: string;\n STRAPI_TELEMETRY_DISABLED: string;\n}\n\n/**\n * @internal\n *\n * @description Load the .env file if it exists\n */\nconst loadEnv = async (cwd: string) => {\n const pathToEnv = path.resolve(cwd, '.env');\n\n if (await pathExists(pathToEnv)) {\n dotenv.config({ path: pathToEnv });\n }\n};\n\n/**\n * @internal\n *\n * @description Get all the environment variables that start with `STRAPI_ADMIN_`\n */\nconst getStrapiAdminEnvVars = (defaultEnv: DefaultEnv): Record<string, string> => {\n return Object.keys(process.env)\n .filter((key) => key.toUpperCase().startsWith('STRAPI_ADMIN_'))\n .reduce(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["loadEnv","cwd","pathToEnv","path","resolve","pathExists","dotenv","config","getStrapiAdminEnvVars","defaultEnv","Object","keys","process","env","filter","key","toUpperCase","startsWith","reduce","acc"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"env.mjs","sources":["../../../../src/node/core/env.ts"],"sourcesContent":["import path from 'node:path';\nimport dotenv from 'dotenv';\nimport { pathExists } from './files';\n\n/**\n * This is the base of _any_ env set for a strapi project,\n * to build a strapi admin panel we require these env variables.\n */\ninterface DefaultEnv {\n ADMIN_PATH: string;\n STRAPI_ADMIN_BACKEND_URL: string;\n STRAPI_TELEMETRY_DISABLED: string;\n STRAPI_ANALYTICS_URL?: string;\n}\n\n/**\n * @internal\n *\n * @description Load the .env file if it exists\n */\nconst loadEnv = async (cwd: string) => {\n const pathToEnv = path.resolve(cwd, '.env');\n\n if (await pathExists(pathToEnv)) {\n dotenv.config({ path: pathToEnv });\n }\n};\n\n/**\n * @internal\n *\n * @description Get all the environment variables that start with `STRAPI_ADMIN_`\n */\nconst getStrapiAdminEnvVars = (defaultEnv: DefaultEnv): Record<string, string> => {\n return Object.keys(process.env)\n .filter((key) => key.toUpperCase().startsWith('STRAPI_ADMIN_'))\n .reduce(\n (acc, key) => {\n acc[key] = process.env[key] as string;\n\n return acc;\n },\n defaultEnv as unknown as Record<string, string>\n );\n};\n\nexport { getStrapiAdminEnvVars, loadEnv };\n"],"names":["loadEnv","cwd","pathToEnv","path","resolve","pathExists","dotenv","config","getStrapiAdminEnvVars","defaultEnv","Object","keys","process","env","filter","key","toUpperCase","startsWith","reduce","acc"],"mappings":";;;;AAeA;;;;IAKA,MAAMA,UAAU,OAAOC,GAAAA,GAAAA;AACrB,IAAA,MAAMC,SAAYC,GAAAA,IAAAA,CAAKC,OAAO,CAACH,GAAK,EAAA,MAAA,CAAA;IAEpC,IAAI,MAAMI,WAAWH,SAAY,CAAA,EAAA;AAC/BI,QAAAA,MAAAA,CAAOC,MAAM,CAAC;YAAEJ,IAAMD,EAAAA;AAAU,SAAA,CAAA;AAClC;AACF;AAEA;;;;IAKA,MAAMM,wBAAwB,CAACC,UAAAA,GAAAA;AAC7B,IAAA,OAAOC,OAAOC,IAAI,CAACC,QAAQC,GAAG,CAAA,CAC3BC,MAAM,CAAC,CAACC,MAAQA,GAAIC,CAAAA,WAAW,GAAGC,UAAU,CAAC,kBAC7CC,MAAM,CACL,CAACC,GAAKJ,EAAAA,GAAAA,GAAAA;AACJI,QAAAA,GAAG,CAACJ,GAAI,CAAA,GAAGH,OAAQC,CAAAA,GAAG,CAACE,GAAI,CAAA;QAE3B,OAAOI,GAAAA;KAETV,EAAAA,UAAAA,CAAAA;AAEN;;;;"}
|
|
@@ -40,7 +40,8 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
|
|
|
40
40
|
const env$1 = env.getStrapiAdminEnvVars({
|
|
41
41
|
ADMIN_PATH: adminPublicPath,
|
|
42
42
|
STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,
|
|
43
|
-
STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled)
|
|
43
|
+
STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),
|
|
44
|
+
STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io'
|
|
44
45
|
});
|
|
45
46
|
const envKeys = Object.keys(env$1);
|
|
46
47
|
if (envKeys.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.js","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","envKeys","Object","keys","length","info","map","key","join","os","EOL","distPath","path","dist","relative","debug","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;AAkDA,MAAMA,oBAAuB,GAAA;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAqB,GAAA,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAU,GAAA,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cACJF,GAAAA,MAAAA,IACAG,iBAAa,CAAA;;QAEXC,MAAQP,EAAAA,GAAAA;QACRQ,OAASN,EAAAA,QAAAA,EAAUO,MAAOL,CAAAA,OAAAA,CAAQM,MAAU,IAAA,EAAA;;QAE5CC,UAAY,EAAA,IAAA;QACZC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAoBR,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAmBV,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAYX,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,YAAA,CAAA;;IAGpD,MAAMG,UAAAA,GAAa,IAAIC,GAAIH,CAAAA,gBAAAA,CAAAA,CAAkBI,MAAM,KAAK,IAAID,GAAIL,CAAAA,iBAAAA,CAAAA,CAAmBM,MAAM;AAEzF,IAAA,MAAMC,eAAkB,GAAA,IAAIF,GAAIH,CAAAA,gBAAAA,CAAAA,CAAkBM,QAAQ;AAC1D,IAAA,MAAMC,gBAAmB,GAAA,IAAIJ,GAAIL,CAAAA,iBAAAA,CAAAA,CAAmBQ,QAAQ;AAE5D,IAAA,MAAMd,SAASF,cAAekB,CAAAA,IAAI,CAACC,GAAG,CAACC,IAAI;AAE3C,IAAA,MAAMC,WAAQ1B,CAAAA,GAAAA,CAAAA;AAEd,IAAA,MAAM2B,QAAMC,yBAAsB,CAAA;QAChCC,UAAYT,EAAAA,eAAAA;AACZU,QAAAA,wBAAAA,EAA0Bb,aAAaK,gBAAmBT,GAAAA,iBAAAA;AAC1DkB,QAAAA,yBAAAA,EAA2BC,MAAO3B,CAAAA,cAAAA,CAAe4B,SAAS,CAACC,UAAU;
|
|
1
|
+
{"version":3,"file":"create-build-context.js","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_ANALYTICS_URL","process","envKeys","Object","keys","length","info","map","key","join","os","EOL","distPath","path","dist","relative","debug","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;AAkDA,MAAMA,oBAAuB,GAAA;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAqB,GAAA,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAU,GAAA,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cACJF,GAAAA,MAAAA,IACAG,iBAAa,CAAA;;QAEXC,MAAQP,EAAAA,GAAAA;QACRQ,OAASN,EAAAA,QAAAA,EAAUO,MAAOL,CAAAA,OAAAA,CAAQM,MAAU,IAAA,EAAA;;QAE5CC,UAAY,EAAA,IAAA;QACZC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAoBR,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAmBV,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAYX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A;IAEzD,MAAMmE,cAAAA,GAAiB,MAAMC,mCAAgB,CAAA;AAAE3D,QAAAA,MAAAA;AAAQiD,QAAAA;AAAW,KAAA,CAAA;AAElE,IAAA,MAAMW,WAAW9D,cAAeI,CAAAA,MAAM,CAACK,GAAG,CAAC,UAAYsD,EAAAA,SAAAA,CAAAA;AAEvD,IAAA,MAAM,EAAEC,OAAU,GAAA,MAAM,EAAE,GAAGC,aAAa,GAAGlE,OAAAA;AAE7C,IAAA,MAAMmE,YAAe,GAAA;AACnBhE,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;QACAwD,QAAUpD,EAAAA,eAAAA;AACViD,QAAAA,OAAAA;AACAJ,QAAAA,cAAAA;AACAjE,QAAAA,GAAAA;AACAQ,QAAAA,OAAAA;AACAuC,QAAAA,QAAAA;AACAU,QAAAA,KAAAA;AACA9B,aAAAA,KAAAA;AACAwC,QAAAA,QAAAA;AACAlE,QAAAA,MAAAA;QACAG,OAASkE,EAAAA,WAAAA;QACTZ,OAASE,EAAAA,gBAAAA;AACTJ,QAAAA,UAAAA;QACArD,MAAQE,EAAAA,cAAAA;AACRyD,QAAAA,MAAAA;AACA5D,QAAAA;AACF,KAAA;IAEA,OAAOqE,YAAAA;AACT;;;;"}
|
|
@@ -38,7 +38,8 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
|
|
|
38
38
|
const env = getStrapiAdminEnvVars({
|
|
39
39
|
ADMIN_PATH: adminPublicPath,
|
|
40
40
|
STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,
|
|
41
|
-
STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled)
|
|
41
|
+
STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),
|
|
42
|
+
STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io'
|
|
42
43
|
});
|
|
43
44
|
const envKeys = Object.keys(env);
|
|
44
45
|
if (envKeys.length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.mjs","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","envKeys","Object","keys","length","info","map","key","join","os","EOL","distPath","path","dist","relative","debug","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;AAkDA,MAAMA,oBAAuB,GAAA;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAqB,GAAA,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAU,GAAA,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cACJF,GAAAA,MAAAA,IACAG,YAAa,CAAA;;QAEXC,MAAQP,EAAAA,GAAAA;QACRQ,OAASN,EAAAA,QAAAA,EAAUO,MAAOL,CAAAA,OAAAA,CAAQM,MAAU,IAAA,EAAA;;QAE5CC,UAAY,EAAA,IAAA;QACZC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAoBR,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAmBV,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAYX,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,YAAA,CAAA;;IAGpD,MAAMG,UAAAA,GAAa,IAAIC,GAAIH,CAAAA,gBAAAA,CAAAA,CAAkBI,MAAM,KAAK,IAAID,GAAIL,CAAAA,iBAAAA,CAAAA,CAAmBM,MAAM;AAEzF,IAAA,MAAMC,eAAkB,GAAA,IAAIF,GAAIH,CAAAA,gBAAAA,CAAAA,CAAkBM,QAAQ;AAC1D,IAAA,MAAMC,gBAAmB,GAAA,IAAIJ,GAAIL,CAAAA,iBAAAA,CAAAA,CAAmBQ,QAAQ;AAE5D,IAAA,MAAMd,SAASF,cAAekB,CAAAA,IAAI,CAACC,GAAG,CAACC,IAAI;AAE3C,IAAA,MAAMC,OAAQ1B,CAAAA,GAAAA,CAAAA;AAEd,IAAA,MAAM2B,MAAMC,qBAAsB,CAAA;QAChCC,UAAYT,EAAAA,eAAAA;AACZU,QAAAA,wBAAAA,EAA0Bb,aAAaK,gBAAmBT,GAAAA,iBAAAA;AAC1DkB,QAAAA,yBAAAA,EAA2BC,MAAO3B,CAAAA,cAAAA,CAAe4B,SAAS,CAACC,UAAU;
|
|
1
|
+
{"version":3,"file":"create-build-context.mjs","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n hmrServer?: Server;\n hmrClientPort?: number;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_ANALYTICS_URL","process","envKeys","Object","keys","length","info","map","key","join","os","EOL","distPath","path","dist","relative","debug","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;AAkDA,MAAMA,oBAAuB,GAAA;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAqB,GAAA,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAU,GAAA,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cACJF,GAAAA,MAAAA,IACAG,YAAa,CAAA;;QAEXC,MAAQP,EAAAA,GAAAA;QACRQ,OAASN,EAAAA,QAAAA,EAAUO,MAAOL,CAAAA,OAAAA,CAAQM,MAAU,IAAA,EAAA;;QAE5CC,UAAY,EAAA,IAAA;QACZC,eAAiB,EAAA;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAoBR,GAAAA,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,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EAAEc,gBAAAA,CAAAA;IAEhD,MAAME,MAAAA,GAASC,YAAaC,CAAAA,UAAU,CAAC;QAAEhB,IAAMhD,EAAAA;KAAUF,CAAAA,IAAAA,oBAAAA;IAEzD,MAAMmE,cAAAA,GAAiB,MAAMC,eAAgB,CAAA;AAAE3D,QAAAA,MAAAA;AAAQiD,QAAAA;AAAW,KAAA,CAAA;AAElE,IAAA,MAAMW,WAAW9D,cAAeI,CAAAA,MAAM,CAACK,GAAG,CAAC,UAAYsD,EAAAA,SAAAA,CAAAA;AAEvD,IAAA,MAAM,EAAEC,OAAU,GAAA,MAAM,EAAE,GAAGC,aAAa,GAAGlE,OAAAA;AAE7C,IAAA,MAAMmE,YAAe,GAAA;AACnBhE,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;QACAwD,QAAUpD,EAAAA,eAAAA;AACViD,QAAAA,OAAAA;AACAJ,QAAAA,cAAAA;AACAjE,QAAAA,GAAAA;AACAQ,QAAAA,OAAAA;AACAuC,QAAAA,QAAAA;AACAU,QAAAA,KAAAA;AACA9B,QAAAA,GAAAA;AACAwC,QAAAA,QAAAA;AACAlE,QAAAA,MAAAA;QACAG,OAASkE,EAAAA,WAAAA;QACTZ,OAASE,EAAAA,gBAAAA;AACTJ,QAAAA,UAAAA;QACArD,MAAQE,EAAAA,cAAAA;AACRyD,QAAAA,MAAAA;AACA5D,QAAAA;AACF,KAAA;IAEA,OAAOqE,YAAAA;AACT;;;;"}
|
|
@@ -9,6 +9,7 @@ var plugins = require('./plugins.js');
|
|
|
9
9
|
|
|
10
10
|
const resolveBaseConfig = async (ctx)=>{
|
|
11
11
|
const target = browserslistToEsbuild(ctx.target);
|
|
12
|
+
const isMonorepoExampleApp = ctx.strapi.internal_config?.uuid === 'getstarted';
|
|
12
13
|
return {
|
|
13
14
|
root: ctx.cwd,
|
|
14
15
|
base: ctx.basePath,
|
|
@@ -32,7 +33,64 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
32
33
|
`react/jsx-runtime`,
|
|
33
34
|
'react-dom/client',
|
|
34
35
|
'styled-components',
|
|
35
|
-
'react-router-dom'
|
|
36
|
+
'react-router-dom',
|
|
37
|
+
/**
|
|
38
|
+
* Pre-bundle other dependencies that would otherwise cause a page reload when imported.
|
|
39
|
+
* See "performance" section: https://vite.dev/guide/dep-pre-bundling.html#the-why
|
|
40
|
+
* Only include dependencies for our internal example apps, otherwise it will break
|
|
41
|
+
* real user apps that may not have those dependencies.
|
|
42
|
+
*/ ...isMonorepoExampleApp ? [
|
|
43
|
+
'@dnd-kit/core',
|
|
44
|
+
'@dnd-kit/sortable',
|
|
45
|
+
'@dnd-kit/utilities',
|
|
46
|
+
'@dnd-kit/modifiers',
|
|
47
|
+
'@radix-ui/react-toolbar',
|
|
48
|
+
'codemirror5',
|
|
49
|
+
'codemirror5/addon/display/placeholder',
|
|
50
|
+
'date-fns-tz',
|
|
51
|
+
'date-fns/format',
|
|
52
|
+
'date-fns/formatISO',
|
|
53
|
+
'highlight.js',
|
|
54
|
+
'lodash/capitalize',
|
|
55
|
+
'lodash/fp',
|
|
56
|
+
'lodash/groupBy',
|
|
57
|
+
'lodash/has',
|
|
58
|
+
'lodash/isNil',
|
|
59
|
+
'lodash/locale',
|
|
60
|
+
'lodash/map',
|
|
61
|
+
'lodash/mapValues',
|
|
62
|
+
'lodash/pull',
|
|
63
|
+
'lodash/size',
|
|
64
|
+
'lodash/sortBy',
|
|
65
|
+
'lodash/tail',
|
|
66
|
+
'lodash/toLower',
|
|
67
|
+
'lodash/toNumber',
|
|
68
|
+
'lodash/toString',
|
|
69
|
+
'lodash/truncate',
|
|
70
|
+
'lodash/uniq',
|
|
71
|
+
'lodash/upperFirst',
|
|
72
|
+
'markdown-it',
|
|
73
|
+
'markdown-it-abbr',
|
|
74
|
+
'markdown-it-container',
|
|
75
|
+
'markdown-it-deflist',
|
|
76
|
+
'markdown-it-emoji',
|
|
77
|
+
'markdown-it-footnote',
|
|
78
|
+
'markdown-it-ins',
|
|
79
|
+
'markdown-it-mark',
|
|
80
|
+
'markdown-it-sub',
|
|
81
|
+
'markdown-it-sup',
|
|
82
|
+
'prismjs/components/*.js',
|
|
83
|
+
'react-colorful',
|
|
84
|
+
'react-dnd-html5-backend',
|
|
85
|
+
'react-window',
|
|
86
|
+
'sanitize-html',
|
|
87
|
+
'semver',
|
|
88
|
+
'semver/functions/lt',
|
|
89
|
+
'semver/functions/valid',
|
|
90
|
+
'slate',
|
|
91
|
+
'slate-history',
|
|
92
|
+
'slate-react'
|
|
93
|
+
] : []
|
|
36
94
|
]
|
|
37
95
|
},
|
|
38
96
|
resolve: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n 'process.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","target","browserslistToEsbuild","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","env","envPrefix","optimizeDeps","include","resolve","dedupe","plugins","react","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n 'process.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'sanitize-html',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","target","browserslistToEsbuild","isMonorepoExampleApp","strapi","internal_config","uuid","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","env","envPrefix","optimizeDeps","include","resolve","dedupe","plugins","react","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","alias","getMonorepoAliases","server","cors","middlewareMode","open","hmr","overlay","hmrServer","clientPort","hmrClientPort","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;;AAUA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;IAC/B,MAAMC,MAAAA,GAASC,qBAAsBF,CAAAA,GAAAA,CAAIC,MAAM,CAAA;AAC/C,IAAA,MAAME,uBAAuB,GAACH,CAAII,MAAM,CAASC,eAAe,EAAEC,IAAS,KAAA,YAAA;IAE3E,OAAO;AACLC,QAAAA,IAAAA,EAAMP,IAAIQ,GAAG;AACbC,QAAAA,IAAAA,EAAMT,IAAIU,QAAQ;QAClBC,KAAO,EAAA;YACLC,WAAa,EAAA,KAAA;AACbC,YAAAA,MAAAA,EAAQb,IAAIc,OAAO;AACnBb,YAAAA;AACF,SAAA;QACAc,QAAU,EAAA,2BAAA;QACVC,UAAY,EAAA,KAAA;QACZC,MAAQ,EAAA;AACN,YAAA,aAAA,EAAejB,IAAIkB;AACrB,SAAA;QACAC,SAAW,EAAA,eAAA;QACXC,YAAc,EAAA;YACZC,OAAS,EAAA;;;;AAIP,gBAAA,OAAA;AACA,gBAAA,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;gBACTL,MAAQ5C,EAAAA,GAAAA,CAAI4B,OAAO,CAACsB,SAAS;gBAC7BC,UAAYnD,EAAAA,GAAAA,CAAI4B,OAAO,CAACwB;AAC1B;AACF,SAAA;QACAC,OAAS,EAAA;AACX,KAAA;AACF;AAEA,MAAMC,YAAe,GAAA;AAAC,IAAA,gBAAA;AAAkB,IAAA,iBAAA;AAAmB,IAAA;AAAiB,CAAA;AAItEC,MAAAA,yBAAAA,GAA4B,OAAOC,QAAsBxD,EAAAA,GAAAA,GAAAA;IAC7D,MAAMyD,UAAAA,GAAa,MAAMC,oBAAAA,CAA8BJ,YAActD,EAAAA,GAAAA,CAAAA;AAErE,IAAA,IAAIyD,UAAY,EAAA;AACd,QAAA,OAAOA,UAAWD,CAAAA,QAAAA,CAAAA;AACpB;IAEA,OAAOA,QAAAA;AACT;;;;;;"}
|
|
@@ -7,6 +7,7 @@ import { buildFilesPlugin } from './plugins.mjs';
|
|
|
7
7
|
|
|
8
8
|
const resolveBaseConfig = async (ctx)=>{
|
|
9
9
|
const target = browserslistToEsbuild(ctx.target);
|
|
10
|
+
const isMonorepoExampleApp = ctx.strapi.internal_config?.uuid === 'getstarted';
|
|
10
11
|
return {
|
|
11
12
|
root: ctx.cwd,
|
|
12
13
|
base: ctx.basePath,
|
|
@@ -30,7 +31,64 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
30
31
|
`react/jsx-runtime`,
|
|
31
32
|
'react-dom/client',
|
|
32
33
|
'styled-components',
|
|
33
|
-
'react-router-dom'
|
|
34
|
+
'react-router-dom',
|
|
35
|
+
/**
|
|
36
|
+
* Pre-bundle other dependencies that would otherwise cause a page reload when imported.
|
|
37
|
+
* See "performance" section: https://vite.dev/guide/dep-pre-bundling.html#the-why
|
|
38
|
+
* Only include dependencies for our internal example apps, otherwise it will break
|
|
39
|
+
* real user apps that may not have those dependencies.
|
|
40
|
+
*/ ...isMonorepoExampleApp ? [
|
|
41
|
+
'@dnd-kit/core',
|
|
42
|
+
'@dnd-kit/sortable',
|
|
43
|
+
'@dnd-kit/utilities',
|
|
44
|
+
'@dnd-kit/modifiers',
|
|
45
|
+
'@radix-ui/react-toolbar',
|
|
46
|
+
'codemirror5',
|
|
47
|
+
'codemirror5/addon/display/placeholder',
|
|
48
|
+
'date-fns-tz',
|
|
49
|
+
'date-fns/format',
|
|
50
|
+
'date-fns/formatISO',
|
|
51
|
+
'highlight.js',
|
|
52
|
+
'lodash/capitalize',
|
|
53
|
+
'lodash/fp',
|
|
54
|
+
'lodash/groupBy',
|
|
55
|
+
'lodash/has',
|
|
56
|
+
'lodash/isNil',
|
|
57
|
+
'lodash/locale',
|
|
58
|
+
'lodash/map',
|
|
59
|
+
'lodash/mapValues',
|
|
60
|
+
'lodash/pull',
|
|
61
|
+
'lodash/size',
|
|
62
|
+
'lodash/sortBy',
|
|
63
|
+
'lodash/tail',
|
|
64
|
+
'lodash/toLower',
|
|
65
|
+
'lodash/toNumber',
|
|
66
|
+
'lodash/toString',
|
|
67
|
+
'lodash/truncate',
|
|
68
|
+
'lodash/uniq',
|
|
69
|
+
'lodash/upperFirst',
|
|
70
|
+
'markdown-it',
|
|
71
|
+
'markdown-it-abbr',
|
|
72
|
+
'markdown-it-container',
|
|
73
|
+
'markdown-it-deflist',
|
|
74
|
+
'markdown-it-emoji',
|
|
75
|
+
'markdown-it-footnote',
|
|
76
|
+
'markdown-it-ins',
|
|
77
|
+
'markdown-it-mark',
|
|
78
|
+
'markdown-it-sub',
|
|
79
|
+
'markdown-it-sup',
|
|
80
|
+
'prismjs/components/*.js',
|
|
81
|
+
'react-colorful',
|
|
82
|
+
'react-dnd-html5-backend',
|
|
83
|
+
'react-window',
|
|
84
|
+
'sanitize-html',
|
|
85
|
+
'semver',
|
|
86
|
+
'semver/functions/lt',
|
|
87
|
+
'semver/functions/valid',
|
|
88
|
+
'slate',
|
|
89
|
+
'slate-history',
|
|
90
|
+
'slate-react'
|
|
91
|
+
] : []
|
|
34
92
|
]
|
|
35
93
|
},
|
|
36
94
|
resolve: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n 'process.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","target","browserslistToEsbuild","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","env","envPrefix","optimizeDeps","include","resolve","dedupe","plugins","react","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n 'process.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'sanitize-html',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","target","browserslistToEsbuild","isMonorepoExampleApp","strapi","internal_config","uuid","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","env","envPrefix","optimizeDeps","include","resolve","dedupe","plugins","react","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","alias","getMonorepoAliases","server","cors","middlewareMode","open","hmr","overlay","hmrServer","clientPort","hmrClientPort","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;AAUA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;IAC/B,MAAMC,MAAAA,GAASC,qBAAsBF,CAAAA,GAAAA,CAAIC,MAAM,CAAA;AAC/C,IAAA,MAAME,uBAAuB,GAACH,CAAII,MAAM,CAASC,eAAe,EAAEC,IAAS,KAAA,YAAA;IAE3E,OAAO;AACLC,QAAAA,IAAAA,EAAMP,IAAIQ,GAAG;AACbC,QAAAA,IAAAA,EAAMT,IAAIU,QAAQ;QAClBC,KAAO,EAAA;YACLC,WAAa,EAAA,KAAA;AACbC,YAAAA,MAAAA,EAAQb,IAAIc,OAAO;AACnBb,YAAAA;AACF,SAAA;QACAc,QAAU,EAAA,2BAAA;QACVC,UAAY,EAAA,KAAA;QACZC,MAAQ,EAAA;AACN,YAAA,aAAA,EAAejB,IAAIkB;AACrB,SAAA;QACAC,SAAW,EAAA,eAAA;QACXC,YAAc,EAAA;YACZC,OAAS,EAAA;;;;AAIP,gBAAA,OAAA;AACA,gBAAA,CAAC,iBAAiB,CAAC;AACnB,gBAAA,kBAAA;AACA,gBAAA,mBAAA;AACA,gBAAA,kBAAA;AACA;;;;;AAKC,YAAA,GACGlB,oBACA,GAAA;AACE,oBAAA,eAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,yBAAA;AACA,oBAAA,aAAA;AACA,oBAAA,uCAAA;AACA,oBAAA,aAAA;AACA,oBAAA,iBAAA;AACA,oBAAA,oBAAA;AACA,oBAAA,cAAA;AACA,oBAAA,mBAAA;AACA,oBAAA,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MC,aAAAA,CAA8BJ,YAActD,EAAAA,GAAAA,CAAAA;AAErE,IAAA,IAAIyD,UAAY,EAAA;AACd,QAAA,OAAOA,UAAWD,CAAAA,MAAAA,CAAAA;AACpB;IAEA,OAAOA,MAAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -110,24 +110,25 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
|
|
113
|
-
"@strapi/admin": "5.
|
|
114
|
-
"@strapi/cloud-cli": "5.
|
|
115
|
-
"@strapi/content-manager": "5.
|
|
116
|
-
"@strapi/content-releases": "5.
|
|
117
|
-
"@strapi/content-type-builder": "5.
|
|
118
|
-
"@strapi/core": "5.
|
|
119
|
-
"@strapi/data-transfer": "5.
|
|
120
|
-
"@strapi/database": "5.
|
|
121
|
-
"@strapi/email": "5.
|
|
122
|
-
"@strapi/generators": "5.
|
|
123
|
-
"@strapi/i18n": "5.
|
|
124
|
-
"@strapi/logger": "5.
|
|
125
|
-
"@strapi/
|
|
126
|
-
"@strapi/
|
|
127
|
-
"@strapi/
|
|
128
|
-
"@strapi/
|
|
129
|
-
"@strapi/
|
|
130
|
-
"@strapi/
|
|
113
|
+
"@strapi/admin": "5.20.0",
|
|
114
|
+
"@strapi/cloud-cli": "5.20.0",
|
|
115
|
+
"@strapi/content-manager": "5.20.0",
|
|
116
|
+
"@strapi/content-releases": "5.20.0",
|
|
117
|
+
"@strapi/content-type-builder": "5.20.0",
|
|
118
|
+
"@strapi/core": "5.20.0",
|
|
119
|
+
"@strapi/data-transfer": "5.20.0",
|
|
120
|
+
"@strapi/database": "5.20.0",
|
|
121
|
+
"@strapi/email": "5.20.0",
|
|
122
|
+
"@strapi/generators": "5.20.0",
|
|
123
|
+
"@strapi/i18n": "5.20.0",
|
|
124
|
+
"@strapi/logger": "5.20.0",
|
|
125
|
+
"@strapi/openapi": "5.20.0",
|
|
126
|
+
"@strapi/permissions": "5.20.0",
|
|
127
|
+
"@strapi/review-workflows": "5.20.0",
|
|
128
|
+
"@strapi/types": "5.20.0",
|
|
129
|
+
"@strapi/typescript-utils": "5.20.0",
|
|
130
|
+
"@strapi/upload": "5.20.0",
|
|
131
|
+
"@strapi/utils": "5.20.0",
|
|
131
132
|
"@types/nodemon": "1.19.6",
|
|
132
133
|
"@vitejs/plugin-react-swc": "3.6.0",
|
|
133
134
|
"boxen": "5.1.2",
|
|
@@ -181,11 +182,11 @@
|
|
|
181
182
|
"@types/node": "18.19.24",
|
|
182
183
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
183
184
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
184
|
-
"eslint-config-custom": "5.
|
|
185
|
+
"eslint-config-custom": "5.20.0",
|
|
185
186
|
"jest": "29.6.0",
|
|
186
187
|
"react": "18.3.1",
|
|
187
188
|
"react-dom": "18.3.1",
|
|
188
|
-
"tsconfig": "5.
|
|
189
|
+
"tsconfig": "5.20.0"
|
|
189
190
|
},
|
|
190
191
|
"peerDependencies": {
|
|
191
192
|
"react": "^17.0.0 || ^18.0.0",
|