@strapi/core 5.56.0 → 5.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Strapi.d.ts +29 -0
- package/dist/Strapi.d.ts.map +1 -1
- package/dist/Strapi.js +10 -3
- package/dist/Strapi.js.map +1 -1
- package/dist/Strapi.mjs +10 -3
- package/dist/Strapi.mjs.map +1 -1
- package/dist/configuration/get-dirs.js +2 -2
- package/dist/configuration/get-dirs.js.map +1 -1
- package/dist/configuration/get-dirs.mjs +2 -2
- package/dist/configuration/get-dirs.mjs.map +1 -1
- package/dist/configuration/index.d.ts +1 -2
- package/dist/configuration/index.d.ts.map +1 -1
- package/dist/configuration/index.js +1 -2
- package/dist/configuration/index.js.map +1 -1
- package/dist/configuration/index.mjs +2 -3
- package/dist/configuration/index.mjs.map +1 -1
- package/dist/core-api/controller/collection-type.js +3 -3
- package/dist/core-api/controller/collection-type.js.map +1 -1
- package/dist/core-api/controller/collection-type.mjs +1 -1
- package/dist/core-api/controller/collection-type.mjs.map +1 -1
- package/dist/core-api/controller/index.js +2 -2
- package/dist/core-api/controller/index.js.map +1 -1
- package/dist/core-api/controller/index.mjs +2 -2
- package/dist/core-api/controller/index.mjs.map +1 -1
- package/dist/core-api/controller/single-type.js +2 -2
- package/dist/core-api/controller/single-type.js.map +1 -1
- package/dist/core-api/controller/single-type.mjs +1 -1
- package/dist/core-api/controller/single-type.mjs.map +1 -1
- package/dist/core-api/controller/transform.d.ts +1 -4
- package/dist/core-api/controller/transform.d.ts.map +1 -1
- package/dist/core-api/controller/transform.js +8 -8
- package/dist/core-api/controller/transform.js.map +1 -1
- package/dist/core-api/controller/transform.mjs +5 -5
- package/dist/core-api/controller/transform.mjs.map +1 -1
- package/dist/core-api/routes/index.js +1 -1
- package/dist/core-api/routes/index.js.map +1 -1
- package/dist/core-api/routes/index.mjs +1 -1
- package/dist/core-api/routes/index.mjs.map +1 -1
- package/dist/core-api/service/pagination.js +9 -9
- package/dist/core-api/service/pagination.js.map +1 -1
- package/dist/core-api/service/pagination.mjs +7 -7
- package/dist/core-api/service/pagination.mjs.map +1 -1
- package/dist/domain/content-type/index.d.ts.map +1 -1
- package/dist/domain/content-type/index.js +1 -2
- package/dist/domain/content-type/index.js.map +1 -1
- package/dist/domain/content-type/index.mjs +1 -2
- package/dist/domain/content-type/index.mjs.map +1 -1
- package/dist/ee/entitlements.d.ts +44 -0
- package/dist/ee/entitlements.d.ts.map +1 -0
- package/dist/ee/entitlements.js +54 -0
- package/dist/ee/entitlements.js.map +1 -0
- package/dist/ee/entitlements.mjs +51 -0
- package/dist/ee/entitlements.mjs.map +1 -0
- package/dist/ee/index.d.ts +33 -0
- package/dist/ee/index.d.ts.map +1 -1
- package/dist/ee/index.js +74 -7
- package/dist/ee/index.js.map +1 -1
- package/dist/ee/index.mjs +74 -7
- package/dist/ee/index.mjs.map +1 -1
- package/dist/ee/license.d.ts +10 -0
- package/dist/ee/license.d.ts.map +1 -1
- package/dist/ee/license.js +25 -1
- package/dist/ee/license.js.map +1 -1
- package/dist/ee/license.mjs +25 -2
- package/dist/ee/license.mjs.map +1 -1
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +3 -2
- package/dist/factories.js.map +1 -1
- package/dist/factories.mjs +3 -2
- package/dist/factories.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/loaders/apis.d.ts.map +1 -1
- package/dist/loaders/apis.js +1 -2
- package/dist/loaders/apis.js.map +1 -1
- package/dist/loaders/apis.mjs +1 -2
- package/dist/loaders/apis.mjs.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.d.ts +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.d.ts.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.js +6 -5
- package/dist/loaders/plugins/get-enabled-plugins.js.map +1 -1
- package/dist/loaders/plugins/get-enabled-plugins.mjs +6 -5
- package/dist/loaders/plugins/get-enabled-plugins.mjs.map +1 -1
- package/dist/loaders/plugins/get-user-plugins-config.js +2 -2
- package/dist/loaders/plugins/get-user-plugins-config.js.map +1 -1
- package/dist/loaders/plugins/get-user-plugins-config.mjs +2 -2
- package/dist/loaders/plugins/get-user-plugins-config.mjs.map +1 -1
- package/dist/loaders/plugins/index.js +9 -12
- package/dist/loaders/plugins/index.js.map +1 -1
- package/dist/loaders/plugins/index.mjs +9 -12
- package/dist/loaders/plugins/index.mjs.map +1 -1
- package/dist/middlewares/body.js +2 -2
- package/dist/middlewares/body.js.map +1 -1
- package/dist/middlewares/body.mjs +2 -2
- package/dist/middlewares/body.mjs.map +1 -1
- package/dist/middlewares/public.js +2 -2
- package/dist/middlewares/public.js.map +1 -1
- package/dist/middlewares/public.mjs +2 -2
- package/dist/middlewares/public.mjs.map +1 -1
- package/dist/middlewares/responses.d.ts.map +1 -1
- package/dist/middlewares/responses.js +1 -3
- package/dist/middlewares/responses.js.map +1 -1
- package/dist/middlewares/responses.mjs +1 -3
- package/dist/middlewares/responses.mjs.map +1 -1
- package/dist/middlewares/security.d.ts.map +1 -1
- package/dist/middlewares/security.js +3 -3
- package/dist/middlewares/security.js.map +1 -1
- package/dist/middlewares/security.mjs +3 -3
- package/dist/middlewares/security.mjs.map +1 -1
- package/dist/middlewares/session.js +2 -2
- package/dist/middlewares/session.js.map +1 -1
- package/dist/middlewares/session.mjs +2 -2
- package/dist/middlewares/session.mjs.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js +1 -2
- package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs +1 -2
- package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
- package/dist/migrations/i18n.d.ts.map +1 -1
- package/dist/migrations/i18n.js +6 -4
- package/dist/migrations/i18n.js.map +1 -1
- package/dist/migrations/i18n.mjs +6 -4
- package/dist/migrations/i18n.mjs.map +1 -1
- package/dist/package.json.js +16 -16
- package/dist/package.json.mjs +16 -16
- package/dist/registries/apis.js +2 -2
- package/dist/registries/apis.js.map +1 -1
- package/dist/registries/apis.mjs +2 -2
- package/dist/registries/apis.mjs.map +1 -1
- package/dist/registries/components.js +2 -2
- package/dist/registries/components.js.map +1 -1
- package/dist/registries/components.mjs +2 -2
- package/dist/registries/components.mjs.map +1 -1
- package/dist/registries/content-types.d.ts +1 -1
- package/dist/registries/content-types.js +3 -3
- package/dist/registries/content-types.js.map +1 -1
- package/dist/registries/content-types.mjs +3 -3
- package/dist/registries/content-types.mjs.map +1 -1
- package/dist/registries/controllers.js +3 -3
- package/dist/registries/controllers.js.map +1 -1
- package/dist/registries/controllers.mjs +3 -3
- package/dist/registries/controllers.mjs.map +1 -1
- package/dist/registries/custom-fields.js +4 -4
- package/dist/registries/custom-fields.js.map +1 -1
- package/dist/registries/custom-fields.mjs +4 -4
- package/dist/registries/custom-fields.mjs.map +1 -1
- package/dist/registries/hooks.d.ts +1 -1
- package/dist/registries/hooks.js +2 -2
- package/dist/registries/hooks.js.map +1 -1
- package/dist/registries/hooks.mjs +2 -2
- package/dist/registries/hooks.mjs.map +1 -1
- package/dist/registries/middlewares.d.ts +1 -1
- package/dist/registries/middlewares.js +3 -3
- package/dist/registries/middlewares.js.map +1 -1
- package/dist/registries/middlewares.mjs +3 -3
- package/dist/registries/middlewares.mjs.map +1 -1
- package/dist/registries/modules.d.ts +1 -4
- package/dist/registries/modules.d.ts.map +1 -1
- package/dist/registries/modules.js +3 -3
- package/dist/registries/modules.js.map +1 -1
- package/dist/registries/modules.mjs +3 -3
- package/dist/registries/modules.mjs.map +1 -1
- package/dist/registries/plugins.js +2 -2
- package/dist/registries/plugins.js.map +1 -1
- package/dist/registries/plugins.mjs +2 -2
- package/dist/registries/plugins.mjs.map +1 -1
- package/dist/registries/policies.d.ts +1 -1
- package/dist/registries/policies.js +4 -4
- package/dist/registries/policies.js.map +1 -1
- package/dist/registries/policies.mjs +3 -3
- package/dist/registries/policies.mjs.map +1 -1
- package/dist/registries/services.js +3 -3
- package/dist/registries/services.js.map +1 -1
- package/dist/registries/services.mjs +3 -3
- package/dist/registries/services.mjs.map +1 -1
- package/dist/services/auth/index.js +3 -3
- package/dist/services/auth/index.js.map +1 -1
- package/dist/services/auth/index.mjs +3 -3
- package/dist/services/auth/index.mjs.map +1 -1
- package/dist/services/core-store.js +3 -3
- package/dist/services/core-store.js.map +1 -1
- package/dist/services/core-store.mjs +1 -1
- package/dist/services/core-store.mjs.map +1 -1
- package/dist/services/cron.d.ts.map +1 -1
- package/dist/services/cron.js +2 -4
- package/dist/services/cron.js.map +1 -1
- package/dist/services/cron.mjs +2 -4
- package/dist/services/cron.mjs.map +1 -1
- package/dist/services/document-service/attributes/index.js +2 -2
- package/dist/services/document-service/attributes/index.js.map +1 -1
- package/dist/services/document-service/attributes/index.mjs +1 -1
- package/dist/services/document-service/attributes/index.mjs.map +1 -1
- package/dist/services/document-service/attributes/transforms.js +3 -3
- package/dist/services/document-service/attributes/transforms.js.map +1 -1
- package/dist/services/document-service/attributes/transforms.mjs +2 -2
- package/dist/services/document-service/attributes/transforms.mjs.map +1 -1
- package/dist/services/document-service/components.d.ts.map +1 -1
- package/dist/services/document-service/components.js +13 -14
- package/dist/services/document-service/components.js.map +1 -1
- package/dist/services/document-service/components.mjs +12 -13
- package/dist/services/document-service/components.mjs.map +1 -1
- package/dist/services/document-service/draft-and-publish.js +65 -38
- package/dist/services/document-service/draft-and-publish.js.map +1 -1
- package/dist/services/document-service/draft-and-publish.mjs +59 -32
- package/dist/services/document-service/draft-and-publish.mjs.map +1 -1
- package/dist/services/document-service/entries.d.ts +2 -2
- package/dist/services/document-service/entries.d.ts.map +1 -1
- package/dist/services/document-service/entries.js +16 -8
- package/dist/services/document-service/entries.js.map +1 -1
- package/dist/services/document-service/entries.mjs +17 -9
- package/dist/services/document-service/entries.mjs.map +1 -1
- package/dist/services/document-service/first-published-at.js +7 -5
- package/dist/services/document-service/first-published-at.js.map +1 -1
- package/dist/services/document-service/first-published-at.mjs +7 -5
- package/dist/services/document-service/first-published-at.mjs.map +1 -1
- package/dist/services/document-service/internationalization.d.ts.map +1 -1
- package/dist/services/document-service/internationalization.js +37 -28
- package/dist/services/document-service/internationalization.js.map +1 -1
- package/dist/services/document-service/internationalization.mjs +33 -24
- package/dist/services/document-service/internationalization.mjs.map +1 -1
- package/dist/services/document-service/params.d.ts +1 -0
- package/dist/services/document-service/params.d.ts.map +1 -1
- package/dist/services/document-service/params.js +6 -4
- package/dist/services/document-service/params.js.map +1 -1
- package/dist/services/document-service/params.mjs +6 -5
- package/dist/services/document-service/params.mjs.map +1 -1
- package/dist/services/document-service/repository.d.ts.map +1 -1
- package/dist/services/document-service/repository.js +84 -61
- package/dist/services/document-service/repository.js.map +1 -1
- package/dist/services/document-service/repository.mjs +47 -24
- package/dist/services/document-service/repository.mjs.map +1 -1
- package/dist/services/document-service/transform/fields.d.ts.map +1 -1
- package/dist/services/document-service/transform/fields.js +7 -1
- package/dist/services/document-service/transform/fields.js.map +1 -1
- package/dist/services/document-service/transform/fields.mjs +7 -1
- package/dist/services/document-service/transform/fields.mjs.map +1 -1
- package/dist/services/document-service/transform/id-map.d.ts.map +1 -1
- package/dist/services/document-service/transform/id-map.js +2 -1
- package/dist/services/document-service/transform/id-map.js.map +1 -1
- package/dist/services/document-service/transform/id-map.mjs +2 -1
- package/dist/services/document-service/transform/id-map.mjs.map +1 -1
- package/dist/services/document-service/transform/id-transform.js +2 -2
- package/dist/services/document-service/transform/id-transform.js.map +1 -1
- package/dist/services/document-service/transform/id-transform.mjs +1 -1
- package/dist/services/document-service/transform/id-transform.mjs.map +1 -1
- package/dist/services/document-service/transform/populate.d.ts.map +1 -1
- package/dist/services/document-service/transform/populate.js +8 -1
- package/dist/services/document-service/transform/populate.js.map +1 -1
- package/dist/services/document-service/transform/populate.mjs +8 -1
- package/dist/services/document-service/transform/populate.mjs.map +1 -1
- package/dist/services/document-service/transform/query.d.ts +3 -1
- package/dist/services/document-service/transform/query.d.ts.map +1 -1
- package/dist/services/document-service/transform/query.js +12 -6
- package/dist/services/document-service/transform/query.js.map +1 -1
- package/dist/services/document-service/transform/query.mjs +11 -5
- package/dist/services/document-service/transform/query.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.js +2 -2
- package/dist/services/document-service/transform/relations/extract/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs +1 -1
- package/dist/services/document-service/transform/relations/extract/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.js +2 -2
- package/dist/services/document-service/transform/relations/transform/data-ids.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs +1 -1
- package/dist/services/document-service/transform/relations/transform/data-ids.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.js +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.js.map +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.mjs +1 -1
- package/dist/services/document-service/transform/relations/transform/default-locale.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.js +1 -2
- package/dist/services/document-service/transform/relations/utils/dp.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/dp.mjs +1 -2
- package/dist/services/document-service/transform/relations/utils/dp.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts +2 -2
- package/dist/services/document-service/transform/relations/utils/i18n.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.js +2 -2
- package/dist/services/document-service/transform/relations/utils/i18n.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/i18n.mjs +2 -2
- package/dist/services/document-service/transform/relations/utils/i18n.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.d.ts.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.js +16 -10
- package/dist/services/document-service/transform/relations/utils/map-relation.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs +13 -7
- package/dist/services/document-service/transform/relations/utils/map-relation.mjs.map +1 -1
- package/dist/services/document-service/transform/relations/utils/xto-one.js +3 -3
- package/dist/services/document-service/transform/relations/utils/xto-one.js.map +1 -1
- package/dist/services/document-service/transform/relations/utils/xto-one.mjs +2 -2
- package/dist/services/document-service/transform/relations/utils/xto-one.mjs.map +1 -1
- package/dist/services/document-service/utils/bidirectional-relations.js +3 -3
- package/dist/services/document-service/utils/bidirectional-relations.js.map +1 -1
- package/dist/services/document-service/utils/bidirectional-relations.mjs +3 -3
- package/dist/services/document-service/utils/bidirectional-relations.mjs.map +1 -1
- package/dist/services/document-service/utils/clone-relations.js +3 -3
- package/dist/services/document-service/utils/clone-relations.js.map +1 -1
- package/dist/services/document-service/utils/clone-relations.mjs +3 -3
- package/dist/services/document-service/utils/clone-relations.mjs.map +1 -1
- package/dist/services/document-service/utils/self-referential-relations.js +4 -4
- package/dist/services/document-service/utils/self-referential-relations.js.map +1 -1
- package/dist/services/document-service/utils/self-referential-relations.mjs +4 -4
- package/dist/services/document-service/utils/self-referential-relations.mjs.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.js +3 -3
- package/dist/services/document-service/utils/unidirectional-relations.js.map +1 -1
- package/dist/services/document-service/utils/unidirectional-relations.mjs +3 -3
- package/dist/services/document-service/utils/unidirectional-relations.mjs.map +1 -1
- package/dist/services/entity-validator/index.d.ts.map +1 -1
- package/dist/services/entity-validator/index.js +9 -10
- package/dist/services/entity-validator/index.js.map +1 -1
- package/dist/services/entity-validator/index.mjs +4 -5
- package/dist/services/entity-validator/index.mjs.map +1 -1
- package/dist/services/localization.d.ts +4 -0
- package/dist/services/localization.d.ts.map +1 -0
- package/dist/services/localization.js +51 -0
- package/dist/services/localization.js.map +1 -0
- package/dist/services/localization.mjs +49 -0
- package/dist/services/localization.mjs.map +1 -0
- package/dist/services/server/compose-endpoint.js +7 -7
- package/dist/services/server/compose-endpoint.js.map +1 -1
- package/dist/services/server/compose-endpoint.mjs +3 -3
- package/dist/services/server/compose-endpoint.mjs.map +1 -1
- package/dist/services/server/koa-methods.js +2 -2
- package/dist/services/server/koa-methods.js.map +1 -1
- package/dist/services/server/koa-methods.mjs +1 -1
- package/dist/services/server/koa-methods.mjs.map +1 -1
- package/dist/services/server/koa.d.ts.map +1 -1
- package/dist/services/server/koa.js +1 -2
- package/dist/services/server/koa.js.map +1 -1
- package/dist/services/server/koa.mjs +1 -2
- package/dist/services/server/koa.mjs.map +1 -1
- package/dist/services/server/middleware.d.ts.map +1 -1
- package/dist/services/server/middleware.js +1 -2
- package/dist/services/server/middleware.js.map +1 -1
- package/dist/services/server/middleware.mjs +1 -2
- package/dist/services/server/middleware.mjs.map +1 -1
- package/dist/services/server/routing.js +2 -2
- package/dist/services/server/routing.js.map +1 -1
- package/dist/services/server/routing.mjs +2 -2
- package/dist/services/server/routing.mjs.map +1 -1
- package/dist/services/utils/conditional-fields.d.ts +1 -1
- package/dist/services/utils/conditional-fields.d.ts.map +1 -1
- package/dist/services/utils/conditional-fields.js +2 -8
- package/dist/services/utils/conditional-fields.js.map +1 -1
- package/dist/services/utils/conditional-fields.mjs +2 -8
- package/dist/services/utils/conditional-fields.mjs.map +1 -1
- package/dist/services/utils/dynamic-zones.d.ts.map +1 -1
- package/dist/services/utils/dynamic-zones.js +2 -8
- package/dist/services/utils/dynamic-zones.js.map +1 -1
- package/dist/services/utils/dynamic-zones.mjs +2 -8
- package/dist/services/utils/dynamic-zones.mjs.map +1 -1
- package/dist/utils/cron.js +2 -2
- package/dist/utils/cron.js.map +1 -1
- package/dist/utils/cron.mjs +1 -1
- package/dist/utils/cron.mjs.map +1 -1
- package/dist/utils/detect-customizations.d.ts +31 -0
- package/dist/utils/detect-customizations.d.ts.map +1 -0
- package/dist/utils/detect-customizations.js +173 -0
- package/dist/utils/detect-customizations.js.map +1 -0
- package/dist/utils/detect-customizations.mjs +165 -0
- package/dist/utils/detect-customizations.mjs.map +1 -0
- package/dist/utils/filepath-to-prop-path.d.ts.map +1 -1
- package/dist/utils/filepath-to-prop-path.js +5 -12
- package/dist/utils/filepath-to-prop-path.js.map +1 -1
- package/dist/utils/filepath-to-prop-path.mjs +5 -11
- package/dist/utils/filepath-to-prop-path.mjs.map +1 -1
- package/dist/utils/is-initialized.js +3 -3
- package/dist/utils/is-initialized.js.map +1 -1
- package/dist/utils/is-initialized.mjs +2 -2
- package/dist/utils/is-initialized.mjs.map +1 -1
- package/dist/utils/startup-logger.d.ts.map +1 -1
- package/dist/utils/startup-logger.js +2 -4
- package/dist/utils/startup-logger.js.map +1 -1
- package/dist/utils/startup-logger.mjs +2 -3
- package/dist/utils/startup-logger.mjs.map +1 -1
- package/dist/utils/transform-content-types-to-models.js +4 -4
- package/dist/utils/transform-content-types-to-models.js.map +1 -1
- package/dist/utils/transform-content-types-to-models.mjs +3 -3
- package/dist/utils/transform-content-types-to-models.mjs.map +1 -1
- package/package.json +16 -16
package/dist/utils/cron.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.mjs","sources":["../../src/utils/cron.ts"],"sourcesContent":["import { isEmpty, negate } from 'lodash
|
|
1
|
+
{"version":3,"file":"cron.mjs","sources":["../../src/utils/cron.ts"],"sourcesContent":["import { isEmpty, negate } from 'lodash';\n\nconst DATE_FUNCTIONS = [\n 'getSeconds',\n 'getMinutes',\n 'getHours',\n 'getDate',\n 'getMonth',\n 'getDay',\n] as const;\n\nconst INTEGER_REGEX = /^\\d+$/;\nconst STEP_REGEX = /^\\*\\/\\d+$/;\nconst COMPONENTS: {\n limit: number;\n zeroBasedIndices: boolean;\n functionName: (typeof DATE_FUNCTIONS)[number];\n}[] = [\n { limit: 60, zeroBasedIndices: true, functionName: 'getSeconds' },\n { limit: 60, zeroBasedIndices: true, functionName: 'getMinutes' },\n { limit: 24, zeroBasedIndices: true, functionName: 'getHours' },\n { limit: 31, zeroBasedIndices: false, functionName: 'getDate' },\n { limit: 12, zeroBasedIndices: false, functionName: 'getMonth' },\n { limit: 7, zeroBasedIndices: true, functionName: 'getDay' },\n];\n\nconst shift = (component: string, index: number, date: Date) => {\n if (component === '*') {\n return '*';\n }\n\n const { limit, zeroBasedIndices, functionName } = COMPONENTS[index];\n const offset = +!zeroBasedIndices;\n const currentValue = date[functionName]();\n\n if (INTEGER_REGEX.test(component)) {\n return ((Number.parseInt(component, 10) + currentValue) % limit) + offset;\n }\n\n if (STEP_REGEX.test(component)) {\n const [, step] = component.split('/');\n const frequency = Math.floor(limit / Number(step));\n const list = Array.from({ length: frequency }, (_, index) => index * Number(step));\n return list.map((value) => ((value + currentValue) % limit) + offset).sort((a, b) => a - b);\n }\n\n // Unsupported syntax\n return component;\n};\n\n/**\n * Simulate an interval by shifting a cron expression using the specified date.\n * @param {string} rule A cron expression you want to shift.\n * @param {Date} date The date that's gonna be used as the start of the \"interval\", it defaults to now.\n * @returns The shifted cron expression.\n */\nexport const shiftCronExpression = (rule: string, date = new Date()) => {\n const components = rule.trim().split(' ').filter(negate(isEmpty));\n const secondsIncluded = components.length === 6;\n return components\n .map((component, index) => shift(component, secondsIncluded ? index : index + 1, date))\n .join(' ');\n};\n"],"names":["INTEGER_REGEX","STEP_REGEX","COMPONENTS","limit","zeroBasedIndices","functionName","shift","component","index","date","offset","currentValue","test","Number","parseInt","step","split","frequency","Math","floor","list","Array","from","length","_","map","value","sort","a","b","shiftCronExpression","rule","Date","components","trim","filter","negate","isEmpty","secondsIncluded","join"],"mappings":";;AAWA,MAAMA,aAAAA,GAAgB,OAAA;AACtB,MAAMC,UAAAA,GAAa,WAAA;AACnB,MAAMC,UAAAA,GAIA;AACJ,IAAA;QAAEC,KAAAA,EAAO,EAAA;QAAIC,gBAAAA,EAAkB,IAAA;QAAMC,YAAAA,EAAc;AAAa,KAAA;AAChE,IAAA;QAAEF,KAAAA,EAAO,EAAA;QAAIC,gBAAAA,EAAkB,IAAA;QAAMC,YAAAA,EAAc;AAA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AAA,CAAMC,IAAI,CAAC;YAAEC,MAAAA,EAAQN;AAAU,SAAA,EAAG,CAACO,CAAAA,EAAGhB,KAAAA,GAAUA,KAAAA,GAAQK,MAAAA,CAAOE,IAAAA,CAAAA,CAAAA;AAC5E,QAAA,OAAOK,KAAKK,GAAG,CAAC,CAACC,KAAAA,GAAU,CAAEA,KAAAA,GAAQf,YAAW,IAAKR,QAASO,MAAAA,CAAAA,CAAQiB,IAAI,CAAC,CAACC,CAAAA,EAAGC,IAAMD,CAAAA,GAAIC,CAAAA,CAAAA;AAC3F,IAAA;;IAGA,OAAOtB,SAAAA;AACT,CAAA;AAEA;;;;;AAKC,IACM,MAAMuB,mBAAAA,GAAsB,CAACC,IAAAA,EAActB,IAAAA,GAAO,IAAIuB,IAAAA,EAAM,GAAA;IACjE,MAAMC,UAAAA,GAAaF,KAAKG,IAAI,EAAA,CAAGlB,KAAK,CAAC,GAAA,CAAA,CAAKmB,MAAM,CAACC,MAAAA,CAAOC,OAAAA,CAAAA,CAAAA;IACxD,MAAMC,eAAAA,GAAkBL,UAAAA,CAAWV,MAAM,KAAK,CAAA;AAC9C,IAAA,OAAOU,UAAAA,CACJR,GAAG,CAAC,CAAClB,WAAWC,KAAAA,GAAUF,KAAAA,CAAMC,SAAAA,EAAW+B,eAAAA,GAAkB9B,KAAAA,GAAQA,KAAAA,GAAQ,CAAA,EAAGC,IAAAA,CAAAA,CAAAA,CAChF8B,IAAI,CAAC,GAAA,CAAA;AACV;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
export declare const isLifecycleNonEmpty: (fn: unknown) => boolean;
|
|
3
|
+
export declare const detectCustomizations: (strapi: Core.Strapi) => {
|
|
4
|
+
apis: {
|
|
5
|
+
uid: string;
|
|
6
|
+
customController: boolean;
|
|
7
|
+
customService: boolean;
|
|
8
|
+
customRoutes: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
controllers: {
|
|
11
|
+
uid: string;
|
|
12
|
+
custom: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
extendedPlugins: string[];
|
|
15
|
+
counts: {
|
|
16
|
+
customControllers: number;
|
|
17
|
+
customServices: number;
|
|
18
|
+
customRoutes: number;
|
|
19
|
+
};
|
|
20
|
+
srcIndex: {
|
|
21
|
+
present: boolean;
|
|
22
|
+
registerDefined: boolean;
|
|
23
|
+
registerNonEmpty: boolean;
|
|
24
|
+
bootstrapDefined: boolean;
|
|
25
|
+
bootstrapNonEmpty: boolean;
|
|
26
|
+
destroyDefined: boolean;
|
|
27
|
+
destroyNonEmpty: boolean;
|
|
28
|
+
beyondTemplate: boolean;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=detect-customizations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.d.ts","sourceRoot":"","sources":["../../src/utils/detect-customizations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAgB1C,eAAO,MAAM,mBAAmB,GAAI,IAAI,OAAO,KAAG,OAsBjD,CAAC;AAgHF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DvD,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var factories = require('../factories.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
10
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
11
|
+
|
|
12
|
+
const APP_UID_PREFIX = 'api::';
|
|
13
|
+
/**
|
|
14
|
+
* True when a lifecycle function has a non-empty body. The compiled function
|
|
15
|
+
* source is inspected here only to derive a boolean; it is never returned.
|
|
16
|
+
*/ const stripComments = (body)=>body.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '').trim();
|
|
17
|
+
const isLifecycleNonEmpty = (fn)=>{
|
|
18
|
+
if (typeof fn !== 'function') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const source = Function.prototype.toString.call(fn);
|
|
22
|
+
// The body starts at the first `{` AFTER the parameter list closes, not the
|
|
23
|
+
// first `{` overall: a real lifecycle signature like `register({ strapi })`
|
|
24
|
+
// or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.
|
|
25
|
+
const parenEnd = source.indexOf(')');
|
|
26
|
+
const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);
|
|
27
|
+
// No brace anywhere after the parameters means a concise arrow body
|
|
28
|
+
// (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the
|
|
29
|
+
// arrow IS the body. Treating that as empty under-reported a real customization,
|
|
30
|
+
// telling Support an app was stock when it was not. The template only ever ships
|
|
31
|
+
// braced method shorthand, so this branch cannot misread a fresh app.
|
|
32
|
+
if (bodyStart === -1) {
|
|
33
|
+
const arrow = source.indexOf('=>');
|
|
34
|
+
return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;
|
|
35
|
+
}
|
|
36
|
+
return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A default `createCoreService` result has its CRUD methods on its class
|
|
40
|
+
* prototype and only `contentType` as an own key; that own key is copied onto
|
|
41
|
+
* the direct prototype (the base service instance) too, so a default service
|
|
42
|
+
* never has an own key that its direct prototype doesn't also have. A custom
|
|
43
|
+
* service (built via a `cfg` object/callback) has extra own method keys that
|
|
44
|
+
* are absent from the prototype it was assigned. Comparing own keys against
|
|
45
|
+
* the DIRECT prototype's own keys (rather than guessing base method names)
|
|
46
|
+
* avoids flagging every real service as custom.
|
|
47
|
+
*/ const isCustomService = (service)=>{
|
|
48
|
+
if (service === null || typeof service !== 'object') {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
const proto = Object.getPrototypeOf(service);
|
|
52
|
+
const protoOwnKeys = proto ? Object.keys(proto) : [];
|
|
53
|
+
return Object.keys(service).some((key)=>!protoOwnKeys.includes(key));
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Custom routes in Strapi are added as separate files in an api's `routes/`
|
|
57
|
+
* directory (each exporting a plain `{ routes: [...] }` object), never by
|
|
58
|
+
* editing the factory-generated route file, because Koa needs explicit route
|
|
59
|
+
* ordering. The factory router exposes `routes` as a getter, so any route
|
|
60
|
+
* file exposing `routes` as a plain data property is a hand-written custom
|
|
61
|
+
* route file.
|
|
62
|
+
*/ const hasCustomRoutes = (strapi, apiName)=>{
|
|
63
|
+
const api = strapi.api(apiName);
|
|
64
|
+
const routeFiles = api?.routes ?? {};
|
|
65
|
+
return Object.values(routeFiles).some((router)=>{
|
|
66
|
+
if (router === null || typeof router !== 'object') {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');
|
|
70
|
+
// A factory router exposes `routes` as an accessor (getter); a hand-written
|
|
71
|
+
// custom routes file exports it as a plain data property.
|
|
72
|
+
return descriptor ? typeof descriptor.get !== 'function' : false;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* `createCoreController` sets the controller's prototype to the factory's base controller, and
|
|
77
|
+
* marks it when the app passed its own config. Anything else was not minted by the factory: a
|
|
78
|
+
* plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a
|
|
79
|
+
* factory that returned a non-object is not stock either. Neither may throw out of the dump.
|
|
80
|
+
*/ const isCustomApiController = (controller)=>{
|
|
81
|
+
if (controller === null || typeof controller !== 'object') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
const prototype = Object.getPrototypeOf(controller);
|
|
85
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return factories.isCustomController(controller);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Plugin and admin controllers are plain objects even when stock, so only the factory's
|
|
92
|
+
* custom-config mark can single one out here (the same test startup telemetry uses).
|
|
93
|
+
*/ const isCustomFactoryController = (controller)=>controller !== null && typeof controller === 'object' && factories.isCustomController(controller);
|
|
94
|
+
/**
|
|
95
|
+
* Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can
|
|
96
|
+
* replace any controller, service or route, or content-type schema overrides. A plugin
|
|
97
|
+
* controller looks the same stock or overridden, so this folder is what tells Support a
|
|
98
|
+
* plugin was changed.
|
|
99
|
+
*/ // The loader applies content-type overrides from `content-types/<name>/schema.json` only
|
|
100
|
+
const hasSchemaOverride = (pluginDir)=>{
|
|
101
|
+
const contentTypesDir = path__default.default.join(pluginDir, 'content-types');
|
|
102
|
+
if (!fs__default.default.existsSync(contentTypesDir)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return fs__default.default.readdirSync(contentTypesDir, {
|
|
106
|
+
withFileTypes: true
|
|
107
|
+
}).some((entry)=>entry.isDirectory() && fs__default.default.existsSync(path__default.default.join(contentTypesDir, entry.name, 'schema.json')));
|
|
108
|
+
};
|
|
109
|
+
const listExtendedPlugins = (strapi)=>{
|
|
110
|
+
const extensionsDir = strapi.dirs?.dist?.extensions;
|
|
111
|
+
if (!extensionsDir || !fs__default.default.existsSync(extensionsDir)) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
return fs__default.default.readdirSync(extensionsDir, {
|
|
115
|
+
withFileTypes: true
|
|
116
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).filter((name)=>fs__default.default.existsSync(path__default.default.join(extensionsDir, name, 'strapi-server.js')) || hasSchemaOverride(path__default.default.join(extensionsDir, name))).sort();
|
|
117
|
+
};
|
|
118
|
+
// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];
|
|
119
|
+
// keep the two in sync.
|
|
120
|
+
const detectCustomizations = (strapi)=>{
|
|
121
|
+
const controllers = strapi.controllers ?? {};
|
|
122
|
+
const services = strapi.services ?? {};
|
|
123
|
+
const appControllerUids = Object.keys(controllers).filter((uid)=>uid.startsWith(APP_UID_PREFIX));
|
|
124
|
+
const apis = appControllerUids.map((uid)=>{
|
|
125
|
+
const controller = controllers[uid];
|
|
126
|
+
const service = services[uid];
|
|
127
|
+
// uid is `api::<name>.<name>`; map to the bare api name for route lookup.
|
|
128
|
+
const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];
|
|
129
|
+
return {
|
|
130
|
+
uid,
|
|
131
|
+
customController: isCustomApiController(controller),
|
|
132
|
+
customService: isCustomService(service),
|
|
133
|
+
customRoutes: hasCustomRoutes(strapi, apiName)
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
// Every controller, not only the app's own: the dump is used to rebuild an app for debugging.
|
|
137
|
+
const allControllers = Object.keys(controllers).map((uid)=>({
|
|
138
|
+
uid,
|
|
139
|
+
custom: uid.startsWith(APP_UID_PREFIX) ? isCustomApiController(controllers[uid]) : isCustomFactoryController(controllers[uid])
|
|
140
|
+
}));
|
|
141
|
+
const app = strapi.app;
|
|
142
|
+
const registerDefined = typeof app?.register === 'function';
|
|
143
|
+
const bootstrapDefined = typeof app?.bootstrap === 'function';
|
|
144
|
+
const destroyDefined = typeof app?.destroy === 'function';
|
|
145
|
+
const registerNonEmpty = isLifecycleNonEmpty(app?.register);
|
|
146
|
+
const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);
|
|
147
|
+
const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);
|
|
148
|
+
return {
|
|
149
|
+
apis,
|
|
150
|
+
controllers: allControllers,
|
|
151
|
+
extendedPlugins: listExtendedPlugins(strapi),
|
|
152
|
+
counts: {
|
|
153
|
+
customControllers: allControllers.filter((c)=>c.custom).length,
|
|
154
|
+
customServices: apis.filter((a)=>a.customService).length,
|
|
155
|
+
customRoutes: apis.filter((a)=>a.customRoutes).length
|
|
156
|
+
},
|
|
157
|
+
srcIndex: {
|
|
158
|
+
present: app != null,
|
|
159
|
+
registerDefined,
|
|
160
|
+
registerNonEmpty,
|
|
161
|
+
bootstrapDefined,
|
|
162
|
+
bootstrapNonEmpty,
|
|
163
|
+
destroyDefined,
|
|
164
|
+
destroyNonEmpty,
|
|
165
|
+
// Template ships only empty register + bootstrap and no destroy.
|
|
166
|
+
beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
exports.detectCustomizations = detectCustomizations;
|
|
172
|
+
exports.isLifecycleNonEmpty = isLifecycleNonEmpty;
|
|
173
|
+
//# sourceMappingURL=detect-customizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.js","sources":["../../src/utils/detect-customizations.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { Core } from '@strapi/types';\n\nimport * as factories from '../factories';\n\nconst APP_UID_PREFIX = 'api::';\n\n/**\n * True when a lifecycle function has a non-empty body. The compiled function\n * source is inspected here only to derive a boolean; it is never returned.\n */\nconst stripComments = (body: string): string =>\n body\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\n]*/g, '')\n .trim();\n\nexport const isLifecycleNonEmpty = (fn: unknown): boolean => {\n if (typeof fn !== 'function') {\n return false;\n }\n const source = Function.prototype.toString.call(fn);\n // The body starts at the first `{` AFTER the parameter list closes, not the\n // first `{` overall: a real lifecycle signature like `register({ strapi })`\n // or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.\n const parenEnd = source.indexOf(')');\n const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);\n\n // No brace anywhere after the parameters means a concise arrow body\n // (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the\n // arrow IS the body. Treating that as empty under-reported a real customization,\n // telling Support an app was stock when it was not. The template only ever ships\n // braced method shorthand, so this branch cannot misread a fresh app.\n if (bodyStart === -1) {\n const arrow = source.indexOf('=>');\n return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;\n }\n\n return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;\n};\n\n/**\n * A default `createCoreService` result has its CRUD methods on its class\n * prototype and only `contentType` as an own key; that own key is copied onto\n * the direct prototype (the base service instance) too, so a default service\n * never has an own key that its direct prototype doesn't also have. A custom\n * service (built via a `cfg` object/callback) has extra own method keys that\n * are absent from the prototype it was assigned. Comparing own keys against\n * the DIRECT prototype's own keys (rather than guessing base method names)\n * avoids flagging every real service as custom.\n */\nconst isCustomService = (service: unknown): boolean => {\n if (service === null || typeof service !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(service);\n const protoOwnKeys = proto ? Object.keys(proto) : [];\n return Object.keys(service).some((key) => !protoOwnKeys.includes(key));\n};\n\n/**\n * Custom routes in Strapi are added as separate files in an api's `routes/`\n * directory (each exporting a plain `{ routes: [...] }` object), never by\n * editing the factory-generated route file, because Koa needs explicit route\n * ordering. The factory router exposes `routes` as a getter, so any route\n * file exposing `routes` as a plain data property is a hand-written custom\n * route file.\n */\nconst hasCustomRoutes = (strapi: Core.Strapi, apiName: string): boolean => {\n const api = strapi.api(apiName);\n const routeFiles = api?.routes ?? {};\n return Object.values(routeFiles).some((router) => {\n if (router === null || typeof router !== 'object') {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');\n // A factory router exposes `routes` as an accessor (getter); a hand-written\n // custom routes file exports it as a plain data property.\n return descriptor ? typeof descriptor.get !== 'function' : false;\n });\n};\n\n/**\n * `createCoreController` sets the controller's prototype to the factory's base controller, and\n * marks it when the app passed its own config. Anything else was not minted by the factory: a\n * plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a\n * factory that returned a non-object is not stock either. Neither may throw out of the dump.\n */\nconst isCustomApiController = (controller: unknown): boolean => {\n if (controller === null || typeof controller !== 'object') {\n return true;\n }\n\n const prototype = Object.getPrototypeOf(controller);\n if (prototype === Object.prototype || prototype === null) {\n return true;\n }\n\n return factories.isCustomController(controller as Core.Controller);\n};\n\n/**\n * Plugin and admin controllers are plain objects even when stock, so only the factory's\n * custom-config mark can single one out here (the same test startup telemetry uses).\n */\nconst isCustomFactoryController = (controller: unknown): boolean =>\n controller !== null &&\n typeof controller === 'object' &&\n factories.isCustomController(controller as Core.Controller);\n\n/**\n * Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can\n * replace any controller, service or route, or content-type schema overrides. A plugin\n * controller looks the same stock or overridden, so this folder is what tells Support a\n * plugin was changed.\n */\n// The loader applies content-type overrides from `content-types/<name>/schema.json` only\nconst hasSchemaOverride = (pluginDir: string): boolean => {\n const contentTypesDir = path.join(pluginDir, 'content-types');\n if (!fs.existsSync(contentTypesDir)) {\n return false;\n }\n\n return fs\n .readdirSync(contentTypesDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json'))\n );\n};\n\nconst listExtendedPlugins = (strapi: Core.Strapi): string[] => {\n const extensionsDir = strapi.dirs?.dist?.extensions;\n if (!extensionsDir || !fs.existsSync(extensionsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(extensionsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter(\n (name) =>\n fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) ||\n hasSchemaOverride(path.join(extensionsDir, name))\n )\n .sort();\n};\n\n// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];\n// keep the two in sync.\nexport const detectCustomizations = (strapi: Core.Strapi) => {\n const controllers = strapi.controllers ?? {};\n const services = strapi.services ?? {};\n\n const appControllerUids = Object.keys(controllers).filter((uid) =>\n uid.startsWith(APP_UID_PREFIX)\n );\n\n const apis = appControllerUids.map((uid) => {\n const controller = controllers[uid];\n const service = services[uid];\n // uid is `api::<name>.<name>`; map to the bare api name for route lookup.\n const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];\n\n return {\n uid,\n customController: isCustomApiController(controller),\n customService: isCustomService(service),\n customRoutes: hasCustomRoutes(strapi, apiName),\n };\n });\n\n // Every controller, not only the app's own: the dump is used to rebuild an app for debugging.\n const allControllers = Object.keys(controllers).map((uid) => ({\n uid,\n custom: uid.startsWith(APP_UID_PREFIX)\n ? isCustomApiController(controllers[uid])\n : isCustomFactoryController(controllers[uid]),\n }));\n\n const app = strapi.app;\n const registerDefined = typeof app?.register === 'function';\n const bootstrapDefined = typeof app?.bootstrap === 'function';\n const destroyDefined = typeof app?.destroy === 'function';\n const registerNonEmpty = isLifecycleNonEmpty(app?.register);\n const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);\n const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);\n\n return {\n apis,\n controllers: allControllers,\n extendedPlugins: listExtendedPlugins(strapi),\n counts: {\n customControllers: allControllers.filter((c) => c.custom).length,\n customServices: apis.filter((a) => a.customService).length,\n customRoutes: apis.filter((a) => a.customRoutes).length,\n },\n srcIndex: {\n present: app != null,\n registerDefined,\n registerNonEmpty,\n bootstrapDefined,\n bootstrapNonEmpty,\n destroyDefined,\n destroyNonEmpty,\n // Template ships only empty register + bootstrap and no destroy.\n beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty,\n },\n };\n};\n"],"names":["APP_UID_PREFIX","stripComments","body","replace","trim","isLifecycleNonEmpty","fn","source","Function","prototype","toString","call","parenEnd","indexOf","bodyStart","arrow","slice","length","lastIndexOf","isCustomService","service","proto","Object","getPrototypeOf","protoOwnKeys","keys","some","key","includes","hasCustomRoutes","strapi","apiName","api","routeFiles","routes","values","router","descriptor","getOwnPropertyDescriptor","get","isCustomApiController","controller","factories","isCustomFactoryController","hasSchemaOverride","pluginDir","contentTypesDir","path","join","fs","existsSync","readdirSync","withFileTypes","entry","isDirectory","name","listExtendedPlugins","extensionsDir","dirs","dist","extensions","filter","map","sort","detectCustomizations","controllers","services","appControllerUids","uid","startsWith","apis","split","customController","customService","customRoutes","allControllers","custom","app","registerDefined","register","bootstrapDefined","bootstrap","destroyDefined","destroy","registerNonEmpty","bootstrapNonEmpty","destroyNonEmpty","extendedPlugins","counts","customControllers","c","customServices","a","srcIndex","present","beyondTemplate"],"mappings":";;;;;;;;;;;AAOA,MAAMA,cAAAA,GAAiB,OAAA;AAEvB;;;AAGC,IACD,MAAMC,aAAAA,GAAgB,CAACC,IAAAA,GACrBA,IAAAA,CACGC,OAAO,CAAC,mBAAA,EAAqB,EAAA,CAAA,CAC7BA,OAAO,CAAC,aAAA,EAAe,IACvBC,IAAI,EAAA;AAEF,MAAMC,sBAAsB,CAACC,EAAAA,GAAAA;IAClC,IAAI,OAAOA,OAAO,UAAA,EAAY;QAC5B,OAAO,KAAA;AACT,IAAA;AACA,IAAA,MAAMC,SAASC,QAAAA,CAASC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACL,EAAAA,CAAAA;;;;IAIhD,MAAMM,QAAAA,GAAWL,MAAAA,CAAOM,OAAO,CAAC,GAAA,CAAA;IAChC,MAAMC,SAAAA,GAAYP,OAAOM,OAAO,CAAC,KAAKD,QAAAA,KAAa,KAAK,CAAA,GAAIA,QAAAA,CAAAA;;;;;;IAO5D,IAAIE,SAAAA,KAAc,EAAC,EAAG;QACpB,MAAMC,KAAAA,GAAQR,MAAAA,CAAOM,OAAO,CAAC,IAAA,CAAA;QAC7B,OAAOE,KAAAA,KAAU,EAAC,GAAI,KAAA,GAAQd,aAAAA,CAAcM,MAAAA,CAAOS,KAAK,CAACD,KAAAA,GAAQ,CAAA,CAAA,CAAA,CAAIE,MAAM,GAAG,CAAA;AAChF,IAAA;IAEA,OAAOhB,aAAAA,CAAcM,MAAAA,CAA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AAC6B,IAAMA,CAAAA,CAAEd,MAAM,EAAE3D,MAAM;YAChE0E,cAAAA,EAAgBrB,IAAAA,CAAKT,MAAM,CAAC,CAAC+B,IAAMA,CAAAA,CAAEnB,aAAa,EAAExD,MAAM;YAC1DyD,YAAAA,EAAcJ,IAAAA,CAAKT,MAAM,CAAC,CAAC+B,IAAMA,CAAAA,CAAElB,YAAY,EAAEzD;AACnD,SAAA;QACA4E,QAAAA,EAAU;AACRC,YAAAA,OAAAA,EAASjB,GAAAA,IAAO,IAAA;AAChBC,YAAAA,eAAAA;AACAM,YAAAA,gBAAAA;AACAJ,YAAAA,gBAAAA;AACAK,YAAAA,iBAAAA;AACAH,YAAAA,cAAAA;AACAI,YAAAA,eAAAA;;AAEAS,YAAAA,cAAAA,EAAgBb,kBAAkBE,gBAAAA,IAAoBC;AACxD;AACF,KAAA;AACF;;;;;"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { isCustomController } from '../factories.mjs';
|
|
4
|
+
|
|
5
|
+
const APP_UID_PREFIX = 'api::';
|
|
6
|
+
/**
|
|
7
|
+
* True when a lifecycle function has a non-empty body. The compiled function
|
|
8
|
+
* source is inspected here only to derive a boolean; it is never returned.
|
|
9
|
+
*/ const stripComments = (body)=>body.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/[^\n]*/g, '').trim();
|
|
10
|
+
const isLifecycleNonEmpty = (fn)=>{
|
|
11
|
+
if (typeof fn !== 'function') {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const source = Function.prototype.toString.call(fn);
|
|
15
|
+
// The body starts at the first `{` AFTER the parameter list closes, not the
|
|
16
|
+
// first `{` overall: a real lifecycle signature like `register({ strapi })`
|
|
17
|
+
// or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.
|
|
18
|
+
const parenEnd = source.indexOf(')');
|
|
19
|
+
const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);
|
|
20
|
+
// No brace anywhere after the parameters means a concise arrow body
|
|
21
|
+
// (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the
|
|
22
|
+
// arrow IS the body. Treating that as empty under-reported a real customization,
|
|
23
|
+
// telling Support an app was stock when it was not. The template only ever ships
|
|
24
|
+
// braced method shorthand, so this branch cannot misread a fresh app.
|
|
25
|
+
if (bodyStart === -1) {
|
|
26
|
+
const arrow = source.indexOf('=>');
|
|
27
|
+
return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;
|
|
28
|
+
}
|
|
29
|
+
return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A default `createCoreService` result has its CRUD methods on its class
|
|
33
|
+
* prototype and only `contentType` as an own key; that own key is copied onto
|
|
34
|
+
* the direct prototype (the base service instance) too, so a default service
|
|
35
|
+
* never has an own key that its direct prototype doesn't also have. A custom
|
|
36
|
+
* service (built via a `cfg` object/callback) has extra own method keys that
|
|
37
|
+
* are absent from the prototype it was assigned. Comparing own keys against
|
|
38
|
+
* the DIRECT prototype's own keys (rather than guessing base method names)
|
|
39
|
+
* avoids flagging every real service as custom.
|
|
40
|
+
*/ const isCustomService = (service)=>{
|
|
41
|
+
if (service === null || typeof service !== 'object') {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const proto = Object.getPrototypeOf(service);
|
|
45
|
+
const protoOwnKeys = proto ? Object.keys(proto) : [];
|
|
46
|
+
return Object.keys(service).some((key)=>!protoOwnKeys.includes(key));
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Custom routes in Strapi are added as separate files in an api's `routes/`
|
|
50
|
+
* directory (each exporting a plain `{ routes: [...] }` object), never by
|
|
51
|
+
* editing the factory-generated route file, because Koa needs explicit route
|
|
52
|
+
* ordering. The factory router exposes `routes` as a getter, so any route
|
|
53
|
+
* file exposing `routes` as a plain data property is a hand-written custom
|
|
54
|
+
* route file.
|
|
55
|
+
*/ const hasCustomRoutes = (strapi, apiName)=>{
|
|
56
|
+
const api = strapi.api(apiName);
|
|
57
|
+
const routeFiles = api?.routes ?? {};
|
|
58
|
+
return Object.values(routeFiles).some((router)=>{
|
|
59
|
+
if (router === null || typeof router !== 'object') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');
|
|
63
|
+
// A factory router exposes `routes` as an accessor (getter); a hand-written
|
|
64
|
+
// custom routes file exports it as a plain data property.
|
|
65
|
+
return descriptor ? typeof descriptor.get !== 'function' : false;
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* `createCoreController` sets the controller's prototype to the factory's base controller, and
|
|
70
|
+
* marks it when the app passed its own config. Anything else was not minted by the factory: a
|
|
71
|
+
* plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a
|
|
72
|
+
* factory that returned a non-object is not stock either. Neither may throw out of the dump.
|
|
73
|
+
*/ const isCustomApiController = (controller)=>{
|
|
74
|
+
if (controller === null || typeof controller !== 'object') {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
const prototype = Object.getPrototypeOf(controller);
|
|
78
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return isCustomController(controller);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Plugin and admin controllers are plain objects even when stock, so only the factory's
|
|
85
|
+
* custom-config mark can single one out here (the same test startup telemetry uses).
|
|
86
|
+
*/ const isCustomFactoryController = (controller)=>controller !== null && typeof controller === 'object' && isCustomController(controller);
|
|
87
|
+
/**
|
|
88
|
+
* Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can
|
|
89
|
+
* replace any controller, service or route, or content-type schema overrides. A plugin
|
|
90
|
+
* controller looks the same stock or overridden, so this folder is what tells Support a
|
|
91
|
+
* plugin was changed.
|
|
92
|
+
*/ // The loader applies content-type overrides from `content-types/<name>/schema.json` only
|
|
93
|
+
const hasSchemaOverride = (pluginDir)=>{
|
|
94
|
+
const contentTypesDir = path.join(pluginDir, 'content-types');
|
|
95
|
+
if (!fs.existsSync(contentTypesDir)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return fs.readdirSync(contentTypesDir, {
|
|
99
|
+
withFileTypes: true
|
|
100
|
+
}).some((entry)=>entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json')));
|
|
101
|
+
};
|
|
102
|
+
const listExtendedPlugins = (strapi)=>{
|
|
103
|
+
const extensionsDir = strapi.dirs?.dist?.extensions;
|
|
104
|
+
if (!extensionsDir || !fs.existsSync(extensionsDir)) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return fs.readdirSync(extensionsDir, {
|
|
108
|
+
withFileTypes: true
|
|
109
|
+
}).filter((entry)=>entry.isDirectory()).map((entry)=>entry.name).filter((name)=>fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) || hasSchemaOverride(path.join(extensionsDir, name))).sort();
|
|
110
|
+
};
|
|
111
|
+
// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];
|
|
112
|
+
// keep the two in sync.
|
|
113
|
+
const detectCustomizations = (strapi)=>{
|
|
114
|
+
const controllers = strapi.controllers ?? {};
|
|
115
|
+
const services = strapi.services ?? {};
|
|
116
|
+
const appControllerUids = Object.keys(controllers).filter((uid)=>uid.startsWith(APP_UID_PREFIX));
|
|
117
|
+
const apis = appControllerUids.map((uid)=>{
|
|
118
|
+
const controller = controllers[uid];
|
|
119
|
+
const service = services[uid];
|
|
120
|
+
// uid is `api::<name>.<name>`; map to the bare api name for route lookup.
|
|
121
|
+
const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];
|
|
122
|
+
return {
|
|
123
|
+
uid,
|
|
124
|
+
customController: isCustomApiController(controller),
|
|
125
|
+
customService: isCustomService(service),
|
|
126
|
+
customRoutes: hasCustomRoutes(strapi, apiName)
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
// Every controller, not only the app's own: the dump is used to rebuild an app for debugging.
|
|
130
|
+
const allControllers = Object.keys(controllers).map((uid)=>({
|
|
131
|
+
uid,
|
|
132
|
+
custom: uid.startsWith(APP_UID_PREFIX) ? isCustomApiController(controllers[uid]) : isCustomFactoryController(controllers[uid])
|
|
133
|
+
}));
|
|
134
|
+
const app = strapi.app;
|
|
135
|
+
const registerDefined = typeof app?.register === 'function';
|
|
136
|
+
const bootstrapDefined = typeof app?.bootstrap === 'function';
|
|
137
|
+
const destroyDefined = typeof app?.destroy === 'function';
|
|
138
|
+
const registerNonEmpty = isLifecycleNonEmpty(app?.register);
|
|
139
|
+
const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);
|
|
140
|
+
const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);
|
|
141
|
+
return {
|
|
142
|
+
apis,
|
|
143
|
+
controllers: allControllers,
|
|
144
|
+
extendedPlugins: listExtendedPlugins(strapi),
|
|
145
|
+
counts: {
|
|
146
|
+
customControllers: allControllers.filter((c)=>c.custom).length,
|
|
147
|
+
customServices: apis.filter((a)=>a.customService).length,
|
|
148
|
+
customRoutes: apis.filter((a)=>a.customRoutes).length
|
|
149
|
+
},
|
|
150
|
+
srcIndex: {
|
|
151
|
+
present: app != null,
|
|
152
|
+
registerDefined,
|
|
153
|
+
registerNonEmpty,
|
|
154
|
+
bootstrapDefined,
|
|
155
|
+
bootstrapNonEmpty,
|
|
156
|
+
destroyDefined,
|
|
157
|
+
destroyNonEmpty,
|
|
158
|
+
// Template ships only empty register + bootstrap and no destroy.
|
|
159
|
+
beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export { detectCustomizations, isLifecycleNonEmpty };
|
|
165
|
+
//# sourceMappingURL=detect-customizations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-customizations.mjs","sources":["../../src/utils/detect-customizations.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport type { Core } from '@strapi/types';\n\nimport * as factories from '../factories';\n\nconst APP_UID_PREFIX = 'api::';\n\n/**\n * True when a lifecycle function has a non-empty body. The compiled function\n * source is inspected here only to derive a boolean; it is never returned.\n */\nconst stripComments = (body: string): string =>\n body\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n .replace(/\\/\\/[^\\n]*/g, '')\n .trim();\n\nexport const isLifecycleNonEmpty = (fn: unknown): boolean => {\n if (typeof fn !== 'function') {\n return false;\n }\n const source = Function.prototype.toString.call(fn);\n // The body starts at the first `{` AFTER the parameter list closes, not the\n // first `{` overall: a real lifecycle signature like `register({ strapi })`\n // or the template's `register(/*{ strapi }*/)` puts a `{` in the params/comment.\n const parenEnd = source.indexOf(')');\n const bodyStart = source.indexOf('{', parenEnd === -1 ? 0 : parenEnd);\n\n // No brace anywhere after the parameters means a concise arrow body\n // (`register: ({ strapi }) => strapi.log.info('x')`), where everything after the\n // arrow IS the body. Treating that as empty under-reported a real customization,\n // telling Support an app was stock when it was not. The template only ever ships\n // braced method shorthand, so this branch cannot misread a fresh app.\n if (bodyStart === -1) {\n const arrow = source.indexOf('=>');\n return arrow === -1 ? false : stripComments(source.slice(arrow + 2)).length > 0;\n }\n\n return stripComments(source.slice(bodyStart + 1, source.lastIndexOf('}'))).length > 0;\n};\n\n/**\n * A default `createCoreService` result has its CRUD methods on its class\n * prototype and only `contentType` as an own key; that own key is copied onto\n * the direct prototype (the base service instance) too, so a default service\n * never has an own key that its direct prototype doesn't also have. A custom\n * service (built via a `cfg` object/callback) has extra own method keys that\n * are absent from the prototype it was assigned. Comparing own keys against\n * the DIRECT prototype's own keys (rather than guessing base method names)\n * avoids flagging every real service as custom.\n */\nconst isCustomService = (service: unknown): boolean => {\n if (service === null || typeof service !== 'object') {\n return false;\n }\n const proto = Object.getPrototypeOf(service);\n const protoOwnKeys = proto ? Object.keys(proto) : [];\n return Object.keys(service).some((key) => !protoOwnKeys.includes(key));\n};\n\n/**\n * Custom routes in Strapi are added as separate files in an api's `routes/`\n * directory (each exporting a plain `{ routes: [...] }` object), never by\n * editing the factory-generated route file, because Koa needs explicit route\n * ordering. The factory router exposes `routes` as a getter, so any route\n * file exposing `routes` as a plain data property is a hand-written custom\n * route file.\n */\nconst hasCustomRoutes = (strapi: Core.Strapi, apiName: string): boolean => {\n const api = strapi.api(apiName);\n const routeFiles = api?.routes ?? {};\n return Object.values(routeFiles).some((router) => {\n if (router === null || typeof router !== 'object') {\n return false;\n }\n const descriptor = Object.getOwnPropertyDescriptor(router, 'routes');\n // A factory router exposes `routes` as an accessor (getter); a hand-written\n // custom routes file exports it as a plain data property.\n return descriptor ? typeof descriptor.get !== 'function' : false;\n });\n};\n\n/**\n * `createCoreController` sets the controller's prototype to the factory's base controller, and\n * marks it when the app passed its own config. Anything else was not minted by the factory: a\n * plain action map (`module.exports = { async find() {} }`) is entirely hand-written, and a\n * factory that returned a non-object is not stock either. Neither may throw out of the dump.\n */\nconst isCustomApiController = (controller: unknown): boolean => {\n if (controller === null || typeof controller !== 'object') {\n return true;\n }\n\n const prototype = Object.getPrototypeOf(controller);\n if (prototype === Object.prototype || prototype === null) {\n return true;\n }\n\n return factories.isCustomController(controller as Core.Controller);\n};\n\n/**\n * Plugin and admin controllers are plain objects even when stock, so only the factory's\n * custom-config mark can single one out here (the same test startup telemetry uses).\n */\nconst isCustomFactoryController = (controller: unknown): boolean =>\n controller !== null &&\n typeof controller === 'object' &&\n factories.isCustomController(controller as Core.Controller);\n\n/**\n * Plugins the app overrides through `src/extensions/<plugin>/`: a `strapi-server.js`, which can\n * replace any controller, service or route, or content-type schema overrides. A plugin\n * controller looks the same stock or overridden, so this folder is what tells Support a\n * plugin was changed.\n */\n// The loader applies content-type overrides from `content-types/<name>/schema.json` only\nconst hasSchemaOverride = (pluginDir: string): boolean => {\n const contentTypesDir = path.join(pluginDir, 'content-types');\n if (!fs.existsSync(contentTypesDir)) {\n return false;\n }\n\n return fs\n .readdirSync(contentTypesDir, { withFileTypes: true })\n .some(\n (entry) =>\n entry.isDirectory() && fs.existsSync(path.join(contentTypesDir, entry.name, 'schema.json'))\n );\n};\n\nconst listExtendedPlugins = (strapi: Core.Strapi): string[] => {\n const extensionsDir = strapi.dirs?.dist?.extensions;\n if (!extensionsDir || !fs.existsSync(extensionsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(extensionsDir, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .filter(\n (name) =>\n fs.existsSync(path.join(extensionsDir, name, 'strapi-server.js')) ||\n hasSchemaOverride(path.join(extensionsDir, name))\n )\n .sort();\n};\n\n// Return shape is mirrored in @strapi/types Core.Strapi['getCustomizations'];\n// keep the two in sync.\nexport const detectCustomizations = (strapi: Core.Strapi) => {\n const controllers = strapi.controllers ?? {};\n const services = strapi.services ?? {};\n\n const appControllerUids = Object.keys(controllers).filter((uid) =>\n uid.startsWith(APP_UID_PREFIX)\n );\n\n const apis = appControllerUids.map((uid) => {\n const controller = controllers[uid];\n const service = services[uid];\n // uid is `api::<name>.<name>`; map to the bare api name for route lookup.\n const apiName = uid.slice(APP_UID_PREFIX.length).split('.')[0];\n\n return {\n uid,\n customController: isCustomApiController(controller),\n customService: isCustomService(service),\n customRoutes: hasCustomRoutes(strapi, apiName),\n };\n });\n\n // Every controller, not only the app's own: the dump is used to rebuild an app for debugging.\n const allControllers = Object.keys(controllers).map((uid) => ({\n uid,\n custom: uid.startsWith(APP_UID_PREFIX)\n ? isCustomApiController(controllers[uid])\n : isCustomFactoryController(controllers[uid]),\n }));\n\n const app = strapi.app;\n const registerDefined = typeof app?.register === 'function';\n const bootstrapDefined = typeof app?.bootstrap === 'function';\n const destroyDefined = typeof app?.destroy === 'function';\n const registerNonEmpty = isLifecycleNonEmpty(app?.register);\n const bootstrapNonEmpty = isLifecycleNonEmpty(app?.bootstrap);\n const destroyNonEmpty = isLifecycleNonEmpty(app?.destroy);\n\n return {\n apis,\n controllers: allControllers,\n extendedPlugins: listExtendedPlugins(strapi),\n counts: {\n customControllers: allControllers.filter((c) => c.custom).length,\n customServices: apis.filter((a) => a.customService).length,\n customRoutes: apis.filter((a) => a.customRoutes).length,\n },\n srcIndex: {\n present: app != null,\n registerDefined,\n registerNonEmpty,\n bootstrapDefined,\n bootstrapNonEmpty,\n destroyDefined,\n destroyNonEmpty,\n // Template ships only empty register + bootstrap and no destroy.\n beyondTemplate: destroyDefined || registerNonEmpty || bootstrapNonEmpty,\n },\n };\n};\n"],"names":["APP_UID_PREFIX","stripComments","body","replace","trim","isLifecycleNonEmpty","fn","source","Function","prototype","toString","call","parenEnd","indexOf","bodyStart","arrow","slice","length","lastIndexOf","isCustomService","service","proto","Object","getPrototypeOf","protoOwnKeys","keys","some","key","includes","hasCustomRoutes","strapi","apiName","api","routeFiles","routes","values","router","descriptor","getOwnPropertyDescriptor","get","isCustomApiController","controller","factories","isCustomFactoryController","hasSchemaOverride","pluginDir","contentTypesDir","path","join","fs","existsSync","readdirSync","withFileTypes","entry","isDirectory","name","listExtendedPlugins","extensionsDir","dirs","dist","extensions","filter","map","sort","detectCustomizations","controllers","services","appControllerUids","uid","startsWith","apis","split","customController","customService","customRoutes","allControllers","custom","app","registerDefined","register","bootstrapDefined","bootstrap","destroyDefined","destroy","registerNonEmpty","bootstrapNonEmpty","destroyNonEmpty","extendedPlugins","counts","customControllers","c","customServices","a","srcIndex","present","beyondTemplate"],"mappings":";;;;AAOA,MAAMA,cAAAA,GAAiB,OAAA;AAEvB;;;AAGC,IACD,MAAMC,aAAAA,GAAgB,CAACC,IAAAA,GACrBA,IAAAA,CACGC,OAAO,CAAC,mBAAA,EAAqB,EAAA,CAAA,CAC7BA,OAAO,CAAC,aAAA,EAAe,IACvBC,IAAI,EAAA;AAEF,MAAMC,sBAA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{"version":3,"file":"filepath-to-prop-path.d.ts","sourceRoot":"","sources":["../../src/utils/filepath-to-prop-path.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,MAAM,EACjB,mBAAkB,OAAc,KAC/B,MAAM,
|
|
1
|
+
{"version":3,"file":"filepath-to-prop-path.d.ts","sourceRoot":"","sources":["../../src/utils/filepath-to-prop-path.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,MAAM,EACjB,mBAAkB,OAAc,KAC/B,MAAM,EAaR,CAAC"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
|
-
var
|
|
4
|
+
var _ = require('lodash');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
7
|
|
|
8
8
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
9
|
-
var fp__default = /*#__PURE__*/_interopDefault(fp);
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Returns a path (as an array) from a file path
|
|
13
12
|
*/ const filePathToPropPath = (entryPath, useFileNameAsKey = true)=>{
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
fp__default.default.toLower, // Split the cleaned path by matching every possible separator (either "/" or "\" depending on the OS)
|
|
19
|
-
fp__default.default.split(new RegExp(`[\\${path__default.default.win32.sep}|${path__default.default.posix.sep}]`, 'g')), // Make sure to remove leading '.' from the different path parts
|
|
20
|
-
fp__default.default.map(fp__default.default.trimCharsStart('.')), // join + split in case some '.' characters are still present in different parts of the path
|
|
21
|
-
fp__default.default.join('.'), fp__default.default.split('.'), // Remove the last portion of the path array if the file name shouldn't be used as a key
|
|
22
|
-
useFileNameAsKey ? fp__default.default.identity : fp__default.default.slice(0, -1));
|
|
23
|
-
return transform(entryPath);
|
|
13
|
+
const cleanPath = removeRelativePrefix(entryPath).replace(/(\.settings|\.json|\.js)/g, '').toLowerCase();
|
|
14
|
+
const parts = cleanPath.split(new RegExp(`[\\${path__default.default.win32.sep}|${path__default.default.posix.sep}]`, 'g')).map((part)=>_.trimStart(part, '.'))// Dots can also delimit properties within a path segment.
|
|
15
|
+
.join('.').split('.');
|
|
16
|
+
return useFileNameAsKey ? parts : parts.slice(0, -1);
|
|
24
17
|
};
|
|
25
18
|
const removeRelativePrefix = (filePath)=>{
|
|
26
19
|
return filePath.startsWith(`.${path__default.default.win32.sep}`) || filePath.startsWith(`.${path__default.default.posix.sep}`) ? filePath.slice(2) : filePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filepath-to-prop-path.js","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"filepath-to-prop-path.js","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport { trimStart } from 'lodash';\n\n/**\n * Returns a path (as an array) from a file path\n */\nexport const filePathToPropPath = (\n entryPath: string,\n useFileNameAsKey: boolean = true\n): string[] => {\n const cleanPath = removeRelativePrefix(entryPath)\n .replace(/(\\.settings|\\.json|\\.js)/g, '')\n .toLowerCase();\n\n const parts = cleanPath\n .split(new RegExp(`[\\\\${path.win32.sep}|${path.posix.sep}]`, 'g'))\n .map((part) => trimStart(part, '.'))\n // Dots can also delimit properties within a path segment.\n .join('.')\n .split('.');\n\n return useFileNameAsKey ? parts : parts.slice(0, -1);\n};\n\nconst removeRelativePrefix = (filePath: string) => {\n return filePath.startsWith(`.${path.win32.sep}`) || filePath.startsWith(`.${path.posix.sep}`)\n ? filePath.slice(2)\n : filePath;\n};\n"],"names":["filePathToPropPath","entryPath","useFileNameAsKey","cleanPath","removeRelativePrefix","replace","toLowerCase","parts","split","RegExp","path","win32","sep","posix","map","part","trimStart","join","slice","filePath","startsWith"],"mappings":";;;;;;;;;AAGA;;AAEC,IACM,MAAMA,kBAAAA,GAAqB,CAChCC,SAAAA,EACAC,mBAA4B,IAAI,GAAA;AAEhC,IAAA,MAAMC,YAAYC,oBAAAA,CAAqBH,SAAAA,CAAAA,CACpCI,OAAO,CAAC,2BAAA,EAA6B,IACrCC,WAAW,EAAA;AAEd,IAAA,MAAMC,KAAAA,GAAQJ,SAAAA,CACXK,KAAK,CAAC,IAAIC,MAAAA,CAAO,CAAC,GAAG,EAAEC,qBAAAA,CAAKC,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEF,qBAAAA,CAAKG,KAAK,CAACD,GAAG,CAAC,CAAC,CAAC,EAAE,GAAA,CAAA,CAAA,CAC5DE,GAAG,CAAC,CAACC,IAAAA,GAASC,WAAAA,CAAUD,IAAAA,EAAM,KAC/B;KACCE,IAAI,CAAC,GAAA,CAAA,CACLT,KAAK,CAAC,GAAA,CAAA;AAET,IAAA,OAAON,mBAAmBK,KAAAA,GAAQA,KAAAA,CAAMW,KAAK,CAAC,GAAG,EAAC,CAAA;AACpD;AAEA,MAAMd,uBAAuB,CAACe,QAAAA,GAAAA;IAC5B,OAAOA,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,qBAAAA,CAAKC,KAAK,CAACC,GAAG,CAAA,CAAE,CAAA,IAAKO,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,qBAAAA,CAAKG,KAAK,CAACD,GAAG,CAAA,CAAE,CAAA,GACxFO,QAAAA,CAASD,KAAK,CAAC,CAAA,CAAA,GACfC,QAAAA;AACN,CAAA;;;;"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import
|
|
2
|
+
import { trimStart } from 'lodash';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns a path (as an array) from a file path
|
|
6
6
|
*/ const filePathToPropPath = (entryPath, useFileNameAsKey = true)=>{
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fp.toLower, // Split the cleaned path by matching every possible separator (either "/" or "\" depending on the OS)
|
|
12
|
-
fp.split(new RegExp(`[\\${path.win32.sep}|${path.posix.sep}]`, 'g')), // Make sure to remove leading '.' from the different path parts
|
|
13
|
-
fp.map(fp.trimCharsStart('.')), // join + split in case some '.' characters are still present in different parts of the path
|
|
14
|
-
fp.join('.'), fp.split('.'), // Remove the last portion of the path array if the file name shouldn't be used as a key
|
|
15
|
-
useFileNameAsKey ? fp.identity : fp.slice(0, -1));
|
|
16
|
-
return transform(entryPath);
|
|
7
|
+
const cleanPath = removeRelativePrefix(entryPath).replace(/(\.settings|\.json|\.js)/g, '').toLowerCase();
|
|
8
|
+
const parts = cleanPath.split(new RegExp(`[\\${path.win32.sep}|${path.posix.sep}]`, 'g')).map((part)=>trimStart(part, '.'))// Dots can also delimit properties within a path segment.
|
|
9
|
+
.join('.').split('.');
|
|
10
|
+
return useFileNameAsKey ? parts : parts.slice(0, -1);
|
|
17
11
|
};
|
|
18
12
|
const removeRelativePrefix = (filePath)=>{
|
|
19
13
|
return filePath.startsWith(`.${path.win32.sep}`) || filePath.startsWith(`.${path.posix.sep}`) ? filePath.slice(2) : filePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filepath-to-prop-path.mjs","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"filepath-to-prop-path.mjs","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport { trimStart } from 'lodash';\n\n/**\n * Returns a path (as an array) from a file path\n */\nexport const filePathToPropPath = (\n entryPath: string,\n useFileNameAsKey: boolean = true\n): string[] => {\n const cleanPath = removeRelativePrefix(entryPath)\n .replace(/(\\.settings|\\.json|\\.js)/g, '')\n .toLowerCase();\n\n const parts = cleanPath\n .split(new RegExp(`[\\\\${path.win32.sep}|${path.posix.sep}]`, 'g'))\n .map((part) => trimStart(part, '.'))\n // Dots can also delimit properties within a path segment.\n .join('.')\n .split('.');\n\n return useFileNameAsKey ? parts : parts.slice(0, -1);\n};\n\nconst removeRelativePrefix = (filePath: string) => {\n return filePath.startsWith(`.${path.win32.sep}`) || filePath.startsWith(`.${path.posix.sep}`)\n ? filePath.slice(2)\n : filePath;\n};\n"],"names":["filePathToPropPath","entryPath","useFileNameAsKey","cleanPath","removeRelativePrefix","replace","toLowerCase","parts","split","RegExp","path","win32","sep","posix","map","part","trimStart","join","slice","filePath","startsWith"],"mappings":";;;AAGA;;AAEC,IACM,MAAMA,kBAAAA,GAAqB,CAChCC,SAAAA,EACAC,mBAA4B,IAAI,GAAA;AAEhC,IAAA,MAAMC,YAAYC,oBAAAA,CAAqBH,SAAAA,CAAAA,CACpCI,OAAO,CAAC,2BAAA,EAA6B,IACrCC,WAAW,EAAA;AAEd,IAAA,MAAMC,KAAAA,GAAQJ,SAAAA,CACXK,KAAK,CAAC,IAAIC,MAAAA,CAAO,CAAC,GAAG,EAAEC,IAAAA,CAAKC,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEF,IAAAA,CAAKG,KAAK,CAACD,GAAG,CAAC,CAAC,CAAC,EAAE,GAAA,CAAA,CAAA,CAC5DE,GAAG,CAAC,CAACC,IAAAA,GAASC,SAAAA,CAAUD,IAAAA,EAAM,KAC/B;KACCE,IAAI,CAAC,GAAA,CAAA,CACLT,KAAK,CAAC,GAAA,CAAA;AAET,IAAA,OAAON,mBAAmBK,KAAAA,GAAQA,KAAAA,CAAMW,KAAK,CAAC,GAAG,EAAC,CAAA;AACpD;AAEA,MAAMd,uBAAuB,CAACe,QAAAA,GAAAA;IAC5B,OAAOA,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAAA,CAAKC,KAAK,CAACC,GAAG,CAAA,CAAE,CAAA,IAAKO,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAAA,CAAKG,KAAK,CAACD,GAAG,CAAA,CAAE,CAAA,GACxFO,QAAAA,CAASD,KAAK,CAAC,CAAA,CAAA,GACfC,QAAAA;AACN,CAAA;;;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _ = require('lodash');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Test if the strapi application is considered as initialized (1st user has been created)
|
|
7
7
|
*/ const isInitialized = async (strapi)=>{
|
|
8
8
|
try {
|
|
9
|
-
if (
|
|
9
|
+
if (_.isEmpty(strapi.admin)) {
|
|
10
10
|
return true;
|
|
11
11
|
}
|
|
12
12
|
// test if there is at least one admin
|
|
@@ -15,7 +15,7 @@ var fp = require('lodash/fp');
|
|
|
15
15
|
'id'
|
|
16
16
|
]
|
|
17
17
|
});
|
|
18
|
-
return
|
|
18
|
+
return anyAdministrator != null;
|
|
19
19
|
} catch (err) {
|
|
20
20
|
strapi.stopWithError(err);
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-initialized.js","sources":["../../src/utils/is-initialized.ts"],"sourcesContent":["import { isEmpty
|
|
1
|
+
{"version":3,"file":"is-initialized.js","sources":["../../src/utils/is-initialized.ts"],"sourcesContent":["import { isEmpty } from 'lodash';\n\nimport type { Core } from '@strapi/types';\n\n/**\n * Test if the strapi application is considered as initialized (1st user has been created)\n */\nexport const isInitialized = async (strapi: Core.Strapi): Promise<boolean> => {\n try {\n if (isEmpty(strapi.admin)) {\n return true;\n }\n\n // test if there is at least one admin\n const anyAdministrator = await strapi.db.query('admin::user').findOne({ select: ['id'] });\n\n return anyAdministrator != null;\n } catch (err) {\n strapi.stopWithError(err);\n }\n};\n"],"names":["isInitialized","strapi","isEmpty","admin","anyAdministrator","db","query","findOne","select","err","stopWithError"],"mappings":";;;;AAIA;;IAGO,MAAMA,aAAAA,GAAgB,OAAOC,MAAAA,GAAAA;IAClC,IAAI;QACF,IAAIC,SAAAA,CAAQD,MAAAA,CAAOE,KAAK,CAAA,EAAG;YACzB,OAAO,IAAA;AACT,QAAA;;QAGA,MAAMC,gBAAAA,GAAmB,MAAMH,MAAAA,CAAOI,EAAE,CAACC,KAAK,CAAC,aAAA,CAAA,CAAeC,OAAO,CAAC;YAAEC,MAAAA,EAAQ;AAAC,gBAAA;AAAK;AAAC,SAAA,CAAA;AAEvF,QAAA,OAAOJ,gBAAAA,IAAoB,IAAA;AAC7B,IAAA,CAAA,CAAE,OAAOK,GAAAA,EAAK;AACZR,QAAAA,MAAAA,CAAOS,aAAa,CAACD,GAAAA,CAAAA;AACvB,IAAA;AACF;;;;"}
|