@intlayer/chokidar 8.3.2 → 8.3.4
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/assets/initConfig/templates/cjs.txt +3 -17
- package/dist/assets/initConfig/templates/json.txt +1 -5
- package/dist/assets/initConfig/templates/mjs.txt +3 -17
- package/dist/assets/initConfig/templates/ts.txt +3 -17
- package/dist/cjs/filterInvalidDictionaries.cjs +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/initConfig/index.cjs +1 -1
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +1 -1
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +1 -1
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs +1 -1
- package/dist/esm/filterInvalidDictionaries.mjs.map +1 -1
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/initConfig/index.mjs +1 -1
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +1 -1
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +1 -1
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/types/installSkills/index.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -25,22 +25,6 @@ const config = {
|
|
|
25
25
|
*/
|
|
26
26
|
mode: 'prefix-no-default',
|
|
27
27
|
},
|
|
28
|
-
content: {
|
|
29
|
-
/**
|
|
30
|
-
* File extensions to scan for dictionaries.
|
|
31
|
-
* Default: ['.content.ts', '.content.js', '.content.json', etc.]
|
|
32
|
-
*/
|
|
33
|
-
fileExtensions: ['.content.ts'],
|
|
34
|
-
/**
|
|
35
|
-
* Directories where .content files are located.
|
|
36
|
-
*/
|
|
37
|
-
contentDir: ['.'],
|
|
38
|
-
/**
|
|
39
|
-
* Directories where source code is located.
|
|
40
|
-
* Used for build optimization and code transformation.
|
|
41
|
-
*/
|
|
42
|
-
codeDir: ['.'],
|
|
43
|
-
},
|
|
44
28
|
editor: {
|
|
45
29
|
/**
|
|
46
30
|
* Whether the visual editor is enabled.
|
|
@@ -72,8 +56,10 @@ const config = {
|
|
|
72
56
|
applicationContext: [''].join('\n'),
|
|
73
57
|
},
|
|
74
58
|
compiler: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
|
|
75
61
|
/**
|
|
76
|
-
* Defines the output files path
|
|
62
|
+
* Defines the output files path for autogenerated content (compiler / autofill / extract)
|
|
77
63
|
*
|
|
78
64
|
* - `./` paths are resolved relative to the component directory.
|
|
79
65
|
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
@@ -6,11 +6,6 @@
|
|
|
6
6
|
"routing": {
|
|
7
7
|
"mode": "prefix-no-default"
|
|
8
8
|
},
|
|
9
|
-
"content": {
|
|
10
|
-
"fileExtensions": [".content.ts"],
|
|
11
|
-
"contentDir": ["./src"],
|
|
12
|
-
"codeDir": ["./src"],
|
|
13
|
-
},
|
|
14
9
|
"editor": {
|
|
15
10
|
"enabled": false,
|
|
16
11
|
"applicationURL": 'http://localhost:3000',
|
|
@@ -25,6 +20,7 @@
|
|
|
25
20
|
"applicationContext": ',
|
|
26
21
|
},
|
|
27
22
|
"compiler": {
|
|
23
|
+
"enabled": true,
|
|
28
24
|
"output": './{{fileName}}.content.ts',
|
|
29
25
|
"saveComponents": false,
|
|
30
26
|
},
|
|
@@ -25,22 +25,6 @@ const config = {
|
|
|
25
25
|
*/
|
|
26
26
|
mode: 'prefix-no-default',
|
|
27
27
|
},
|
|
28
|
-
content: {
|
|
29
|
-
/**
|
|
30
|
-
* File extensions to scan for dictionaries.
|
|
31
|
-
* Default: ['.content.ts', '.content.js', '.content.json', etc.]
|
|
32
|
-
*/
|
|
33
|
-
fileExtensions: ['.content.ts'],
|
|
34
|
-
/**
|
|
35
|
-
* Directories where .content files are located.
|
|
36
|
-
*/
|
|
37
|
-
contentDir: ['.'],
|
|
38
|
-
/**
|
|
39
|
-
* Directories where source code is located.
|
|
40
|
-
* Used for build optimization and code transformation.
|
|
41
|
-
*/
|
|
42
|
-
codeDir: ['.'],
|
|
43
|
-
},
|
|
44
28
|
editor: {
|
|
45
29
|
/**
|
|
46
30
|
* Whether the visual editor is enabled.
|
|
@@ -72,8 +56,10 @@ const config = {
|
|
|
72
56
|
applicationContext: [''].join('\n'),
|
|
73
57
|
},
|
|
74
58
|
compiler: {
|
|
59
|
+
enabled: true,
|
|
60
|
+
|
|
75
61
|
/**
|
|
76
|
-
* Defines the output files path
|
|
62
|
+
* Defines the output files path for autogenerated content (compiler / autofill / extract)
|
|
77
63
|
*
|
|
78
64
|
* - `./` paths are resolved relative to the component directory.
|
|
79
65
|
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
@@ -24,22 +24,6 @@ const config: IntlayerConfig = {
|
|
|
24
24
|
*/
|
|
25
25
|
mode: 'prefix-no-default',
|
|
26
26
|
},
|
|
27
|
-
content: {
|
|
28
|
-
/**
|
|
29
|
-
* File extensions to scan for dictionaries.
|
|
30
|
-
* Default: ['.content.ts', '.content.js', '.content.json', etc.]
|
|
31
|
-
*/
|
|
32
|
-
fileExtensions: ['.content.ts'],
|
|
33
|
-
/**
|
|
34
|
-
* Directories where .content files are located.
|
|
35
|
-
*/
|
|
36
|
-
contentDir: ['.'],
|
|
37
|
-
/**
|
|
38
|
-
* Directories where source code is located.
|
|
39
|
-
* Used for build optimization and code transformation.
|
|
40
|
-
*/
|
|
41
|
-
codeDir: ['.'],
|
|
42
|
-
},
|
|
43
27
|
editor: {
|
|
44
28
|
/**
|
|
45
29
|
* Whether the visual editor is enabled.
|
|
@@ -71,8 +55,10 @@ const config: IntlayerConfig = {
|
|
|
71
55
|
applicationContext: [''].join('\n'),
|
|
72
56
|
},
|
|
73
57
|
compiler: {
|
|
58
|
+
enabled: true,
|
|
59
|
+
|
|
74
60
|
/**
|
|
75
|
-
* Defines the output files path
|
|
61
|
+
* Defines the output files path for autogenerated content (compiler / autofill / extract)
|
|
76
62
|
*
|
|
77
63
|
* - `./` paths are resolved relative to the component directory.
|
|
78
64
|
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/formatter.cjs`);let t=require(`@intlayer/config/logger`),n=require(`@intlayer/core/interpreter`);const r=(r,i,a)=>{let o=(0,t.getAppLogger)(i);if(!r)return!1;let s=r.location===`local`||typeof r.filePath==`string`?`Local`:`Remote`,c=!!r.key,l=!!r.content;if(!c)return o(`${s} dictionary has no key`,{level:`error`}),!1;if(!l)return o(`${s} dictionary ${(0,t.colorizeKey)(r.key)} has no content - ${r.filePath?e.formatPath(r.filePath):(0,t.colorizePath)(`Remote`)}`,{level:`error`}),!1;if(r.schema&&a?.checkSchema&&!(typeof r.content==`function`||typeof r.content==`object`&&r.content!==null&&typeof r.content.then==`function`)){let a=i?.internationalization?.locales??[],c=i?.internationalization.strictMode===`strict`,l=typeof r.schema==`string`?i?.schemas?.[r.schema]:void 0;if(l&&typeof l.safeParse==`function`)for(let i of a){let a=(0,n.getContent)(r.content,{dictionaryKey:r.key,keyPath:[]},i,!c),u=l.safeParse(a);if(!u.success)return o(`${s} dictionary ${(0,t.colorizeKey)(r.key)} has invalid content according to schema ${(0,t.colorize)(r.schema,t.ANSIColors.ORANGE)} for locale ${e.formatLocale(i)} - ${r.filePath?e.formatPath(r.filePath):(0,t.colorizePath)(`Remote`)}`,{level:`error`}),u.error.issues.forEach(n=>{o(`${t.x} Error: ${(0,t.colorizeKey)(r.key)} - ${e.formatLocale(i)} - ${(0,t.colorize)(`${n.path.join(`.`)}:`,t.ANSIColors.BLUE)} ${(0,t.colorize)(n.message,t.ANSIColors.GREY)}`,{level:`error`})}),!1}}return!0},i=(e,t,n)=>(e??[])?.filter(e=>r(e,t,n));exports.filterInvalidDictionaries=i,exports.isInvalidDictionary=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/formatter.cjs`);let t=require(`@intlayer/config/logger`),n=require(`@intlayer/core/interpreter`);const r=(r,i,a)=>{let o=(0,t.getAppLogger)(i);if(!r)return!1;let s=r.location===`local`||typeof r.filePath==`string`?`Local`:`Remote`,c=!!r.key,l=!!r.content;if(!c)return o(`${s} dictionary has no key`,{level:`error`}),!1;if(!l)return o(`${s} dictionary ${(0,t.colorizeKey)(r.key)} has no content - ${r.filePath?e.formatPath(r.filePath):(0,t.colorizePath)(`Remote`)}`,{level:`error`}),!1;if(r.schema&&a?.checkSchema&&!(typeof r.content==`function`||typeof r.content==`object`&&r.content!==null&&typeof r.content.then==`function`)){let a=i?.internationalization?.locales??[],c=i?.internationalization.strictMode===`strict`,l=typeof r.schema==`string`?i?.schemas?.[r.schema]:void 0;if(l&&typeof l.safeParse==`function`)for(let i of a){let a=(0,n.getContent)(r.content,{dictionaryKey:r.key,keyPath:[],locale:i},(0,n.getBasePlugins)(i,!c)),u=l.safeParse(a);if(!u.success)return o(`${s} dictionary ${(0,t.colorizeKey)(r.key)} has invalid content according to schema ${(0,t.colorize)(r.schema,t.ANSIColors.ORANGE)} for locale ${e.formatLocale(i)} - ${r.filePath?e.formatPath(r.filePath):(0,t.colorizePath)(`Remote`)}`,{level:`error`}),u.error.issues.forEach(n=>{o(`${t.x} Error: ${(0,t.colorizeKey)(r.key)} - ${e.formatLocale(i)} - ${(0,t.colorize)(`${n.path.join(`.`)}:`,t.ANSIColors.BLUE)} ${(0,t.colorize)(n.message,t.ANSIColors.GREY)}`,{level:`error`})}),!1}}return!0},i=(e,t,n)=>(e??[])?.filter(e=>r(e,t,n));exports.filterInvalidDictionaries=i,exports.isInvalidDictionary=r;
|
|
2
2
|
//# sourceMappingURL=filterInvalidDictionaries.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterInvalidDictionaries.cjs","names":["formatPath","ANSIColors","formatLocale","x"],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getContent } from '@intlayer/core/interpreter';\nimport type {
|
|
1
|
+
{"version":3,"file":"filterInvalidDictionaries.cjs","names":["formatPath","ANSIColors","formatLocale","x"],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n locale,\n },\n getBasePlugins(locale, !isStrict)\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":"yOAeA,MAAa,GACX,EACA,EACA,IACY,CACZ,IAAM,GAAA,EAAA,EAAA,cAAyB,EAAc,CAE7C,GAAI,CAAC,EAAY,MAAO,GAKxB,IAAM,EAFJ,EAAW,WAAa,SAAW,OAAO,EAAW,UAAa,SAEzC,QAAU,SAC/B,EAAS,EAAQ,EAAW,IAC5B,EAAa,EAAQ,EAAW,QAEtC,GAAI,CAAC,EAKH,OAJA,EAAU,GAAG,EAAS,wBAAyB,CAC7C,MAAO,QACR,CAAC,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CAAC,GAAID,EAAAA,WAAW,KAAK,CAAC,IAAA,EAAA,EAAA,UAAY,EAAM,QAASA,EAAAA,WAAW,KAAK,GAC3K,CACE,MAAO,QACR,CACF,EACD,CAEK,IAOjB,MAAO,IAGI,GACX,EACA,EACA,KAEC,GAAgB,EAAE,GAAG,OAAQ,GAC5B,EAAoB,EAAY,EAAe,EAAQ,CACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","writeFileToRoot","v","parseJSONWithComments","ensureDirectory","findTsConfigFiles","initConfig","updateViteConfig","updateNextConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n ensureDirectory,\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // 3. CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT FOR NEXT.JS >= 16\n if (isNextJsProject) {\n const nextVersion =\n packageJson.dependencies?.next || packageJson.devDependencies?.next;\n\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n if (!match) return false;\n const majorVersion = parseInt(match[1], 10);\n return majorVersion >= major;\n };\n\n if (nextVersion && isVersionGreaterOrEqual(nextVersion, 16)) {\n const devScript = packageJson.scripts?.dev;\n const expectedScript = \"intlayer watch --with 'bun run --bun next dev'\";\n\n if (\n devScript &&\n devScript !== expectedScript &&\n devScript.includes('next dev')\n ) {\n packageJson.scripts.dev = expectedScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script for Next.js >= 16`\n );\n }\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":"wbA2BA,MAAM,EAAsB,CAC1B,OAAQ,iDACR,UAAW,oDACX,UAAW,oDACX,IAAK,2DACL,MAAO,gDACP,aAAc,yDACd,2BACE,yEACF,oCACE,mFACF,WAAY,uDACZ,aAAc,yDACd,cAAe,0DACf,cAAe,0DACf,eAAgB,mDAChB,WAAY,uDACZ,QAAS,kDACT,UAAW,oDACX,mBACE,gEACF,KAAM,yDACN,QAAS,kDACT,OAAQ,iDACR,QAAS,kDACT,QAAS,uCAGT,SAAU,uDACV,aAAc,2DACd,UAAW,wDACX,YAAa,0DACb,QAAS,sDACV,CAKK,EAAuB,GAA6B,CACxD,IAAM,EAAO,CACX,GAAG,EAAY,aACf,GAAG,EAAY,gBAChB,CAMK,GAAa,EAAuB,IACpC,CAAC,GAAiB,OAAO,GAAkB,SAAiB,GAC9C,OAAO,WAAW,EAAM,WAAW,CACxC,KAAK,EAAc,CAIlC,GAAI,EAAK,mBAAqB,EAAK,iBACjC,OAAO,EAAoB,KAE7B,GAAI,EAAK,iBAAmB,EAAK,KAC/B,OAAO,EAAoB,mBAI7B,GAAI,EAAK,KAAM,CACb,IAAM,EAAU,EAAK,KAUrB,OARI,EAAU,EAAS,GAA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B,EAAO,gBAAgB,QAAU,EAAE,CAEnC,IAAI,EAAU,GAEd,OAAO,QAAQ,EAAQ,CAAC,SAAS,CAAC,EAAO,KAAU,CAC5C,EAAO,gBAAgB,MAAM,KAChC,EAAO,gBAAgB,MAAM,GAAS,CAAC,EAAK,CAC5C,EAAU,KAEZ,CAEE,IACF,MAAMC,EAAAA,gBACJ,EACA,EACA,KAAK,UAAU,EAAQ,KAAM,EAAE,CAChC,EACD,EAAA,EAAA,QACE,GAAGC,EAAAA,EAAE,YAAA,EAAA,EAAA,cACH,EACD,CAAC,8BACH,MAEE,CACL,EAAY,UAAY,EAAE,CAE1B,IAAI,EAAU,GAEd,OAAO,QAAQ,EAAQ,CAAC,SAAS,CAAC,EAAO,KAAU,CACjD,IAAM,EAAc,EAAM,QAAQ,IAAK,IAAI,CACrC,EAAa,EAAK,WAAW,IAAI,CAAG,EAAO,KAAK,IAEjD,EAAY,QAAQ,KACvB,EAAY,QAAQ,GAAe,EACnC,EAAU,KAEZ,CAEE,IACF,MAAMD,EAAAA,gBACJ,EACA,EACA,KAAK,UAAU,EAAa,KAAM,EAAE,CACrC,EACD,EAAA,EAAA,QACE,GAAGC,EAAAA,EAAE,YAAA,EAAA,EAAA,cACH,EACD,CAAC,8BACH,KAOT,EAAA,EAAA,QAAO,GAAGA,EAAAA,EAAE,IAAA,EAAA,EAAA,UAAY,gCAAiCL,EAAAA,WAAW,MAAM,GAAG,EAC7E,EAAA,EAAA,QAAO,gBACI,SAAUA,EAAAA,WAAW,QAAQ,gBAEpC,sEACAA,EAAAA,WAAW,WACZ,oBACY,EAAS,CACvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","writeFileToRoot","v","parseJSONWithComments","ensureDirectory","findTsConfigFiles","initConfig","updateViteConfig","updateNextConfig"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n ensureDirectory,\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT FOR NEXT.JS >= 16\n if (isNextJsProject) {\n const nextVersion =\n packageJson.dependencies?.next || packageJson.devDependencies?.next;\n\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n\n if (!match) return false;\n const majorVersion = parseInt(match[1], 10);\n return majorVersion >= major;\n };\n\n if (nextVersion && isVersionGreaterOrEqual(nextVersion, 16)) {\n const devScript = packageJson.scripts?.dev;\n const expectedScript = \"intlayer watch --with 'bun run --bun next dev'\";\n\n if (\n devScript &&\n devScript !== expectedScript &&\n devScript.includes('next dev')\n ) {\n packageJson.scripts.dev = expectedScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script for Next.js >= 16`\n );\n }\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\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Ac,EAAM,QAAQ,IAAK,IAAI,CACrC,EAAa,EAAK,WAAW,IAAI,CAAG,EAAO,KAAK,IAEjD,EAAY,QAAQ,KACvB,EAAY,QAAQ,GAAe,EACnC,EAAU,KAEZ,CAEE,IACF,MAAMD,EAAAA,gBACJ,EACA,EACA,KAAK,UAAU,EAAa,KAAM,EAAE,CACrC,EACD,EAAA,EAAA,QACE,GAAGC,EAAAA,EAAE,YAAA,EAAA,EAAA,cACH,EACD,CAAC,8BACH,KAOT,EAAA,EAAA,QAAO,GAAGA,EAAAA,EAAE,IAAA,EAAA,EAAA,UAAY,gCAAiCL,EAAAA,WAAW,MAAM,GAAG,EAC7E,EAAA,EAAA,QAAO,gBACI,SAAUA,EAAAA,WAAW,QAAQ,gBAEpC,sEACAA,EAAAA,WAAW,WACZ,oBACY,EAAS,CACvB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_utils_asset.cjs`);let t=require(`node:fs/promises`),n=require(`node:path`),r=require(`@intlayer/config/logger`),i=require(`@intlayer/config/node`);const a=process.cwd(),o=async(e,r)=>await(0,t.writeFile)((0,n.join)(a,e),r,`utf8`),s=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},c=async(t,a)=>{let{configurationFilePath:c}=(0,i.searchConfigurationFile)(a);if(c){(0,r.logger)(`${r.v} ${(0,r.colorizePath)((0,n.relative)(a,c))} already exists`);return}await o(t,e.readAsset(s(t.split(`.`).pop()))),(0,r.logger)(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../_virtual/_utils_asset.cjs`);let t=require(`node:fs/promises`),n=require(`node:path`),r=require(`@intlayer/config/logger`),i=require(`@intlayer/config/node`);const a=process.cwd(),o=async(e,r)=>await(0,t.writeFile)((0,n.join)(a,e),r,`utf8`),s=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},c=async(t,a)=>{let{configurationFilePath:c}=(0,i.searchConfigurationFile)(a);if(c){(0,r.logger)(`${r.v} ${(0,r.colorizePath)((0,n.relative)(a,c))} already exists`);return}await o(t,e.readAsset(s(t.split(`.`).pop()))),(0,r.logger)(`${r.v} Created ${(0,r.colorizePath)(t)}`)};exports.initConfig=c;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["v","readAsset"],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["v","readAsset"],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`${v} Created ${colorizePath(format)}`);\n};\n"],"mappings":"iSAYA,MAAM,EAAU,QAAQ,KAAK,CAGvB,EAAkB,MAAO,EAAkB,IAC/C,MAAA,EAAA,EAAA,YAAA,EAAA,EAAA,MAAqB,EAAS,EAAS,CAAE,EAAS,OAAO,CAIrD,EAAmB,GAAyB,CAChD,OAAQ,EAAR,CACE,IAAK,KACH,MAAO,qBACT,IAAK,MACH,MAAO,sBACT,IAAK,MACH,MAAO,sBACT,IAAK,KACH,MAAO,sBACT,IAAK,OACH,MAAO,uBACT,QACE,MAAO,uBAOA,EAAa,MACxB,EACA,IACG,CAEH,GAAM,CAAE,0BAAA,EAAA,EAAA,yBAAkD,EAAQ,CAGlE,GAAI,EAAuB,EAEzB,EAAA,EAAA,QAAO,GAAGA,EAAAA,EAAE,IAAA,EAAA,EAAA,eAAA,EAAA,EAAA,UADkB,EAAS,EAAsB,CACpB,CAAC,iBAAiB,CAC3D,OASF,MAAM,EAAgB,EAFAC,EAAAA,UADD,EAFH,EAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACF,CAED,EAC5C,EAAA,EAAA,QAAO,GAAGD,EAAAA,EAAE,YAAA,EAAA,EAAA,cAAwB,EAAO,GAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../_virtual/_utils_asset.cjs`);let n=require(`node:path`);n=e.__toESM(n);let r=require(`node:fs`),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../_virtual/_utils_asset.cjs`);let n=require(`node:path`);n=e.__toESM(n);let r=require(`@intlayer/config/logger`),i=require(`node:fs`),a=require(`@intlayer/core/markdown`);const o={Config:`Intlayer configuration documentation`,Content:`Reference for all Intlayer content node types (t, enu, etc.)`,Usage:`How to use Intlayer in your project`,CLI:`Intlayer CLI commands and usage`,Compiler:`Intlayer Compiler setup and usage for automatic content extraction without .content files`,RemoteContent:`How to use Intlayer with Remote/CMS/Server-side content`,NextJS:`Next.js-specific usage (Server & Client components)`,React:`React-specific syntax and hooks usage`,Vue:`Vue-specific composables and syntax`,Svelte:`Svelte-specific stores and syntax`,Angular:`Angular-specific syntax and Injectable Function usage`,Preact:`Preact-specific syntax and hooks usage`,Solid:`Integrates Intlayer internationalization with SolidJS components. Use when the user asks to "setup SolidJS i18n", use the "useIntlayer" hook in Solid, or manage locales in a SolidJS application.`,Astro:`Astro-specific usage and getIntlayer`},s=Object.keys(o),c=e=>{let t=[`Usage`,`Content`,`Config`,`CLI`,`Compiler`];return e.next&&t.push(`NextJS`),(e.react||!e.next)&&t.push(`React`),e.preact&&t.push(`Preact`),e[`solid-js`]&&t.push(`Solid`),(e.vue||e.nuxt)&&t.push(`Vue`),(e.svelte||e[`@sveltejs/kit`])&&t.push(`Svelte`),e.astro&&t.push(`Astro`),t},l={Cursor:{label:`Cursor`,dir:`.cursor/skills`,check:()=>process.env.CURSOR===`true`||process.env.TERM_PROGRAM===`cursor`},Windsurf:{label:`Windsurf`,dir:`.windsurf/skills`,check:()=>process.env.WINDSURF===`true`||process.env.TERM_PROGRAM===`windsurf`},Trae:{label:`Trae`,dir:`.trae/skills`,check:()=>process.env.TRAE===`true`||process.env.TERM_PROGRAM===`trae`},TraeCN:{label:`Trae CN`,dir:`.trae/skills`,check:()=>process.env.TRAE_CN===`true`},VSCode:{label:`VS Code`,dir:`.vscode/skills`,check:()=>process.env.VSCODE===`true`||process.env.TERM_PROGRAM===`vscode`},OpenCode:{label:`OpenCode`,dir:`.opencode/skills`,check:()=>process.env.OPENCODE===`true`},Claude:{label:`Claude Code`,dir:`.claude/skills`,check:()=>process.env.CLAUDE===`true`},GitHub:{label:`GitHub Copilot Workspace`,dir:`.github/skills`,check:()=>process.env.GITHUB_ACTIONS===`true`||!!process.env.GITHUB_WORKSPACE},Antigravity:{label:`Antigravity`,dir:`.agent/skills`},Augment:{label:`Augment`,dir:`.augment/skills`},OpenClaw:{label:`OpenClaw`,dir:`skills`},Cline:{label:`Cline`,dir:`.cline/skills`},CodeBuddy:{label:`CodeBuddy`,dir:`.codebuddy/skills`},CommandCode:{label:`Command Code`,dir:`.commandcode/skills`},Continue:{label:`Continue`,dir:`.continue/skills`},Crush:{label:`Crush`,dir:`.crush/skills`},Droid:{label:`Droid`,dir:`.factory/skills`},Goose:{label:`Goose`,dir:`.goose/skills`},IFlow:{label:`iFlow CLI`,dir:`.iflow/skills`},Junie:{label:`Junie`,dir:`.junie/skills`},KiloCode:{label:`Kilo Code`,dir:`.kilocode/skills`},Kiro:{label:`Kiro CLI`,dir:`.kiro/skills`},Kode:{label:`Kode`,dir:`.kode/skills`},MCPJam:{label:`MCPJam`,dir:`.mcpjam/skills`},MistralVibe:{label:`Mistral Vibe`,dir:`.vibe/skills`},Mux:{label:`Mux`,dir:`.mux/skills`},OpenHands:{label:`OpenHands`,dir:`.openhands/skills`},Pi:{label:`Pi`,dir:`.pi/skills`},Qoder:{label:`Qoder`,dir:`.qoder/skills`},Qwen:{label:`Qwen Code`,dir:`.qwen/skills`},RooCode:{label:`Roo Code`,dir:`.roo/skills`},Zencoder:{label:`Zencoder`,dir:`.zencoder/skills`},Neovate:{label:`Neovate`,dir:`.neovate/skills`},Pochi:{label:`Pochi`,dir:`.pochi/skills`},Other:{label:`Other`,dir:`skills`}},u=Object.keys(l),d={},f=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),p=e=>{let n=`./skills/${d[e]??f(e)}.md`;try{return t.readAsset(n)}catch{return console.warn(`Warning: Could not read asset for skill: ${e} at ${n}`),``}},m=()=>{try{return t.readAsset(`./LICENCE.md`)}catch{return console.warn(`Warning: Could not read LICENCE.md asset`),``}},h=async e=>{let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: ${t.statusText}`);return t.text()},g=async(e,t,o)=>{let s=l[t].dir??`skills`,c=n.default.join(e,s);await i.promises.mkdir(c,{recursive:!0});let u=[],g=m();for(let e of o){let t=`intlayer-${d[e]??f(e)}`,r=p(e);if(!r)continue;let o=Array.from(new Set(r.match(/https:\/\/intlayer\.org\/doc\/[^\s)]+\.md/g)||[])),s=n.default.join(c,t),l=n.default.join(s,`references`);await i.promises.mkdir(l,{recursive:!0}),g&&await i.promises.writeFile(n.default.join(s,`LICENCE.md`),g,`utf-8`);let m=r,_=o.map(async t=>{try{let e=await h(t),n=(0,a.getMarkdownMetadata)(e),r=``;return r=Array.isArray(n.slugs)?n.slugs.filter(e=>e!==`doc`).join(`_`):new URL(t).pathname.split(`/`).filter(e=>e&&e!==`doc`).map(e=>e.replace(`.md`,``)).join(`_`),r=r?`${r}.md`:`index.md`,{url:t,localRefPath:`references/${r}`,fileName:r,content:e,success:!0}}catch(n){return console.warn(`Warning: Failed to download ref ${t} for skill ${e}`,n),{url:t,success:!1}}}),v=await Promise.all(_);for(let e of v)e.success&&e.fileName&&e.content&&e.localRefPath&&(await i.promises.writeFile(n.default.join(l,e.fileName),e.content,`utf-8`),m=m.replaceAll(e.url,e.localRefPath));let y=n.default.join(s,`SKILL.md`);await i.promises.writeFile(y,m,`utf-8`),u.push(`${t}/SKILL.md`)}return u.length===0?`No skill files were created. Check your asset paths.`:`${r.v} Created ${u.length} skills in ${c}`};exports.PLATFORMS=u,exports.PLATFORMS_METADATA=l,exports.SKILLS=s,exports.SKILLS_METADATA=o,exports.getInitialSkills=c,exports.installSkills=g;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["readAsset","path","fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid:\n 'Integrates Intlayer internationalization with SolidJS components. Use when the user asks to \"setup SolidJS i18n\", use the \"useIntlayer\" hook in Solid, or manage locales in a SolidJS application.',\n Astro: 'Astro-specific usage and getIntlayer',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\nexport const getInitialSkills = (\n deps: Record<string, string>\n): (keyof typeof SKILLS_METADATA)[] => {\n const skills: (keyof typeof SKILLS_METADATA)[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n ];\n\n if (deps.next) skills.push('NextJS');\n if (deps.react || !deps.next) skills.push('React');\n if (deps.preact) skills.push('Preact');\n if (deps['solid-js']) skills.push('Solid');\n if (deps.vue || deps.nuxt) skills.push('Vue');\n if (deps.svelte || deps['@sveltejs/kit']) skills.push('Svelte');\n if (deps.astro) skills.push('Astro');\n\n return skills;\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n return response.text();\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform].dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(\n skillContent.match(/https:\\/\\/intlayer\\.org\\/doc\\/[^\\s)]+\\.md/g) || []\n )\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs.filter((slug) => slug !== 'doc').join('_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":"0QAQA,MAAa,EAAkB,CAC7B,OAAQ,uCACR,QAAS,+DACT,MAAO,sCACP,IAAK,kCACL,SACE,4FACF,cAAe,0DACf,OAAQ,sDACR,MAAO,wCACP,IAAK,sCACL,OAAQ,oCACR,QAAS,wDACT,OAAQ,yCACR,MACE,qMACF,MAAO,uCACR,CAIY,EAAS,OAAO,KAAK,EAAgB,CAErC,EACX,GACqC,CACrC,IAAM,EAA2C,CAC/C,QACA,UACA,SACA,MACA,WACD,CAUD,OARI,EAAK,MAAM,EAAO,KAAK,SAAS,EAChC,EAAK,OAAS,CAAC,EAAK,OAAM,EAAO,KAAK,QAAQ,CAC9C,EAAK,QAAQ,EAAO,KAAK,SAAS,CAClC,EAAK,aAAa,EAAO,KAAK,QAAQ,EACtC,EAAK,KAAO,EAAK,OAAM,EAAO,KAAK,MAAM,EACzC,EAAK,QAAU,EAAK,mBAAkB,EAAO,KAAK,SAAS,CAC3D,EAAK,OAA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iB,CAGnD,IAAK,IAAM,KAAO,EACZ,EAAI,SAAW,EAAI,UAAY,EAAI,SAAW,EAAI,eAEpD,MAAMC,EAAAA,SAAG,UACPD,EAAAA,QAAK,KAAK,EAAc,EAAI,SAAS,CACrC,EAAI,QACJ,QACD,CAGD,EAAsB,EAAoB,WACxC,EAAI,IACJ,EAAI,aACL,EAKL,IAAM,EAAWA,EAAAA,QAAK,KAAK,EAAU,WAAW,CAChD,MAAMC,EAAAA,SAAG,UAAU,EAAU,EAAqB,QAAQ,CAC1D,EAAc,KAAK,GAAG,EAAU,WAAW,CAO7C,OAJI,EAAc,SAAW,EACpB,uDAGF,WAAW,EAAc,OAAO,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["readAsset","path","fs","v"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { v } from '@intlayer/config/logger';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid:\n 'Integrates Intlayer internationalization with SolidJS components. Use when the user asks to \"setup SolidJS i18n\", use the \"useIntlayer\" hook in Solid, or manage locales in a SolidJS application.',\n Astro: 'Astro-specific usage and getIntlayer',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\nexport const getInitialSkills = (\n deps: Record<string, string>\n): (keyof typeof SKILLS_METADATA)[] => {\n const skills: (keyof typeof SKILLS_METADATA)[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n ];\n\n if (deps.next) skills.push('NextJS');\n if (deps.react || !deps.next) skills.push('React');\n if (deps.preact) skills.push('Preact');\n if (deps['solid-js']) skills.push('Solid');\n if (deps.vue || deps.nuxt) skills.push('Vue');\n if (deps.svelte || deps['@sveltejs/kit']) skills.push('Svelte');\n if (deps.astro) skills.push('Astro');\n\n return skills;\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n return response.text();\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform].dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(\n skillContent.match(/https:\\/\\/intlayer\\.org\\/doc\\/[^\\s)]+\\.md/g) || []\n )\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs.filter((slug) => slug !== 'doc').join('_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `${v} Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":"+SASA,MAAa,EAAkB,CAC7B,OAAQ,uCACR,QAAS,+DACT,MAAO,sCACP,IAAK,kCACL,SACE,4FACF,cAAe,0DACf,OAAQ,sDACR,MAAO,wCACP,IAAK,sCACL,OAAQ,oCACR,QAAS,wDACT,OAAQ,yCACR,MACE,qMACF,MAAO,uCACR,CAIY,EAAS,OAAO,KAAK,EAAgB,CAErC,EACX,GACqC,CACrC,IAAM,EAA2C,CAC/C,QACA,UACA,SACA,MACA,WACD,CAUD,OARI,EAAK,MAAM,EAAO,KAAK,SAAS,EAChC,EAAK,OAAS,CAAC,EAAK,OAAM,EAAO,KAAK,QAAQ,CAC9C,EAAK,QAAQ,EAAO,KAAK,SAAS,CAClC,EAAK,aAAa,EAAO,KAAK,QAAQ,EACtC,EAAK,KAAO,EAAK,OAAM,EAAO,KAAK,MAAM,EACzC,EAAK,QAAU,EAAK,mBAAkB,EAAO,KAAK,SAAS,CAC3D,EAAK,OAAO,EAAO,KAAK,QAAQ,CAE7B,GAYI,EAAuD,CAClE,OAAQ,CACN,MAAO,SACP,IAAK,iBACL,UACE,QAAQ,IAAI,SAAW,QAAU,QAAQ,IAAI,eAAiB,SACjE,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACL,UACE,QAAQ,IAAI,WAAa,QACzB,QAAQ,IAAI,eAAiB,WAChC,CACD,KAAM,CACJ,MAAO,OACP,IAAK,eACL,UACE,QAAQ,IAAI,OAAS,QAAU,QAAQ,IAAI,eAAiB,OAC/D,CACD,OAAQ,CACN,MAAO,UACP,IAAK,eACL,UAAa,QAAQ,IAAI,UAAY,OACtC,CACD,OAAQ,CACN,MAAO,UACP,IAAK,iBACL,UACE,QAAQ,IAAI,SAAW,QAAU,QAAQ,IAAI,eAAiB,SACjE,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACL,UAAa,QAAQ,IAAI,WAAa,OACvC,CACD,OAAQ,CACN,MAAO,cACP,IAAK,iBACL,UAAa,QAAQ,IAAI,SAAW,OACrC,CACD,OAAQ,CACN,MAAO,2BACP,IAAK,iBACL,UACE,QAAQ,IAAI,iBAAmB,QAAU,CAAC,CAAC,QAAQ,IAAI,iBAC1D,CACD,YAAa,CACX,MAAO,cACP,IAAK,gBACN,CACD,QAAS,CACP,MAAO,UACP,IAAK,kBACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,SACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,UAAW,CACT,MAAO,YACP,IAAK,oBACN,CACD,YAAa,CACX,MAAO,eACP,IAAK,sBACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,kBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,YACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,SAAU,CACR,MAAO,YACP,IAAK,mBACN,CACD,KAAM,CACJ,MAAO,WACP,IAAK,eACN,CACD,KAAM,CACJ,MAAO,OACP,IAAK,eACN,CACD,OAAQ,CACN,MAAO,SACP,IAAK,iBACN,CACD,YAAa,CACX,MAAO,eACP,IAAK,eACN,CACD,IAAK,CACH,MAAO,MACP,IAAK,cACN,CACD,UAAW,CACT,MAAO,YACP,IAAK,oBACN,CACD,GAAI,CACF,MAAO,KACP,IAAK,aACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,KAAM,CACJ,MAAO,YACP,IAAK,eACN,CACD,QAAS,CACP,MAAO,WACP,IAAK,cACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACN,CACD,QAAS,CACP,MAAO,UACP,IAAK,kBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,SACN,CACF,CAIY,EA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`./spawnPosix.cjs`),t=require(`./spawnWin32.cjs`);let n=require(`node:path`);const r=r=>{if(!r||Array.isArray(r)&&r.length===0)throw Error(`Invalid command`);let i=Array.isArray(r)?r.join(` `):r,a=Array.isArray(r),o=a?r[0]:i,s=a?r.slice(1):[],c=(0,n.join)(process.cwd(),`node_modules`,`.bin`),l=Object.keys(process.env).find(e=>e.toLowerCase()===`path`)??`PATH`,u=[c,process.env[l]??``].filter(Boolean).join(n.delimiter),d={...process.env,[l]:u},f=process.platform===`win32`,p=f?t.spawnWin32:e.spawnPosix,m={cwd:process.cwd(),stdio:`inherit`,env:d,shell:f},h=a?s.length===0&&/\s/.test(o)?f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,o],m):p(process.env.SHELL??`/bin/sh`,[`-c`,o],m):p(o,s,m):f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,i],m):p(process.env.SHELL??`/bin/sh`,[`-c`,i],m),g=new Promise((e,t)=>{h.on(`error`,e=>{try{console.error(`[runParallel] Failed to start: ${e?.message??String(e)}`)}catch{}y(),t(e)}),h.on(`exit`,(n,r)=>{y(),n===0||r&&[`SIGINT`,`SIGTERM`,`SIGQUIT`,`SIGHUP`].includes(r)?e():t(Object.assign(Error(`Parallel process failed`),{code:n,signal:r}))})}),_=()=>{try{h.kill(`SIGTERM`)}catch{}},v=[{event:`SIGINT`,handler:_},{event:`SIGTERM`,handler:_},{event:`SIGQUIT`,handler:_},{event:`SIGHUP`,handler:_}];v.forEach(({event:e,handler:t})=>{process.on(e,t)});let y=()=>{v.forEach(({event:e,handler:t})=>{process.off(e,t)})};return{kill:()=>{try{h.kill(`SIGTERM`)}catch{}},result:g,commandText:i}};exports.runParallel=r;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./spawnPosix.cjs`),t=require(`./spawnWin32.cjs`);let n=require(`node:path`);const r=r=>{if(!r||Array.isArray(r)&&r.length===0)throw Error(`Invalid command`);let i=Array.isArray(r)?r.join(` `):r,a=Array.isArray(r),o=a?r[0]:i,s=a?r.slice(1):[],c=(0,n.join)(process.cwd(),`node_modules`,`.bin`),l=Object.keys(process.env).find(e=>e.toLowerCase()===`path`)??`PATH`,u=[c,process.env[l]??``].filter(Boolean).join(n.delimiter),d={...process.env,[l]:u},f=process.platform===`win32`,p=f?t.spawnWin32:e.spawnPosix,m={cwd:process.cwd(),stdio:`inherit`,env:d,shell:f},h=a?s.length===0&&/\s/.test(o)?f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,o],m):p(process.env.SHELL??`/bin/sh`,[`-c`,o],m):p(o,s,m):f?p(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,i],m):p(process.env.SHELL??`/bin/sh`,[`-c`,i],m),g=new Promise((e,t)=>{h.on(`error`,e=>{try{console.error(`[runParallel] Failed to start: ${e?.message??String(e)}`)}catch{}y(),t(e)}),h.on(`exit`,(n,r)=>{y(),n===0||new Set([129,130,131,143]).has(n??-1)||r&&[`SIGINT`,`SIGTERM`,`SIGQUIT`,`SIGHUP`].includes(r)?e():t(Object.assign(Error(`Parallel process failed`),{code:n,signal:r}))})}),_=()=>{try{h.kill(`SIGTERM`)}catch{}},v=[{event:`SIGINT`,handler:_},{event:`SIGTERM`,handler:_},{event:`SIGQUIT`,handler:_},{event:`SIGHUP`,handler:_}];v.forEach(({event:e,handler:t})=>{process.on(e,t)});let y=()=>{v.forEach(({event:e,handler:t})=>{process.off(e,t)})};return{kill:()=>{try{h.kill(`SIGTERM`)}catch{}},result:g,commandText:i}};exports.runParallel=r;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n if (code === 0
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\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AQ,CACzB,GAAI,CACF,QAAQ,MACN,kCAAkC,GAAK,SAAW,OAAO,EAAI,GAC9D,MACK,EACR,GAAiB,CACjB,EAAO,EAAI,EACX,CAEF,EAAM,GAAG,QAAS,EAAM,IAAW,CACjC,GAAiB,CAQf,IAAS,GAFiB,IAAI,IAAI,CAAC,IAAK,IAAK,IAAK,IAAI,CAAC,CAGnC,IAAI,GAAQ,GAAG,EAClC,GAPqB,CAAC,SAAU,UAAW,UAAW,SAAS,CAOrC,SAAS,EAAO,CAE3C,GAAS,CAET,EACE,OAAO,OAAW,MAAM,0BAA0B,CAAE,CAAE,OAAM,SAAQ,CAAC,CACtE,EAEH,EACF,CAEI,MAAgB,CACpB,GAAI,CACF,EAAM,KAAK,UAAU,MACf,IAKJ,EACJ,CACE,CAAE,MAAO,SAAU,QAAS,EAAS,CACrC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,SAAU,QAAS,EAAS,CACtC,CAGH,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,GAAG,EAAc,EAAe,EACxC,CAEF,IAAM,MAAwB,CAC5B,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,IAAI,EAAc,EAAe,EACzC,EAWJ,MAAO,CAAE,SARU,CACjB,GAAI,CACF,EAAM,KAAK,UAAU,MACf,IAKK,SAAQ,cAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{formatLocale as e,formatPath as t}from"./utils/formatter.mjs";import{ANSIColors as n,colorize as r,colorizeKey as i,colorizePath as a,getAppLogger as o,x as s}from"@intlayer/config/logger";import{getContent as
|
|
1
|
+
import{formatLocale as e,formatPath as t}from"./utils/formatter.mjs";import{ANSIColors as n,colorize as r,colorizeKey as i,colorizePath as a,getAppLogger as o,x as s}from"@intlayer/config/logger";import{getBasePlugins as c,getContent as l}from"@intlayer/core/interpreter";const u=(u,d,f)=>{let p=o(d);if(!u)return!1;let m=u.location===`local`||typeof u.filePath==`string`?`Local`:`Remote`,h=!!u.key,g=!!u.content;if(!h)return p(`${m} dictionary has no key`,{level:`error`}),!1;if(!g)return p(`${m} dictionary ${i(u.key)} has no content - ${u.filePath?t(u.filePath):a(`Remote`)}`,{level:`error`}),!1;if(u.schema&&f?.checkSchema&&!(typeof u.content==`function`||typeof u.content==`object`&&u.content!==null&&typeof u.content.then==`function`)){let o=d?.internationalization?.locales??[],f=d?.internationalization.strictMode===`strict`,h=typeof u.schema==`string`?d?.schemas?.[u.schema]:void 0;if(h&&typeof h.safeParse==`function`)for(let d of o){let o=l(u.content,{dictionaryKey:u.key,keyPath:[],locale:d},c(d,!f)),g=h.safeParse(o);if(!g.success)return p(`${m} dictionary ${i(u.key)} has invalid content according to schema ${r(u.schema,n.ORANGE)} for locale ${e(d)} - ${u.filePath?t(u.filePath):a(`Remote`)}`,{level:`error`}),g.error.issues.forEach(t=>{p(`${s} Error: ${i(u.key)} - ${e(d)} - ${r(`${t.path.join(`.`)}:`,n.BLUE)} ${r(t.message,n.GREY)}`,{level:`error`})}),!1}}return!0},d=(e,t,n)=>(e??[])?.filter(e=>u(e,t,n));export{d as filterInvalidDictionaries,u as isInvalidDictionary};
|
|
2
2
|
//# sourceMappingURL=filterInvalidDictionaries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getContent } from '@intlayer/core/interpreter';\nimport type {
|
|
1
|
+
{"version":3,"file":"filterInvalidDictionaries.mjs","names":[],"sources":["../../src/filterInvalidDictionaries.ts"],"sourcesContent":["import {\n ANSIColors,\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getBasePlugins, getContent } from '@intlayer/core/interpreter';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { formatLocale, formatPath } from './utils/formatter';\n\ntype IsInvalidDictionaryOptions = { checkSchema: boolean };\n\nexport const isInvalidDictionary = (\n dictionary: Dictionary | undefined,\n configuration?: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): boolean => {\n const appLogger = getAppLogger(configuration);\n\n if (!dictionary) return false;\n\n const isLocal = Boolean(\n dictionary.location === 'local' || typeof dictionary.filePath === 'string'\n );\n const location = isLocal ? 'Local' : 'Remote';\n const hasKey = Boolean(dictionary.key);\n const hasContent = Boolean(dictionary.content);\n\n if (!hasKey) {\n appLogger(`${location} dictionary has no key`, {\n level: 'error',\n });\n\n return false;\n }\n\n if (!hasContent) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has no content - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n return false;\n }\n\n if (dictionary.schema && options?.checkSchema) {\n const isAsync =\n typeof dictionary.content === 'function' ||\n (typeof dictionary.content === 'object' &&\n dictionary.content !== null &&\n typeof (dictionary.content as any).then === 'function');\n\n if (!isAsync) {\n const locales = configuration?.internationalization?.locales ?? [];\n const isStrict =\n configuration?.internationalization.strictMode === 'strict';\n\n const schema =\n typeof dictionary.schema === 'string'\n ? configuration?.schemas?.[dictionary.schema]\n : undefined;\n\n if (schema && typeof schema.safeParse === 'function') {\n for (const locale of locales) {\n const resolvedContent = getContent(\n dictionary.content,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n locale,\n },\n getBasePlugins(locale, !isStrict)\n );\n const result = (schema as any).safeParse(resolvedContent);\n\n if (!result.success) {\n appLogger(\n `${location} dictionary ${colorizeKey(dictionary.key)} has invalid content according to schema ${colorize(dictionary.schema as string, ANSIColors.ORANGE)} for locale ${formatLocale(locale)} - ${dictionary.filePath ? formatPath(dictionary.filePath) : colorizePath('Remote')}`,\n {\n level: 'error',\n }\n );\n\n result.error.issues.forEach((issue: any) => {\n appLogger(\n `${x} Error: ${colorizeKey(dictionary.key)} - ${formatLocale(locale)} - ${colorize(`${issue.path.join('.')}:`, ANSIColors.BLUE)} ${colorize(issue.message, ANSIColors.GREY)}`,\n {\n level: 'error',\n }\n );\n });\n\n return false;\n }\n }\n }\n }\n }\n\n return true;\n};\n\nexport const filterInvalidDictionaries = (\n dictionaries: (Dictionary | undefined)[] | undefined,\n configuration: IntlayerConfig,\n options?: IsInvalidDictionaryOptions\n): Dictionary[] =>\n (dictionaries ?? [])?.filter((dictionary) =>\n isInvalidDictionary(dictionary, configuration, options)\n ) as Dictionary[];\n"],"mappings":"gRAeA,MAAa,GACX,EACA,EACA,IACY,CACZ,IAAM,EAAY,EAAa,EAAc,CAE7C,GAAI,CAAC,EAAY,MAAO,GAKxB,IAAM,EAFJ,EAAW,WAAa,SAAW,OAAO,EAAW,UAAa,SAEzC,QAAU,SAC/B,EAAS,EAAQ,EAAW,IAC5B,EAAa,EAAQ,EAAW,QAEtC,GAAI,CAAC,EAKH,OAJA,EAAU,GAAG,EAAS,wBAAyB,CAC7C,MAAO,QACR,CAAC,CAEK,GAGT,GAAI,CAAC,EAOH,OANA,EACE,GAAG,EAAS,cAAc,EAAY,EAAW,IAAI,CAAC,oBAAoB,EAAW,SAAW,EAAW,EAAW,SAAS,CAAG,EAAa,SAAS,GACxJ,CACE,MAAO,QACR,CACF,CACM,GAGT,GAAI,EAAW,QAAU,GAAS,aAO5B,EALF,OAAO,EAAW,SAAY,YAC7B,OAAO,EAAW,SAAY,UAC7B,EAAW,UAAY,MACvB,OAAQ,EAAW,QAAgB,MAAS,YAElC,CACZ,IAAM,EAAU,GAAe,sBAAsB,SAAW,EAAE,CAC5D,EACJ,GAAe,qBAAqB,aAAe,SAE/C,EACJ,OAAO,EAAW,QAAW,SACzB,GAAe,UAAU,EAAW,QACpC,IAAA,GAEN,GAAI,GAAU,OAAO,EAAO,WAAc,WACxC,IAAK,IAAM,KAAU,EAAS,CAC5B,IAAM,EAAkB,EACtB,EAAW,QACX,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,SACD,CACD,EAAe,EAAQ,CAAC,EAAS,CAClC,CACK,EAAU,EAAe,UAAU,EAAgB,CAEzD,GAAI,CAAC,EAAO,QAiBV,OAhBA,EACE,GAAG,EAAS,cAAc,EAAY,EAAW,IAAI,CAAC,2CAA2C,EAAS,EAAW,OAAkB,EAAW,OAAO,CAAC,cAAc,EAAa,EAAO,CAAC,KAAK,EAAW,SAAW,EAAW,EAAW,SAAS,CAAG,EAAa,SAAS,GAChR,CACE,MAAO,QACR,CACF,CAED,EAAO,MAAM,OAAO,QAAS,GAAe,CAC1C,EACE,GAAG,EAAE,UAAU,EAAY,EAAW,IAAI,CAAC,KAAK,EAAa,EAAO,CAAC,KAAK,EAAS,GAAG,EAAM,KAAK,KAAK,IAAI,CAAC,GAAI,EAAW,KAAK,CAAC,GAAG,EAAS,EAAM,QAAS,EAAW,KAAK,GAC3K,CACE,MAAO,QACR,CACF,EACD,CAEK,IAOjB,MAAO,IAGI,GACX,EACA,EACA,KAEC,GAAgB,EAAE,GAAG,OAAQ,GAC5B,EAAoB,EAAY,EAAe,EAAQ,CACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n ensureDirectory,\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // 2. CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // 3. CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT FOR NEXT.JS >= 16\n if (isNextJsProject) {\n const nextVersion =\n packageJson.dependencies?.next || packageJson.devDependencies?.next;\n\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n if (!match) return false;\n const majorVersion = parseInt(match[1], 10);\n return majorVersion >= major;\n };\n\n if (nextVersion && isVersionGreaterOrEqual(nextVersion, 16)) {\n const devScript = packageJson.scripts?.dev;\n const expectedScript = \"intlayer watch --with 'bun run --bun next dev'\";\n\n if (\n devScript &&\n devScript !== expectedScript &&\n devScript.includes('next dev')\n ) {\n packageJson.scripts.dev = expectedScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script for Next.js >= 16`\n );\n }\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":"gnBA2BA,MAAM,EAAsB,CAC1B,OAAQ,iDACR,UAAW,oDACX,UAAW,oDACX,IAAK,2DACL,MAAO,gDACP,aAAc,yDACd,2BACE,yEACF,oCACE,mFACF,WAAY,uDACZ,aAAc,yDACd,cAAe,0DACf,cAAe,0DACf,eAAgB,mDAChB,WAAY,uDACZ,QAAS,kDACT,UAAW,oDACX,mBACE,gEACF,KAAM,yDACN,QAAS,kDACT,OAAQ,iDACR,QAAS,kDACT,QAAS,uCAG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D,EAAY,QAAQ,KACvB,EAAY,QAAQ,GAAe,EACnC,EAAU,KAEZ,CAEE,IACF,MAAM,EACJ,EACA,EACA,KAAK,UAAU,EAAa,KAAM,EAAE,CACrC,CACD,EACE,GAAG,EAAE,WAAW,EACd,EACD,CAAC,8BACH,IAOT,EAAO,GAAG,EAAE,GAAG,EAAS,gCAAiC,EAAW,MAAM,GAAG,CAC7E,EAAO,CACL,EAAS,SAAU,EAAW,QAAQ,CACtC,EACE,sEACA,EAAW,WACZ,CACD,EAAa,EAAS,CACvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n logger,\n v,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n ensureDirectory,\n exists,\n findTsConfigFiles,\n parseJSONWithComments,\n readFileFromRoot,\n updateNextConfig,\n updateViteConfig,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (await exists(rootDir, gitignorePath)) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n await initConfig(format, rootDir);\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('vite-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('next-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT FOR NEXT.JS >= 16\n if (isNextJsProject) {\n const nextVersion =\n packageJson.dependencies?.next || packageJson.devDependencies?.next;\n\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n\n if (!match) return false;\n const majorVersion = parseInt(match[1], 10);\n return majorVersion >= major;\n };\n\n if (nextVersion && isVersionGreaterOrEqual(nextVersion, 16)) {\n const devScript = packageJson.scripts?.dev;\n const expectedScript = \"intlayer watch --with 'bun run --bun next dev'\";\n\n if (\n devScript &&\n devScript !== expectedScript &&\n devScript.includes('next dev')\n ) {\n packageJson.scripts.dev = expectedScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script for Next.js >= 16`\n );\n }\n }\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((f) => f === 'tsconfig.json') || tsConfigFiles[0];\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n};\n"],"mappings":"gnBA2BA,MAAM,EAAsB,CAC1B,OAAQ,iDACR,UAAW,oDACX,UAAW,oDACX,IAAK,2DACL,MAAO,gDACP,aAAc,yDACd,2BACE,yEACF,oCACE,mFACF,WAAY,uDACZ,aAAc,yDACd,cAAe,0DACf,cAAe,0DACf,eAAgB,mDAChB,WAAY,uDACZ,QAAS,kDACT,UAAW,oDACX,mBACE,gEACF,KAAM,yDACN,QAAS,kDACT,OAAQ,iDACR,QAAS,kDACT,QAAS,uCAGT,SAAU,uDACV,aAAc,2DACd,UAAW,wDACX,YAAa,0DACb,QAAS,sDACV,CAKK,EAAuB,GAA6B,CACxD,IAAM,EAAO,CACX,GAAG,EAAY,aACf,GAAG,EAAY,gBAChB,CAMK,GAAa,EAAuB,IACpC,CAAC,GAAiB,OAAO,GAAkB,SAAiB,GAC9C,OAAO,WAAW,EAAM,WAAW,CACxC,KAAK,EAAc,CAIlC,GAAI,EAAK,mBAAqB,EAAK,iBACjC,OAAO,EAAoB,KAE7B,GAAI,EAAK,iBAAmB,EAAK,KAC/B,OAAO,EAAoB,mBAI7B,GAAI,EAAK,KAAM,CACb,IAAM,EAAU,EAAK,KAUrB,OARI,EAAU,EAAS,GAAG,CACj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ises";import{join as n,relative as r}from"node:path";import{colorizePath as i,logger as a,v as o}from"@intlayer/config/logger";import{searchConfigurationFile as s}from"@intlayer/config/node";const c=process.cwd(),l=async(e,r)=>await t(n(c,e),r,`utf8`),u=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},d=async(t,n)=>{let{configurationFilePath:c}=s(n);if(c){a(`${o} ${i(r(n,c))} already exists`);return}await l(t,e(u(t.split(`.`).pop()))),a(
|
|
1
|
+
import{readAsset as e}from"../_virtual/_utils_asset.mjs";import{writeFile as t}from"node:fs/promises";import{join as n,relative as r}from"node:path";import{colorizePath as i,logger as a,v as o}from"@intlayer/config/logger";import{searchConfigurationFile as s}from"@intlayer/config/node";const c=process.cwd(),l=async(e,r)=>await t(n(c,e),r,`utf8`),u=e=>{switch(e){case`ts`:return`./templates/ts.txt`;case`cjs`:return`./templates/cjs.txt`;case`mjs`:return`./templates/mjs.txt`;case`js`:return`./templates/mjs.txt`;case`json`:return`./templates/json.txt`;default:return`./templates/ts.txt`}},d=async(t,n)=>{let{configurationFilePath:c}=s(n);if(c){a(`${o} ${i(r(n,c))} already exists`);return}await l(t,e(u(t.split(`.`).pop()))),a(`${o} Created ${i(t)}`)};export{d as initConfig};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/initConfig/index.ts"],"sourcesContent":["import { writeFile } from 'node:fs/promises';\nimport { join, relative } from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { colorizePath, logger, v } from '@intlayer/config/logger';\nimport {\n type configurationFilesCandidates,\n searchConfigurationFile,\n} from '@intlayer/config/node';\n\n/**\n * UTILITIES\n */\nconst rootDir = process.cwd();\n\n// Helper to write a file\nconst writeFileToRoot = async (filePath: string, content: string) =>\n await writeFile(join(rootDir, filePath), content, 'utf8');\n\ntype ConfigFormat = 'ts' | 'cjs' | 'mjs' | 'js' | 'json';\n\nconst getTemplatePath = (format: ConfigFormat) => {\n switch (format) {\n case 'ts':\n return './templates/ts.txt';\n case 'cjs':\n return './templates/cjs.txt';\n case 'mjs':\n return './templates/mjs.txt';\n case 'js':\n return './templates/mjs.txt';\n case 'json':\n return './templates/json.txt';\n default:\n return './templates/ts.txt';\n }\n};\n\n/**\n * Initialize the Intlayer configuration file\n */\nexport const initConfig = async (\n format: (typeof configurationFilesCandidates)[number],\n baseDir: string\n) => {\n // Search for configuration file\n const { configurationFilePath } = searchConfigurationFile(baseDir);\n\n // return if the configuration file is found\n if (configurationFilePath) {\n const relativePath = relative(baseDir, configurationFilePath);\n logger(`${v} ${colorizePath(relativePath)} already exists`);\n return;\n }\n\n // Extract the format from the filename (e.g. 'intlayer.config.ts' -> 'ts')\n const extension = format.split('.').pop() as ConfigFormat;\n\n const templatePath = getTemplatePath(extension);\n const configContent = readAsset(templatePath);\n\n await writeFileToRoot(format, configContent);\n logger(`${v} Created ${colorizePath(format)}`);\n};\n"],"mappings":"+RAYA,MAAM,EAAU,QAAQ,KAAK,CAGvB,EAAkB,MAAO,EAAkB,IAC/C,MAAM,EAAU,EAAK,EAAS,EAAS,CAAE,EAAS,OAAO,CAIrD,EAAmB,GAAyB,CAChD,OAAQ,EAAR,CACE,IAAK,KACH,MAAO,qBACT,IAAK,MACH,MAAO,sBACT,IAAK,MACH,MAAO,sBACT,IAAK,KACH,MAAO,sBACT,IAAK,OACH,MAAO,uBACT,QACE,MAAO,uBAOA,EAAa,MACxB,EACA,IACG,CAEH,GAAM,CAAE,yBAA0B,EAAwB,EAAQ,CAGlE,GAAI,EAAuB,CAEzB,EAAO,GAAG,EAAE,GAAG,EADM,EAAS,EAAS,EAAsB,CACpB,CAAC,iBAAiB,CAC3D,OASF,MAAM,EAAgB,EAFA,EADD,EAFH,EAAO,MAAM,IAAI,CAAC,KAAK,CAEM,CACF,CAED,CAC5C,EAAO,GAAG,EAAE,WAAW,EAAa,EAAO,GAAG"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readAsset as e}from"../_virtual/_utils_asset.mjs";import t from"node:path";import{
|
|
1
|
+
import{readAsset as e}from"../_virtual/_utils_asset.mjs";import t from"node:path";import{v as n}from"@intlayer/config/logger";import{promises as r}from"node:fs";import{getMarkdownMetadata as i}from"@intlayer/core/markdown";const a={Config:`Intlayer configuration documentation`,Content:`Reference for all Intlayer content node types (t, enu, etc.)`,Usage:`How to use Intlayer in your project`,CLI:`Intlayer CLI commands and usage`,Compiler:`Intlayer Compiler setup and usage for automatic content extraction without .content files`,RemoteContent:`How to use Intlayer with Remote/CMS/Server-side content`,NextJS:`Next.js-specific usage (Server & Client components)`,React:`React-specific syntax and hooks usage`,Vue:`Vue-specific composables and syntax`,Svelte:`Svelte-specific stores and syntax`,Angular:`Angular-specific syntax and Injectable Function usage`,Preact:`Preact-specific syntax and hooks usage`,Solid:`Integrates Intlayer internationalization with SolidJS components. Use when the user asks to "setup SolidJS i18n", use the "useIntlayer" hook in Solid, or manage locales in a SolidJS application.`,Astro:`Astro-specific usage and getIntlayer`},o=Object.keys(a),s=e=>{let t=[`Usage`,`Content`,`Config`,`CLI`,`Compiler`];return e.next&&t.push(`NextJS`),(e.react||!e.next)&&t.push(`React`),e.preact&&t.push(`Preact`),e[`solid-js`]&&t.push(`Solid`),(e.vue||e.nuxt)&&t.push(`Vue`),(e.svelte||e[`@sveltejs/kit`])&&t.push(`Svelte`),e.astro&&t.push(`Astro`),t},c={Cursor:{label:`Cursor`,dir:`.cursor/skills`,check:()=>process.env.CURSOR===`true`||process.env.TERM_PROGRAM===`cursor`},Windsurf:{label:`Windsurf`,dir:`.windsurf/skills`,check:()=>process.env.WINDSURF===`true`||process.env.TERM_PROGRAM===`windsurf`},Trae:{label:`Trae`,dir:`.trae/skills`,check:()=>process.env.TRAE===`true`||process.env.TERM_PROGRAM===`trae`},TraeCN:{label:`Trae CN`,dir:`.trae/skills`,check:()=>process.env.TRAE_CN===`true`},VSCode:{label:`VS Code`,dir:`.vscode/skills`,check:()=>process.env.VSCODE===`true`||process.env.TERM_PROGRAM===`vscode`},OpenCode:{label:`OpenCode`,dir:`.opencode/skills`,check:()=>process.env.OPENCODE===`true`},Claude:{label:`Claude Code`,dir:`.claude/skills`,check:()=>process.env.CLAUDE===`true`},GitHub:{label:`GitHub Copilot Workspace`,dir:`.github/skills`,check:()=>process.env.GITHUB_ACTIONS===`true`||!!process.env.GITHUB_WORKSPACE},Antigravity:{label:`Antigravity`,dir:`.agent/skills`},Augment:{label:`Augment`,dir:`.augment/skills`},OpenClaw:{label:`OpenClaw`,dir:`skills`},Cline:{label:`Cline`,dir:`.cline/skills`},CodeBuddy:{label:`CodeBuddy`,dir:`.codebuddy/skills`},CommandCode:{label:`Command Code`,dir:`.commandcode/skills`},Continue:{label:`Continue`,dir:`.continue/skills`},Crush:{label:`Crush`,dir:`.crush/skills`},Droid:{label:`Droid`,dir:`.factory/skills`},Goose:{label:`Goose`,dir:`.goose/skills`},IFlow:{label:`iFlow CLI`,dir:`.iflow/skills`},Junie:{label:`Junie`,dir:`.junie/skills`},KiloCode:{label:`Kilo Code`,dir:`.kilocode/skills`},Kiro:{label:`Kiro CLI`,dir:`.kiro/skills`},Kode:{label:`Kode`,dir:`.kode/skills`},MCPJam:{label:`MCPJam`,dir:`.mcpjam/skills`},MistralVibe:{label:`Mistral Vibe`,dir:`.vibe/skills`},Mux:{label:`Mux`,dir:`.mux/skills`},OpenHands:{label:`OpenHands`,dir:`.openhands/skills`},Pi:{label:`Pi`,dir:`.pi/skills`},Qoder:{label:`Qoder`,dir:`.qoder/skills`},Qwen:{label:`Qwen Code`,dir:`.qwen/skills`},RooCode:{label:`Roo Code`,dir:`.roo/skills`},Zencoder:{label:`Zencoder`,dir:`.zencoder/skills`},Neovate:{label:`Neovate`,dir:`.neovate/skills`},Pochi:{label:`Pochi`,dir:`.pochi/skills`},Other:{label:`Other`,dir:`skills`}},l=Object.keys(c),u={},d=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),f=t=>{let n=`./skills/${u[t]??d(t)}.md`;try{return e(n)}catch{return console.warn(`Warning: Could not read asset for skill: ${t} at ${n}`),``}},p=()=>{try{return e(`./LICENCE.md`)}catch{return console.warn(`Warning: Could not read LICENCE.md asset`),``}},m=async e=>{let t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: ${t.statusText}`);return t.text()},h=async(e,a,o)=>{let s=c[a].dir??`skills`,l=t.join(e,s);await r.mkdir(l,{recursive:!0});let h=[],g=p();for(let e of o){let n=`intlayer-${u[e]??d(e)}`,a=f(e);if(!a)continue;let o=Array.from(new Set(a.match(/https:\/\/intlayer\.org\/doc\/[^\s)]+\.md/g)||[])),s=t.join(l,n),c=t.join(s,`references`);await r.mkdir(c,{recursive:!0}),g&&await r.writeFile(t.join(s,`LICENCE.md`),g,`utf-8`);let p=a,_=o.map(async t=>{try{let e=await m(t),n=i(e),r=``;return r=Array.isArray(n.slugs)?n.slugs.filter(e=>e!==`doc`).join(`_`):new URL(t).pathname.split(`/`).filter(e=>e&&e!==`doc`).map(e=>e.replace(`.md`,``)).join(`_`),r=r?`${r}.md`:`index.md`,{url:t,localRefPath:`references/${r}`,fileName:r,content:e,success:!0}}catch(n){return console.warn(`Warning: Failed to download ref ${t} for skill ${e}`,n),{url:t,success:!1}}}),v=await Promise.all(_);for(let e of v)e.success&&e.fileName&&e.content&&e.localRefPath&&(await r.writeFile(t.join(c,e.fileName),e.content,`utf-8`),p=p.replaceAll(e.url,e.localRefPath));let y=t.join(s,`SKILL.md`);await r.writeFile(y,p,`utf-8`),h.push(`${n}/SKILL.md`)}return h.length===0?`No skill files were created. Check your asset paths.`:`${n} Created ${h.length} skills in ${l}`};export{l as PLATFORMS,c as PLATFORMS_METADATA,o as SKILLS,a as SKILLS_METADATA,s as getInitialSkills,h as installSkills};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid:\n 'Integrates Intlayer internationalization with SolidJS components. Use when the user asks to \"setup SolidJS i18n\", use the \"useIntlayer\" hook in Solid, or manage locales in a SolidJS application.',\n Astro: 'Astro-specific usage and getIntlayer',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\nexport const getInitialSkills = (\n deps: Record<string, string>\n): (keyof typeof SKILLS_METADATA)[] => {\n const skills: (keyof typeof SKILLS_METADATA)[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n ];\n\n if (deps.next) skills.push('NextJS');\n if (deps.react || !deps.next) skills.push('React');\n if (deps.preact) skills.push('Preact');\n if (deps['solid-js']) skills.push('Solid');\n if (deps.vue || deps.nuxt) skills.push('Vue');\n if (deps.svelte || deps['@sveltejs/kit']) skills.push('Svelte');\n if (deps.astro) skills.push('Astro');\n\n return skills;\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n return response.text();\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform].dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(\n skillContent.match(/https:\\/\\/intlayer\\.org\\/doc\\/[^\\s)]+\\.md/g) || []\n )\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs.filter((slug) => slug !== 'doc').join('_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":"mLAQA,MAAa,EAAkB,CAC7B,OAAQ,uCACR,QAAS,+DACT,MAAO,sCACP,IAAK,kCACL,SACE,4FACF,cAAe,0DACf,OAAQ,sDACR,MAAO,wCACP,IAAK,sCACL,OAAQ,oCACR,QAAS,wDACT,OAAQ,yCACR,MACE,qMACF,MAAO,uCACR,CAIY,EAAS,OAAO,KAAK,EAAgB,CAErC,EACX,GACqC,CACrC,IAAM,EAA2C,CAC/C,QACA,UACA,SACA,MACA,WACD,CAUD,OARI,EAAK,MAAM,EAAO,KAAK,SAAS,EAChC,EAAK,OAAS,CAAC,EAAK,OAAM,EAAO,KAAK,QAAQ,CAC9C,EAAK,QAAQ,EAAO,KAAK,SAAS,CAClC,EAAK,aAAa,EAAO,KAAK,QAAQ,EACtC,EAAK,KAAO,EAAK,OAAM,EAAO,KAAK,MAAM,EACzC,EAAK,QAAU,EAAK,mBAAkB,EAAO,KAAK,SAAS,CAC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AAI,eAEpD,MAAMA,EAAG,UACP,EAAK,KAAK,EAAc,EAAI,SAAS,CACrC,EAAI,QACJ,QACD,CAGD,EAAsB,EAAoB,WACxC,EAAI,IACJ,EAAI,aACL,EAKL,IAAM,EAAW,EAAK,KAAK,EAAU,WAAW,CAChD,MAAMA,EAAG,UAAU,EAAU,EAAqB,QAAQ,CAC1D,EAAc,KAAK,GAAG,EAAU,WAAW,CAO7C,OAJI,EAAc,SAAW,EACpB,uDAGF,WAAW,EAAc,OAAO,aAAa"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { v } from '@intlayer/config/logger';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid:\n 'Integrates Intlayer internationalization with SolidJS components. Use when the user asks to \"setup SolidJS i18n\", use the \"useIntlayer\" hook in Solid, or manage locales in a SolidJS application.',\n Astro: 'Astro-specific usage and getIntlayer',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\nexport const getInitialSkills = (\n deps: Record<string, string>\n): (keyof typeof SKILLS_METADATA)[] => {\n const skills: (keyof typeof SKILLS_METADATA)[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n ];\n\n if (deps.next) skills.push('NextJS');\n if (deps.react || !deps.next) skills.push('React');\n if (deps.preact) skills.push('Preact');\n if (deps['solid-js']) skills.push('Solid');\n if (deps.vue || deps.nuxt) skills.push('Vue');\n if (deps.svelte || deps['@sveltejs/kit']) skills.push('Svelte');\n if (deps.astro) skills.push('Astro');\n\n return skills;\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n return response.text();\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform].dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(\n skillContent.match(/https:\\/\\/intlayer\\.org\\/doc\\/[^\\s)]+\\.md/g) || []\n )\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs.filter((slug) => slug !== 'doc').join('_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `${v} Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":"+NASA,MAAa,EAAkB,CAC7B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BACL,UACE,QAAQ,IAAI,iBAAmB,QAAU,CAAC,CAAC,QAAQ,IAAI,iBAC1D,CACD,YAAa,CACX,MAAO,cACP,IAAK,gBACN,CACD,QAAS,CACP,MAAO,UACP,IAAK,kBACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,SACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,UAAW,CACT,MAAO,YACP,IAAK,oBACN,CACD,YAAa,CACX,MAAO,eACP,IAAK,sBACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,kBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,YACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,SAAU,CACR,MAAO,YACP,IAAK,mBACN,CACD,KAAM,CACJ,MAAO,WACP,IAAK,eACN,CACD,KAAM,CACJ,MAAO,OACP,IAAK,eACN,CACD,OAAQ,CACN,MAAO,SACP,IAAK,iBACN,CACD,YAAa,CACX,MAAO,eACP,IAAK,eACN,CACD,IAAK,CACH,MAAO,MACP,IAAK,cACN,CACD,UAAW,CACT,MAAO,YACP,IAAK,oBACN,CACD,GAAI,CACF,MAAO,KACP,IAAK,aACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,KAAM,CACJ,MAAO,YACP,IAAK,eACN,CACD,QAAS,CACP,MAAO,WACP,IAAK,cACN,CACD,SAAU,CACR,MAAO,WACP,IAAK,mBACN,CACD,QAAS,CACP,MAAO,UACP,IAAK,kBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,gBACN,CACD,MAAO,CACL,MAAO,QACP,IAAK,SACN,CACF,CAIY,EAAY,OAAO,KAAK,EAAmB,CAKlD,EAAqD,EAAE,CAKvD,EAAoB,GACxB,EAAI,QAAQ,qBAAsB,QAAQ,CAAC,aAAa,CAKpD,EA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,MAAM,QAAQ,EAAS,MAAM,CACpB,EAAS,MAAM,OAAQ,GAAS,IAAS,MAAM,CAAC,KAAK,IAAI,CAEpD,IAAI,IAAI,EAAI,CAAC,SAE1B,MAAM,IAAI,CACV,OAAQ,GAAS,GAAQ,IAAS,MAAM,CACxC,IAAK,GAAS,EAAK,QAAQ,MAAO,GAAG,CAAC,CACtC,KAAK,IAAI,CAId,EAAW,EAAW,GAAG,EAAS,KAAO,WAGlC,CACL,MACA,aAJmB,cAAc,IAKjC,WACA,UACA,QAAS,GACV,OACM,EAAO,CAKd,OAJA,QAAQ,KACN,mCAAmC,EAAI,aAAa,IACpD,EACD,CACM,CAAE,MAAK,QAAS,GAAO,GAEhC,CAEI,EAAU,MAAM,QAAQ,IAAI,EAAiB,CAGnD,IAAK,IAAM,KAAO,EACZ,EAAI,SAAW,EAAI,UAAY,EAAI,SAAW,EAAI,eAEpD,MAAMA,EAAG,UACP,EAAK,KAAK,EAAc,EAAI,SAAS,CACrC,EAAI,QACJ,QACD,CAGD,EAAsB,EAAoB,WACxC,EAAI,IACJ,EAAI,aACL,EAKL,IAAM,EAAW,EAAK,KAAK,EAAU,WAAW,CAChD,MAAMA,EAAG,UAAU,EAAU,EAAqB,QAAQ,CAC1D,EAAc,KAAK,GAAG,EAAU,WAAW,CAO7C,OAJI,EAAc,SAAW,EACpB,uDAGF,GAAG,EAAE,WAAW,EAAc,OAAO,aAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{spawnPosix as e}from"./spawnPosix.mjs";import{spawnWin32 as t}from"./spawnWin32.mjs";import{delimiter as n,join as r}from"node:path";const i=i=>{if(!i||Array.isArray(i)&&i.length===0)throw Error(`Invalid command`);let a=Array.isArray(i)?i.join(` `):i,o=Array.isArray(i),s=o?i[0]:a,c=o?i.slice(1):[],l=r(process.cwd(),`node_modules`,`.bin`),u=Object.keys(process.env).find(e=>e.toLowerCase()===`path`)??`PATH`,d=[l,process.env[u]??``].filter(Boolean).join(n),f={...process.env,[u]:d},p=process.platform===`win32`,m=p?t:e,h={cwd:process.cwd(),stdio:`inherit`,env:f,shell:p},g=o?c.length===0&&/\s/.test(s)?p?m(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,s],h):m(process.env.SHELL??`/bin/sh`,[`-c`,s],h):m(s,c,h):p?m(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,a],h):m(process.env.SHELL??`/bin/sh`,[`-c`,a],h),_=new Promise((e,t)=>{g.on(`error`,e=>{try{console.error(`[runParallel] Failed to start: ${e?.message??String(e)}`)}catch{}b(),t(e)}),g.on(`exit`,(n,r)=>{b(),n===0||r&&[`SIGINT`,`SIGTERM`,`SIGQUIT`,`SIGHUP`].includes(r)?e():t(Object.assign(Error(`Parallel process failed`),{code:n,signal:r}))})}),v=()=>{try{g.kill(`SIGTERM`)}catch{}},y=[{event:`SIGINT`,handler:v},{event:`SIGTERM`,handler:v},{event:`SIGQUIT`,handler:v},{event:`SIGHUP`,handler:v}];y.forEach(({event:e,handler:t})=>{process.on(e,t)});let b=()=>{y.forEach(({event:e,handler:t})=>{process.off(e,t)})};return{kill:()=>{try{g.kill(`SIGTERM`)}catch{}},result:_,commandText:a}};export{i as runParallel};
|
|
1
|
+
import{spawnPosix as e}from"./spawnPosix.mjs";import{spawnWin32 as t}from"./spawnWin32.mjs";import{delimiter as n,join as r}from"node:path";const i=i=>{if(!i||Array.isArray(i)&&i.length===0)throw Error(`Invalid command`);let a=Array.isArray(i)?i.join(` `):i,o=Array.isArray(i),s=o?i[0]:a,c=o?i.slice(1):[],l=r(process.cwd(),`node_modules`,`.bin`),u=Object.keys(process.env).find(e=>e.toLowerCase()===`path`)??`PATH`,d=[l,process.env[u]??``].filter(Boolean).join(n),f={...process.env,[u]:d},p=process.platform===`win32`,m=p?t:e,h={cwd:process.cwd(),stdio:`inherit`,env:f,shell:p},g=o?c.length===0&&/\s/.test(s)?p?m(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,s],h):m(process.env.SHELL??`/bin/sh`,[`-c`,s],h):m(s,c,h):p?m(process.env.ComSpec??`cmd.exe`,[`/d`,`/s`,`/c`,a],h):m(process.env.SHELL??`/bin/sh`,[`-c`,a],h),_=new Promise((e,t)=>{g.on(`error`,e=>{try{console.error(`[runParallel] Failed to start: ${e?.message??String(e)}`)}catch{}b(),t(e)}),g.on(`exit`,(n,r)=>{b(),n===0||new Set([129,130,131,143]).has(n??-1)||r&&[`SIGINT`,`SIGTERM`,`SIGQUIT`,`SIGHUP`].includes(r)?e():t(Object.assign(Error(`Parallel process failed`),{code:n,signal:r}))})}),v=()=>{try{g.kill(`SIGTERM`)}catch{}},y=[{event:`SIGINT`,handler:v},{event:`SIGTERM`,handler:v},{event:`SIGQUIT`,handler:v},{event:`SIGHUP`,handler:v}];y.forEach(({event:e,handler:t})=>{process.on(e,t)});let b=()=>{y.forEach(({event:e,handler:t})=>{process.off(e,t)})};return{kill:()=>{try{g.kill(`SIGTERM`)}catch{}},result:_,commandText:a}};export{i as runParallel};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n if (code === 0
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n cleanupHandlers();\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n cleanupHandlers();\n\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const cleanup = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const signalHandlers: { event: string; handler: (...args: any[]) => void }[] =\n [\n { event: 'SIGINT', handler: cleanup },\n { event: 'SIGTERM', handler: cleanup },\n { event: 'SIGQUIT', handler: cleanup },\n { event: 'SIGHUP', handler: cleanup },\n ];\n\n // Register signal handlers\n signalHandlers.forEach(({ event, handler }) => {\n process.on(event as any, handler as any);\n });\n\n const cleanupHandlers = () => {\n signalHandlers.forEach(({ event, handler }) => {\n process.off(event as any, handler as any);\n });\n };\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":"4IAcA,MAAa,EAAe,GAA6C,CACvE,GAAI,CAAC,GAAS,MAAM,QAAQ,EAAK,EAAI,EAAK,SAAW,EACnD,MAAU,MAAM,kBAAkB,CAEpC,IAAM,EAAc,MAAM,QAAQ,EAAK,CAAG,EAAK,KAAK,IAAI,CAAG,EAErD,EAAU,MAAM,QAAQ,EAAK,CAC7B,EAAU,EAAW,EAAkB,GAAK,EAC5C,EAAO,EAAW,EAAkB,MAAM,EAAE,CAAG,EAAE,CAGjD,EAAS,EAAK,QAAQ,KAAK,CAAE,eAAgB,OAAO,CACpD,EACJ,OAAO,KAAK,QAA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,IAKJ,EACJ,CACE,CAAE,MAAO,SAAU,QAAS,EAAS,CACrC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,UAAW,QAAS,EAAS,CACtC,CAAE,MAAO,SAAU,QAAS,EAAS,CACtC,CAGH,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,GAAG,EAAc,EAAe,EACxC,CAEF,IAAM,MAAwB,CAC5B,EAAe,SAAS,CAAE,QAAO,aAAc,CAC7C,QAAQ,IAAI,EAAc,EAAe,EACzC,EAWJ,MAAO,CAAE,SARU,CACjB,GAAI,CACF,EAAM,KAAK,UAAU,MACf,IAKK,SAAQ,cAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/installSkills/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/installSkills/index.ts"],"mappings":";;AASA;;cAAa,eAAA;EAAA;;;;;;;;;;;;;;;KAmBD,KAAA,gBAAqB,eAAA;AAAA,cAEpB,MAAA,EAAyC,KAAA;AAAA,cAEzC,gBAAA,GACX,IAAA,EAAM,MAAA,mCACS,eAAA;AAAA,UAoBA,gBAAA;EACf,KAAA;EACA,GAAA;EACA,KAAA;AAAA;;;;cAMW,kBAAA,EAAoB,MAAA,SAAe,gBAAA;AAAA,KA6JpC,QAAA,gBAAwB,kBAAA;AAAA,cAEvB,SAAA,EAA+C,QAAA;;;;;cAyD/C,aAAA,GACX,WAAA,UACA,QAAA,EAAU,QAAA,EACV,MAAA,EAAQ,KAAA,OACP,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"@babel/parser": "7.29.0",
|
|
105
|
-
"@intlayer/api": "8.3.
|
|
106
|
-
"@intlayer/config": "8.3.
|
|
107
|
-
"@intlayer/core": "8.3.
|
|
108
|
-
"@intlayer/dictionaries-entry": "8.3.
|
|
109
|
-
"@intlayer/remote-dictionaries-entry": "8.3.
|
|
110
|
-
"@intlayer/types": "8.3.
|
|
111
|
-
"@intlayer/unmerged-dictionaries-entry": "8.3.
|
|
105
|
+
"@intlayer/api": "8.3.4",
|
|
106
|
+
"@intlayer/config": "8.3.4",
|
|
107
|
+
"@intlayer/core": "8.3.4",
|
|
108
|
+
"@intlayer/dictionaries-entry": "8.3.4",
|
|
109
|
+
"@intlayer/remote-dictionaries-entry": "8.3.4",
|
|
110
|
+
"@intlayer/types": "8.3.4",
|
|
111
|
+
"@intlayer/unmerged-dictionaries-entry": "8.3.4",
|
|
112
112
|
"chokidar": "3.6.0",
|
|
113
113
|
"defu": "6.1.4",
|
|
114
114
|
"fast-glob": "3.3.3",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@utils/ts-config-types": "1.0.4",
|
|
123
123
|
"@utils/tsdown-config": "1.0.4",
|
|
124
124
|
"rimraf": "6.1.3",
|
|
125
|
-
"tsdown": "0.21.
|
|
125
|
+
"tsdown": "0.21.4",
|
|
126
126
|
"typescript": "5.9.3",
|
|
127
127
|
"vitest": "4.1.0",
|
|
128
128
|
"zod": "4.3.6"
|