UNPKG

@strapi/strapi

Version:

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

1 lines 1.92 kB
{"version":3,"file":"linked-packages.mjs","sources":["../../../../src/node/core/linked-packages.ts"],"sourcesContent":["import path from 'node:path';\nimport { getModulePath } from './resolve-module';\n\nconst DESIGN_SYSTEM_MODULE = '@strapi/design-system';\n\n/**\n * Detect if a package is locally linked (portal:, file:, yarn link) rather than installed in node_modules.\n * When linked, the resolved path is outside node_modules.\n *\n * @internal\n */\nexport const isPackageLinked = (mod: string): boolean => {\n const pkgRoot = getModulePath(mod);\n const pathSegments = pkgRoot.split(path.sep);\n return !pathSegments.includes('node_modules');\n};\n\n/**\n * Detects if @strapi/design-system is linked (portal:, file:, or yarn link).\n * Returns the package root path when linked, null otherwise.\n * Uses the heuristic: linked packages resolve outside node_modules.\n */\nexport const getLinkedDesignSystemPath = (): string | null => {\n try {\n const pkgRoot = getModulePath(DESIGN_SYSTEM_MODULE);\n return isPackageLinked(DESIGN_SYSTEM_MODULE) ? pkgRoot : null;\n } catch {\n return null;\n }\n};\n\nexport const isDesignSystemLinked = (): boolean => getLinkedDesignSystemPath() !== null;\n"],"names":["DESIGN_SYSTEM_MODULE","isPackageLinked","mod","pkgRoot","getModulePath","pathSegments","split","path","sep","includes","getLinkedDesignSystemPath","isDesignSystemLinked"],"mappings":";;;AAGA,MAAMA,oBAAAA,GAAuB,uBAAA;AAE7B;;;;;IAMO,MAAMC,eAAAA,GAAkB,CAACC,GAAAA,GAAAA;AAC9B,IAAA,MAAMC,UAAUC,aAAAA,CAAcF,GAAAA,CAAAA;AAC9B,IAAA,MAAMG,YAAAA,GAAeF,OAAAA,CAAQG,KAAK,CAACC,KAAKC,GAAG,CAAA;IAC3C,OAAO,CAACH,YAAAA,CAAaI,QAAQ,CAAC,cAAA,CAAA;AAChC;AAEA;;;;UAKaC,yBAAAA,GAA4B,IAAA;IACvC,IAAI;AACF,QAAA,MAAMP,UAAUC,aAAAA,CAAcJ,oBAAAA,CAAAA;QAC9B,OAAOC,eAAAA,CAAgBD,wBAAwBG,OAAAA,GAAU,IAAA;AAC3D,IAAA,CAAA,CAAE,OAAM;QACN,OAAO,IAAA;AACT,IAAA;AACF;AAEO,MAAMQ,oBAAAA,GAAuB,IAAeD,yBAAAA,EAAAA,KAAgC;;;;"}