@intlayer/chokidar 8.3.0 → 8.3.2
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 +97 -0
- package/dist/assets/initConfig/templates/json.txt +26 -1
- package/dist/assets/initConfig/templates/mjs.txt +97 -0
- package/dist/assets/initConfig/templates/ts.txt +97 -0
- package/dist/cjs/init/index.cjs +1 -1
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/logConfigDetails.cjs +1 -1
- package/dist/cjs/logConfigDetails.cjs.map +1 -1
- package/dist/cjs/utils/buildComponentFilesList.cjs +2 -0
- package/dist/cjs/utils/buildComponentFilesList.cjs.map +1 -0
- package/dist/cjs/utils/buildFilesList.cjs +1 -1
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -1
- package/dist/esm/init/index.mjs +1 -1
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/logConfigDetails.mjs +1 -1
- package/dist/esm/logConfigDetails.mjs.map +1 -1
- package/dist/esm/utils/buildComponentFilesList.mjs +2 -0
- package/dist/esm/utils/buildComponentFilesList.mjs.map +1 -0
- package/dist/esm/utils/buildFilesList.mjs +1 -1
- package/dist/esm/utils/buildFilesList.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/types/formatDictionary.d.ts +3 -3
- package/dist/types/utils/buildComponentFilesList.d.ts +26 -0
- package/dist/types/utils/buildComponentFilesList.d.ts.map +1 -0
- package/dist/types/utils/buildFilesList.d.ts +35 -20
- package/dist/types/utils/buildFilesList.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +2 -3
- package/package.json +10 -10
- package/dist/cjs/utils/getComponentTransformPattern.cjs +0 -2
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +0 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +0 -2
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +0 -1
- package/dist/types/intlayer/dist/types/index.d.ts +0 -3
- package/dist/types/utils/getComponentTransformPattern.d.ts +0 -8
- package/dist/types/utils/getComponentTransformPattern.d.ts.map +0 -1
|
@@ -1,11 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intlayer configuration file documentation
|
|
3
|
+
* @see https://intlayer.org/doc/concept/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
const { Locales } = require('intlayer');
|
|
2
7
|
|
|
3
8
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
4
9
|
const config = {
|
|
5
10
|
internationalization: {
|
|
6
11
|
locales: [Locales.ENGLISH],
|
|
12
|
+
/**
|
|
13
|
+
* Default locale used as a fallback if the requested locale is not found.
|
|
14
|
+
*/
|
|
7
15
|
defaultLocale: Locales.ENGLISH,
|
|
8
16
|
},
|
|
17
|
+
routing: {
|
|
18
|
+
/**
|
|
19
|
+
* Locale routing strategy.
|
|
20
|
+
* - "prefix-no-default": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
|
|
21
|
+
* - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
|
|
22
|
+
* - "no-prefix": No locale in the URL.
|
|
23
|
+
* - "search-params": Use ?locale=...
|
|
24
|
+
* Default: "prefix-no-default"
|
|
25
|
+
*/
|
|
26
|
+
mode: 'prefix-no-default',
|
|
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
|
+
editor: {
|
|
45
|
+
/**
|
|
46
|
+
* Whether the visual editor is enabled.
|
|
47
|
+
*/
|
|
48
|
+
enabled: false,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* URL of your application for origin validation.
|
|
52
|
+
*/
|
|
53
|
+
applicationURL: 'http://localhost:3000',
|
|
54
|
+
},
|
|
55
|
+
dictionary: {
|
|
56
|
+
/**
|
|
57
|
+
* Controls how dictionaries are imported.
|
|
58
|
+
* - "static": Statically imported at build time.
|
|
59
|
+
* - "dynamic": Dynamically imported using Suspense.
|
|
60
|
+
* - "fetch": Fetched dynamically via the live sync API.
|
|
61
|
+
*/
|
|
62
|
+
importMode: 'static',
|
|
63
|
+
},
|
|
64
|
+
ai: {
|
|
65
|
+
/**
|
|
66
|
+
* AI provider to use.
|
|
67
|
+
* Options: 'openai', 'anthropic', 'mistral', 'deepseek', 'gemini', 'ollama', 'openrouter', 'alibaba', 'fireworks', 'groq', 'huggingface', 'bedrock', 'googlevertex', 'togetherai'
|
|
68
|
+
*/
|
|
69
|
+
provider: 'openai',
|
|
70
|
+
model: 'gpt-5-mini',
|
|
71
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
72
|
+
applicationContext: [''].join('\n'),
|
|
73
|
+
},
|
|
74
|
+
compiler: {
|
|
75
|
+
/**
|
|
76
|
+
* Defines the output files path. Replaces `outputDir`.
|
|
77
|
+
*
|
|
78
|
+
* - `./` paths are resolved relative to the component directory.
|
|
79
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
80
|
+
*
|
|
81
|
+
* - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
|
|
82
|
+
*
|
|
83
|
+
* Example:
|
|
84
|
+
* ```ts
|
|
85
|
+
* {
|
|
86
|
+
* // Create Multilingual .content.ts files close to the component
|
|
87
|
+
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* {
|
|
93
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
94
|
+
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Indicates if the components should be saved after being transformed.
|
|
102
|
+
* That way, the compiler can be run only once to transform the app, and then it can be removed.
|
|
103
|
+
*/
|
|
104
|
+
saveComponents: false,
|
|
105
|
+
},
|
|
9
106
|
};
|
|
10
107
|
|
|
11
108
|
module.exports = config;
|
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
"internationalization": {
|
|
3
3
|
"locales": ["en"],
|
|
4
4
|
"defaultLocale": "en"
|
|
5
|
-
}
|
|
5
|
+
},
|
|
6
|
+
"routing": {
|
|
7
|
+
"mode": "prefix-no-default"
|
|
8
|
+
},
|
|
9
|
+
"content": {
|
|
10
|
+
"fileExtensions": [".content.ts"],
|
|
11
|
+
"contentDir": ["./src"],
|
|
12
|
+
"codeDir": ["./src"],
|
|
13
|
+
},
|
|
14
|
+
"editor": {
|
|
15
|
+
"enabled": false,
|
|
16
|
+
"applicationURL": 'http://localhost:3000',
|
|
17
|
+
},
|
|
18
|
+
"dictionary": {
|
|
19
|
+
"importMode": "static",
|
|
20
|
+
},
|
|
21
|
+
"ai": {
|
|
22
|
+
"provider": 'openai',
|
|
23
|
+
"model": 'gpt-5-mini',
|
|
24
|
+
"apiKey": process.env.OPENAI_API_KEY,
|
|
25
|
+
"applicationContext": ',
|
|
26
|
+
},
|
|
27
|
+
"compiler": {
|
|
28
|
+
"output": './{{fileName}}.content.ts',
|
|
29
|
+
"saveComponents": false,
|
|
30
|
+
},
|
|
6
31
|
}
|
|
7
32
|
|
|
@@ -1,11 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intlayer configuration file documentation
|
|
3
|
+
* @see https://intlayer.org/doc/concept/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { Locales } from 'intlayer';
|
|
2
7
|
|
|
3
8
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
4
9
|
const config = {
|
|
5
10
|
internationalization: {
|
|
6
11
|
locales: [Locales.ENGLISH],
|
|
12
|
+
/**
|
|
13
|
+
* Default locale used as a fallback if the requested locale is not found.
|
|
14
|
+
*/
|
|
7
15
|
defaultLocale: Locales.ENGLISH,
|
|
8
16
|
},
|
|
17
|
+
routing: {
|
|
18
|
+
/**
|
|
19
|
+
* Locale routing strategy.
|
|
20
|
+
* - "prefix-no-default": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
|
|
21
|
+
* - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
|
|
22
|
+
* - "no-prefix": No locale in the URL.
|
|
23
|
+
* - "search-params": Use ?locale=...
|
|
24
|
+
* Default: "prefix-no-default"
|
|
25
|
+
*/
|
|
26
|
+
mode: 'prefix-no-default',
|
|
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
|
+
editor: {
|
|
45
|
+
/**
|
|
46
|
+
* Whether the visual editor is enabled.
|
|
47
|
+
*/
|
|
48
|
+
enabled: false,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* URL of your application for origin validation.
|
|
52
|
+
*/
|
|
53
|
+
applicationURL: 'http://localhost:3000',
|
|
54
|
+
},
|
|
55
|
+
dictionary: {
|
|
56
|
+
/**
|
|
57
|
+
* Controls how dictionaries are imported.
|
|
58
|
+
* - "static": Statically imported at build time.
|
|
59
|
+
* - "dynamic": Dynamically imported using Suspense.
|
|
60
|
+
* - "fetch": Fetched dynamically via the live sync API.
|
|
61
|
+
*/
|
|
62
|
+
importMode: 'static',
|
|
63
|
+
},
|
|
64
|
+
ai: {
|
|
65
|
+
/**
|
|
66
|
+
* AI provider to use.
|
|
67
|
+
* Options: 'openai', 'anthropic', 'mistral', 'deepseek', 'gemini', 'ollama', 'openrouter', 'alibaba', 'fireworks', 'groq', 'huggingface', 'bedrock', 'googlevertex', 'togetherai'
|
|
68
|
+
*/
|
|
69
|
+
provider: 'openai',
|
|
70
|
+
model: 'gpt-5-mini',
|
|
71
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
72
|
+
applicationContext: [''].join('\n'),
|
|
73
|
+
},
|
|
74
|
+
compiler: {
|
|
75
|
+
/**
|
|
76
|
+
* Defines the output files path. Replaces `outputDir`.
|
|
77
|
+
*
|
|
78
|
+
* - `./` paths are resolved relative to the component directory.
|
|
79
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
80
|
+
*
|
|
81
|
+
* - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
|
|
82
|
+
*
|
|
83
|
+
* Example:
|
|
84
|
+
* ```ts
|
|
85
|
+
* {
|
|
86
|
+
* // Create Multilingual .content.ts files close to the component
|
|
87
|
+
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* {
|
|
93
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
94
|
+
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Indicates if the components should be saved after being transformed.
|
|
102
|
+
* That way, the compiler can be run only once to transform the app, and then it can be removed.
|
|
103
|
+
*/
|
|
104
|
+
saveComponents: false,
|
|
105
|
+
},
|
|
9
106
|
};
|
|
10
107
|
|
|
11
108
|
export default config;
|
|
@@ -1,10 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intlayer configuration file documentation
|
|
3
|
+
* @see https://intlayer.org/doc/concept/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import { type IntlayerConfig, Locales } from 'intlayer';
|
|
2
7
|
|
|
3
8
|
const config: IntlayerConfig = {
|
|
4
9
|
internationalization: {
|
|
5
10
|
locales: [Locales.ENGLISH],
|
|
11
|
+
/**
|
|
12
|
+
* Default locale used as a fallback if the requested locale is not found.
|
|
13
|
+
*/
|
|
6
14
|
defaultLocale: Locales.ENGLISH,
|
|
7
15
|
},
|
|
16
|
+
routing: {
|
|
17
|
+
/**
|
|
18
|
+
* Locale routing strategy.
|
|
19
|
+
* - "prefix-no-default": Prefix all except the default locale (e.g., /dashboard, /fr/dashboard).
|
|
20
|
+
* - "prefix-all": Prefix all locales (e.g., /en/dashboard, /fr/dashboard).
|
|
21
|
+
* - "no-prefix": No locale in the URL.
|
|
22
|
+
* - "search-params": Use ?locale=...
|
|
23
|
+
* Default: "prefix-no-default"
|
|
24
|
+
*/
|
|
25
|
+
mode: 'prefix-no-default',
|
|
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
|
+
editor: {
|
|
44
|
+
/**
|
|
45
|
+
* Whether the visual editor is enabled.
|
|
46
|
+
*/
|
|
47
|
+
enabled: false,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* URL of your application for origin validation.
|
|
51
|
+
*/
|
|
52
|
+
applicationURL: 'http://localhost:3000',
|
|
53
|
+
},
|
|
54
|
+
build: {
|
|
55
|
+
/**
|
|
56
|
+
* Controls how dictionaries are imported.
|
|
57
|
+
* - "static": Statically imported at build time.
|
|
58
|
+
* - "dynamic": Dynamically imported using Suspense.
|
|
59
|
+
* - "fetch": Fetched dynamically via the live sync API.
|
|
60
|
+
*/
|
|
61
|
+
importMode: 'static',
|
|
62
|
+
},
|
|
63
|
+
ai: {
|
|
64
|
+
/**
|
|
65
|
+
* AI provider to use.
|
|
66
|
+
* Options: 'openai', 'anthropic', 'mistral', 'deepseek', 'gemini', 'ollama', 'openrouter', 'alibaba', 'fireworks', 'groq', 'huggingface', 'bedrock', 'googlevertex', 'togetherai'
|
|
67
|
+
*/
|
|
68
|
+
provider: 'openai',
|
|
69
|
+
model: 'gpt-5-mini',
|
|
70
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
71
|
+
applicationContext: [''].join('\n'),
|
|
72
|
+
},
|
|
73
|
+
compiler: {
|
|
74
|
+
/**
|
|
75
|
+
* Defines the output files path. Replaces `outputDir`.
|
|
76
|
+
*
|
|
77
|
+
* - `./` paths are resolved relative to the component directory.
|
|
78
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
79
|
+
*
|
|
80
|
+
* - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
|
|
81
|
+
*
|
|
82
|
+
* Example:
|
|
83
|
+
* ```ts
|
|
84
|
+
* {
|
|
85
|
+
* // Create Multilingual .content.ts files close to the component
|
|
86
|
+
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* {
|
|
92
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
93
|
+
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
output: ({ fileName }) => `./${fileName}.content.ts`,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Indicates if the components should be saved after being transformed.
|
|
101
|
+
* That way, the compiler can be run only once to transform the app, and then it can be removed.
|
|
102
|
+
*/
|
|
103
|
+
saveComponents: false,
|
|
104
|
+
},
|
|
8
105
|
};
|
|
9
106
|
|
|
10
107
|
export default config;
|
package/dist/cjs/init/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../initConfig/index.cjs`),t=require(`./utils/configManipulation.cjs`),n=require(`./utils/fileSystem.cjs`),r=require(`./utils/jsonParser.cjs`),i=require(`./utils/tsConfig.cjs`);let a=require(`node:path`),o=require(`@intlayer/config/logger`),s=require(`@intlayer/config/node`),c=require(`@intlayer/config/utils`);const l={NextJS:`https://intlayer.org/doc/environment/nextjs.md`,NextJS_15:`https://intlayer.org/doc/environment/nextjs/15.md`,NextJS_14:`https://intlayer.org/doc/environment/nextjs/14.md`,CRA:`https://intlayer.org/doc/environment/create-react-app.md`,Astro:`https://intlayer.org/doc/environment/astro.md`,ViteAndReact:`https://intlayer.org/doc/environment/vite-and-react.md`,ViteAndReact_ReactRouterV7:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md`,ViteAndReact_ReactRouterV7_FSRoutes:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md`,ViteAndVue:`https://intlayer.org/doc/environment/vite-and-vue.md`,ViteAndSolid:`https://intlayer.org/doc/environment/vite-and-solid.md`,ViteAndSvelte:`https://intlayer.org/doc/environment/vite-and-svelte.md`,ViteAndPreact:`https://intlayer.org/doc/environment/vite-and-preact.md`,TanStackRouter:`https://intlayer.org/doc/environment/tanstack.md`,NuxtAndVue:`https://intlayer.org/doc/environment/nuxt-and-vue.md`,Angular:`https://intlayer.org/doc/environment/angular.md`,SvelteKit:`https://intlayer.org/doc/environment/sveltekit.md`,ReactNativeAndExpo:`https://intlayer.org/doc/environment/react-native-and-expo.md`,Lynx:`https://intlayer.org/doc/environment/lynx-and-react.md`,Express:`https://intlayer.org/doc/environment/express.md`,NestJS:`https://intlayer.org/doc/environment/nestjs.md`,Fastify:`https://intlayer.org/doc/environment/fastify.md`,Default:`https://intlayer.org/doc/get-started`,NextIntl:`https://intlayer.org/blog/intlayer-with-next-intl.md`,ReactI18Next:`https://intlayer.org/blog/intlayer-with-react-i18next.md`,ReactIntl:`https://intlayer.org/blog/intlayer-with-react-intl.md`,NextI18Next:`https://intlayer.org/blog/intlayer-with-next-i18next.md`,VueI18n:`https://intlayer.org/blog/intlayer-with-vue-i18n.md`},u=e=>{let t={...e.dependencies,...e.devDependencies},n=(e,t)=>!e||typeof e!=`string`?!1:RegExp(`^[\\^~]?${t}(?:\\.|$)`).test(e);if(t[`@lynx-js/react`]||t[`@lynx-js/core`])return l.Lynx;if(t[`react-native`]||t.expo)return l.ReactNativeAndExpo;if(t.next){let e=t.next;return n(e,14)?l.NextJS_14:n(e,15)?l.NextJS_15:l.NextJS}if(t.nuxt)return l.NuxtAndVue;if(t.astro)return l.Astro;if(t[`@sveltejs/kit`])return l.SvelteKit;if(t[`@tanstack/react-router`])return l.TanStackRouter;let r=t[`react-router`];if(r&&typeof r==`string`){if(t[`@react-router/fs-routes`])return l.ViteAndReact_ReactRouterV7_FSRoutes;if(n(r,7))return l.ViteAndReact_ReactRouterV7}return t.vite?t.vue?l.ViteAndVue:t[`solid-js`]?l.ViteAndSolid:t.svelte?l.ViteAndSvelte:t.preact?l.ViteAndPreact:l.ViteAndReact:t[`react-scripts`]?l.CRA:t[`@angular/core`]?l.Angular:t[`@nestjs/core`]?l.NestJS:t.express?l.Express:t.fastify?l.Fastify:t[`next-intl`]?l.NextIntl:t[`react-i18next`]||t.i18next?l.ReactI18Next:t[`react-intl`]?l.ReactIntl:t[`next-i18next`]?l.NextI18Next:t[`vue-i18n`]?l.VueI18n:l.Default},d=async l=>{(0,o.logger)((0,o.colorize)(`Checking Intlayer configuration...`,o.ANSIColors.CYAN));let d=`package.json`;await n.exists(l,d)||((0,o.logger)(`${o.x} No ${(0,o.colorizePath)(`package.json`)} found. Please run this script from the project root.`,{level:`error`}),process.exit(1));let f=await n.readFileFromRoot(l,d),p;try{p=JSON.parse(f)}catch{(0,o.logger)(`${o.x} Could not parse ${(0,o.colorizePath)(`package.json`)}.`,{level:`error`}),process.exit(1)}let m=u(p),h=`.gitignore`;if(await n.exists(l,h)){let e=await n.readFileFromRoot(l,h);e.includes(`intlayer`)?(0,o.logger)(`${o.v} ${(0,o.colorizePath)(h)} already includes .intlayer`):(await n.writeFileToRoot(l,h,`${e}\n# Intlayer\n.intlayer\n`),(0,o.logger)(`${o.v} Added ${(0,o.colorizePath)(`.intlayer`)} to ${(0,o.colorizePath)(h)}`))}let g=`.vscode`,_=(0,a.join)(g,`extensions.json`),v=`intlayer.intlayer-vs-code-extension`;try{let e={recommendations:[]};await n.exists(l,_)?e=r.parseJSONWithComments(await n.readFileFromRoot(l,_)):await n.ensureDirectory(l,g),e.recommendations||=[],e.recommendations.includes(v)?(0,o.logger)(`${o.v} ${(0,o.colorizePath)(_)} already includes ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)}`):(e.recommendations.push(v),await n.writeFileToRoot(l,_,JSON.stringify(e,null,2)),(0,o.logger)(`${o.v} Added ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)} to ${(0,o.colorizePath)(_)}`))}catch{(0,o.logger)(`${o.x} Could not update ${(0,o.colorizePath)(_)}. You may need to add ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)} manually.`,{level:`warn`})}let y=await i.findTsConfigFiles(l),b=!1;for(let e of y)if(await n.exists(l,e)){b=!0;try{let t=r.parseJSONWithComments(await n.readFileFromRoot(l,e)),i=`.intlayer/**/*.ts`,a=!1;t.include&&(Array.isArray(t.include)&&!t.include.some(e=>e.includes(`.intlayer`))?(t.include.push(i),a=!0):t.include.includes(i)&&(0,o.logger)(`${o.v} ${(0,o.colorizePath)(e)} already includes intlayer types`)),a&&(await n.writeFileToRoot(l,e,JSON.stringify(t,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(e)} to include intlayer types`))}catch{(0,o.logger)(`${o.x} Could not parse or update ${(0,o.colorizePath)(e)}. You may need to add ${(0,o.colorizePath)(`.intlayer/types/**/*.ts`)} manually.`,{level:`warn`})}}await e.initConfig(b?`intlayer.config.ts`:`intlayer.config.mjs`,l);let x=!1;for(let e of[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`])if(await n.exists(l,e)){x=!0;let r=await n.readFileFromRoot(l,e);r.includes(`vite-intlayer`)||(await n.writeFileToRoot(l,e,t.updateViteConfig(r,e.split(`.`).pop())),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(e)} to include Intlayer plugin`));break}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../initConfig/index.cjs`),t=require(`./utils/configManipulation.cjs`),n=require(`./utils/fileSystem.cjs`),r=require(`./utils/jsonParser.cjs`),i=require(`./utils/tsConfig.cjs`);let a=require(`node:path`),o=require(`@intlayer/config/logger`),s=require(`@intlayer/config/node`),c=require(`@intlayer/config/utils`);const l={NextJS:`https://intlayer.org/doc/environment/nextjs.md`,NextJS_15:`https://intlayer.org/doc/environment/nextjs/15.md`,NextJS_14:`https://intlayer.org/doc/environment/nextjs/14.md`,CRA:`https://intlayer.org/doc/environment/create-react-app.md`,Astro:`https://intlayer.org/doc/environment/astro.md`,ViteAndReact:`https://intlayer.org/doc/environment/vite-and-react.md`,ViteAndReact_ReactRouterV7:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md`,ViteAndReact_ReactRouterV7_FSRoutes:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md`,ViteAndVue:`https://intlayer.org/doc/environment/vite-and-vue.md`,ViteAndSolid:`https://intlayer.org/doc/environment/vite-and-solid.md`,ViteAndSvelte:`https://intlayer.org/doc/environment/vite-and-svelte.md`,ViteAndPreact:`https://intlayer.org/doc/environment/vite-and-preact.md`,TanStackRouter:`https://intlayer.org/doc/environment/tanstack.md`,NuxtAndVue:`https://intlayer.org/doc/environment/nuxt-and-vue.md`,Angular:`https://intlayer.org/doc/environment/angular.md`,SvelteKit:`https://intlayer.org/doc/environment/sveltekit.md`,ReactNativeAndExpo:`https://intlayer.org/doc/environment/react-native-and-expo.md`,Lynx:`https://intlayer.org/doc/environment/lynx-and-react.md`,Express:`https://intlayer.org/doc/environment/express.md`,NestJS:`https://intlayer.org/doc/environment/nestjs.md`,Fastify:`https://intlayer.org/doc/environment/fastify.md`,Default:`https://intlayer.org/doc/get-started`,NextIntl:`https://intlayer.org/blog/intlayer-with-next-intl.md`,ReactI18Next:`https://intlayer.org/blog/intlayer-with-react-i18next.md`,ReactIntl:`https://intlayer.org/blog/intlayer-with-react-intl.md`,NextI18Next:`https://intlayer.org/blog/intlayer-with-next-i18next.md`,VueI18n:`https://intlayer.org/blog/intlayer-with-vue-i18n.md`},u=e=>{let t={...e.dependencies,...e.devDependencies},n=(e,t)=>!e||typeof e!=`string`?!1:RegExp(`^[\\^~]?${t}(?:\\.|$)`).test(e);if(t[`@lynx-js/react`]||t[`@lynx-js/core`])return l.Lynx;if(t[`react-native`]||t.expo)return l.ReactNativeAndExpo;if(t.next){let e=t.next;return n(e,14)?l.NextJS_14:n(e,15)?l.NextJS_15:l.NextJS}if(t.nuxt)return l.NuxtAndVue;if(t.astro)return l.Astro;if(t[`@sveltejs/kit`])return l.SvelteKit;if(t[`@tanstack/react-router`])return l.TanStackRouter;let r=t[`react-router`];if(r&&typeof r==`string`){if(t[`@react-router/fs-routes`])return l.ViteAndReact_ReactRouterV7_FSRoutes;if(n(r,7))return l.ViteAndReact_ReactRouterV7}return t.vite?t.vue?l.ViteAndVue:t[`solid-js`]?l.ViteAndSolid:t.svelte?l.ViteAndSvelte:t.preact?l.ViteAndPreact:l.ViteAndReact:t[`react-scripts`]?l.CRA:t[`@angular/core`]?l.Angular:t[`@nestjs/core`]?l.NestJS:t.express?l.Express:t.fastify?l.Fastify:t[`next-intl`]?l.NextIntl:t[`react-i18next`]||t.i18next?l.ReactI18Next:t[`react-intl`]?l.ReactIntl:t[`next-i18next`]?l.NextI18Next:t[`vue-i18n`]?l.VueI18n:l.Default},d=async l=>{(0,o.logger)((0,o.colorize)(`Checking Intlayer configuration...`,o.ANSIColors.CYAN));let d=`package.json`;await n.exists(l,d)||((0,o.logger)(`${o.x} No ${(0,o.colorizePath)(`package.json`)} found. Please run this script from the project root.`,{level:`error`}),process.exit(1));let f=await n.readFileFromRoot(l,d),p;try{p=JSON.parse(f)}catch{(0,o.logger)(`${o.x} Could not parse ${(0,o.colorizePath)(`package.json`)}.`,{level:`error`}),process.exit(1)}let m=u(p),h=`.gitignore`;if(await n.exists(l,h)){let e=await n.readFileFromRoot(l,h);e.includes(`intlayer`)?(0,o.logger)(`${o.v} ${(0,o.colorizePath)(h)} already includes .intlayer`):(await n.writeFileToRoot(l,h,`${e}\n# Intlayer\n.intlayer\n`),(0,o.logger)(`${o.v} Added ${(0,o.colorizePath)(`.intlayer`)} to ${(0,o.colorizePath)(h)}`))}let g=`.vscode`,_=(0,a.join)(g,`extensions.json`),v=`intlayer.intlayer-vs-code-extension`;try{let e={recommendations:[]};await n.exists(l,_)?e=r.parseJSONWithComments(await n.readFileFromRoot(l,_)):await n.ensureDirectory(l,g),e.recommendations||=[],e.recommendations.includes(v)?(0,o.logger)(`${o.v} ${(0,o.colorizePath)(_)} already includes ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)}`):(e.recommendations.push(v),await n.writeFileToRoot(l,_,JSON.stringify(e,null,2)),(0,o.logger)(`${o.v} Added ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)} to ${(0,o.colorizePath)(_)}`))}catch{(0,o.logger)(`${o.x} Could not update ${(0,o.colorizePath)(_)}. You may need to add ${(0,o.colorize)(v,o.ANSIColors.MAGENTA)} manually.`,{level:`warn`})}let y=await i.findTsConfigFiles(l),b=!1;for(let e of y)if(await n.exists(l,e)){b=!0;try{let t=r.parseJSONWithComments(await n.readFileFromRoot(l,e)),i=`.intlayer/**/*.ts`,a=!1;t.include&&(Array.isArray(t.include)&&!t.include.some(e=>e.includes(`.intlayer`))?(t.include.push(i),a=!0):t.include.includes(i)&&(0,o.logger)(`${o.v} ${(0,o.colorizePath)(e)} already includes intlayer types`)),a&&(await n.writeFileToRoot(l,e,JSON.stringify(t,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(e)} to include intlayer types`))}catch{(0,o.logger)(`${o.x} Could not parse or update ${(0,o.colorizePath)(e)}. You may need to add ${(0,o.colorizePath)(`.intlayer/types/**/*.ts`)} manually.`,{level:`warn`})}}await e.initConfig(b?`intlayer.config.ts`:`intlayer.config.mjs`,l);let x=!1;for(let e of[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`])if(await n.exists(l,e)){x=!0;let r=await n.readFileFromRoot(l,e);r.includes(`vite-intlayer`)||(await n.writeFileToRoot(l,e,t.updateViteConfig(r,e.split(`.`).pop())),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(e)} to include Intlayer plugin`));break}let S=[`next.config.js`,`next.config.mjs`,`next.config.ts`],C=!1;for(let e of S)if(await n.exists(l,e)){C=!0,x=!0;let r=await n.readFileFromRoot(l,e);r.includes(`next-intlayer`)||(await n.writeFileToRoot(l,e,t.updateNextConfig(r,e.split(`.`).pop())),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(e)} to include Intlayer plugin`));break}if(C){let e=p.dependencies?.next||p.devDependencies?.next;if(e&&((e,t)=>{if(!e||typeof e!=`string`)return!1;let n=e.match(/^[^\d]*(\d+)/);return n?parseInt(n[1],10)>=t:!1})(e,16)){let e=p.scripts?.dev,t=`intlayer watch --with 'bun run --bun next dev'`;e&&e!==t&&e.includes(`next dev`)&&(p.scripts.dev=t,await n.writeFileToRoot(l,d,JSON.stringify(p,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(`package.json`)} dev script for Next.js >= 16`))}}for(let e of[`webpack.config.js`,`webpack.config.ts`,`webpack.config.mjs`,`webpack.config.cjs`])if(await n.exists(l,e)){x=!0,(0,o.logger)(`${o.v} Found ${(0,o.colorizePath)(e)}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`);break}if(!x){let e=(0,c.getAlias)({configuration:(0,s.getConfiguration)({baseDir:l})});if(b&&y.length>0){let t=y.find(e=>e===`tsconfig.json`)||y[0],i=r.parseJSONWithComments(await n.readFileFromRoot(l,t));i.compilerOptions??={},i.compilerOptions.paths??={};let a=!1;Object.entries(e).forEach(([e,t])=>{i.compilerOptions.paths[e]||(i.compilerOptions.paths[e]=[t],a=!0)}),a&&(await n.writeFileToRoot(l,t,JSON.stringify(i,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(t)} to include Intlayer aliases`))}else{let t=`jsconfig.json`;if(await n.exists(l,t)){let i=r.parseJSONWithComments(await n.readFileFromRoot(l,t));i.compilerOptions??={},i.compilerOptions.paths??={};let a=!1;Object.entries(e).forEach(([e,t])=>{i.compilerOptions.paths[e]||(i.compilerOptions.paths[e]=[t],a=!0)}),a&&(await n.writeFileToRoot(l,t,JSON.stringify(i,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(t)} to include Intlayer aliases`))}else{p.imports??={};let t=!1;Object.entries(e).forEach(([e,n])=>{let r=e.replace(`@`,`#`),i=n.startsWith(`.`)?n:`./${n}`;p.imports[r]||(p.imports[r]=i,t=!0)}),t&&(await n.writeFileToRoot(l,d,JSON.stringify(p,null,2)),(0,o.logger)(`${o.v} Updated ${(0,o.colorizePath)(d)} to include Intlayer imports`))}}}(0,o.logger)(`${o.v} ${(0,o.colorize)(`Intlayer init setup complete.`,o.ANSIColors.GREEN)}`),(0,o.logger)([(0,o.colorize)(`Next →`,o.ANSIColors.MAGENTA),(0,o.colorize)(`Follow the instructions in the documentation to complete the setup:`,o.ANSIColors.GREY_LIGHT),(0,o.colorizePath)(m)])};exports.initIntlayer=d;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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 for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\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 // 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,EA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OAAO,EAAS,EAAa,CAAE,CAEvC,IAAM,EAASK,EAAAA,sBADS,MAAMH,EAAAA,iBAAiB,EAAS,EAAa,CAChB,CAErD,EAAO,kBAAoB,EAAE,CAC7B,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 // 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,GAAG,CACjB,EAAoB,UAGzB,EAAU,EAAS,GAAG,CACjB,EAAoB,UAGtB,EAAoB,OAG7B,GAAI,EAAK,KAAM,OAAO,EAAoB,WAC1C,GAAI,EAAK,MAAO,OAAO,EAAoB,MAC3C,GAAI,EAAK,iBAAkB,OAAO,EAAoB,UAGtD,GAAI,EAAK,0BACP,OAAO,EAAoB,eAI7B,IAAM,EAAqB,EAAK,gBAChC,GAAI,GAAsB,OAAO,GAAuB,SAAU,CAEhE,GAAI,EAAK,2BACP,OAAO,EAAoB,oCAI7B,GAAI,EAAU,EAAoB,EAA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EE,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,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./_virtual/_rolldown/runtime.cjs`);const e=require(`./utils/formatter.cjs`),t=require(`./utils/runOnce.cjs`);let n=require(`node:path`),r=require(`@intlayer/config/logger`),i=require(`@intlayer/config/node`),a=require(`@intlayer/config/env`);const o=o=>{let{configuration:s,customConfiguration:c,numCustomConfiguration:l,configurationFilePath:u}=(0,i.getConfigurationAndFilePath)(o),d=(0,r.getAppLogger)(s);t.runOnce((0,n.join)(s.system.baseDir,`.intlayer`,`cache`,`intlayer-config-locaded.lock`),()=>{if(l===0)d(`Configuration file not found, using default configuration.`,{isVerbose:!0});else{let t=s.system.baseDir,r=(0,n.relative)(t,u);if(l===1){let t=(0,a.getEnvFilePath)(o?.env,o?.envFile);d(`Configuration loaded ${e.formatPath(r)}${t?` - Env: ${e.formatPath(t)}`:``}`,{isVerbose:!0})}else d(`Multiple configuration files found, using ${e.formatPath(r)}.`,{isVerbose:!0})}if(c){let e=i.intlayerConfigSchema.safeParse(c);e.success||d(`${r.x} Invalid configuration:\n${e.error.issues.map(e=>`${(0,r.colorizePath)(` - ${e.path.join(`.`)}:`)} ${(0,r.colorize)(e.message,r.ANSIColors.GREY_DARK)}`).join(`
|
|
2
|
-
`)}`),c.
|
|
2
|
+
`)}`),c.build?.importMode&&d(`${(0,r.colorize)(`build.importMode`,r.ANSIColors.BLUE)} is deprecated, use ${(0,r.colorize)(`dictionary.importMode`,r.ANSIColors.BLUE)} instead`),c.compiler?.transformPattern&&d(`${(0,r.colorize)(`compiler.transformPattern`,r.ANSIColors.BLUE)} is deprecated, use ${(0,r.colorize)(`build.traversePattern`,r.ANSIColors.BLUE)} instead`),c.compiler?.excludePattern&&d(`${(0,r.colorize)(`compiler.excludePattern`,r.ANSIColors.BLUE)} is deprecated, use ${(0,r.colorize)(`build.traversePattern`,r.ANSIColors.BLUE)} instead`)}},{cacheTimeoutMs:1e3*60})};exports.logConfigDetails=o;
|
|
3
3
|
//# sourceMappingURL=logConfigDetails.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logConfigDetails.cjs","names":["formatPath","intlayerConfigSchema","x","ANSIColors"],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfigurationAndFilePath,\n intlayerConfigSchema,\n} from '@intlayer/config/node';\nimport { formatPath, runOnce } from './utils';\n\nexport const logConfigDetails = (options?: GetConfigurationOptions) => {\n const {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n } = getConfigurationAndFilePath(options);\n const appLogger = getAppLogger(configuration);\n\n runOnce(\n join(\n configuration.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-config-locaded.lock'\n ),\n () => {\n if (numCustomConfiguration === 0) {\n appLogger(\n 'Configuration file not found, using default configuration.',\n {\n isVerbose: true,\n }\n );\n } else {\n const baseDir = configuration.system.baseDir;\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${formatPath(relativeOutputPath)}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n\n if (customConfiguration) {\n const validation = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!validation.success) {\n const errorMessages = validation.error.issues\n .map((error) => {\n const path = colorizePath(` - ${error.path.join('.')}:`);\n const message = colorize(error.message, ANSIColors.GREY_DARK);\n return `${path} ${message}`;\n })\n .join('\\n');\n const errorMessage = `${x} Invalid configuration:\\n${errorMessages}`;\n\n appLogger(errorMessage);\n }\n\n
|
|
1
|
+
{"version":3,"file":"logConfigDetails.cjs","names":["formatPath","intlayerConfigSchema","x","ANSIColors"],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfigurationAndFilePath,\n intlayerConfigSchema,\n} from '@intlayer/config/node';\nimport { formatPath, runOnce } from './utils';\n\nexport const logConfigDetails = (options?: GetConfigurationOptions) => {\n const {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n } = getConfigurationAndFilePath(options);\n const appLogger = getAppLogger(configuration);\n\n runOnce(\n join(\n configuration.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-config-locaded.lock'\n ),\n () => {\n if (numCustomConfiguration === 0) {\n appLogger(\n 'Configuration file not found, using default configuration.',\n {\n isVerbose: true,\n }\n );\n } else {\n const baseDir = configuration.system.baseDir;\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${formatPath(relativeOutputPath)}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n\n if (customConfiguration) {\n const validation = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!validation.success) {\n const errorMessages = validation.error.issues\n .map((error) => {\n const path = colorizePath(` - ${error.path.join('.')}:`);\n const message = colorize(error.message, ANSIColors.GREY_DARK);\n return `${path} ${message}`;\n })\n .join('\\n');\n const errorMessage = `${x} Invalid configuration:\\n${errorMessages}`;\n\n appLogger(errorMessage);\n }\n\n if (customConfiguration.build?.importMode) {\n appLogger(\n `${colorize('build.importMode', ANSIColors.BLUE)} is deprecated, use ${colorize('dictionary.importMode', ANSIColors.BLUE)} instead`\n );\n }\n if (customConfiguration.compiler?.transformPattern) {\n appLogger(\n `${colorize('compiler.transformPattern', ANSIColors.BLUE)} is deprecated, use ${colorize('build.traversePattern', ANSIColors.BLUE)} instead`\n );\n }\n if (customConfiguration.compiler?.excludePattern) {\n appLogger(\n `${colorize('compiler.excludePattern', ANSIColors.BLUE)} is deprecated, use ${colorize('build.traversePattern', ANSIColors.BLUE)} instead`\n );\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 60, // 1 minute\n }\n );\n};\n"],"mappings":"8TAgBA,MAAa,EAAoB,GAAsC,CACrE,GAAM,CACJ,gBACA,sBACA,yBACA,0BAAA,EAAA,EAAA,6BAC8B,EAAQ,CAClC,GAAA,EAAA,EAAA,cAAyB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,EAAA,UAA+B,wBAAyBA,EAAAA,WAAW,KAAK,CAAC,UAClI,GAIP,CACE,eAAgB,IAAO,GACxB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:path`),n=require(`fast-glob`);n=e.__toESM(n);const r=e=>Array.isArray(e)?e:[e],i=e=>{let n=Array.from(new Set(e.map(e=>(0,t.resolve)(e))));return n.sort((e,t)=>e.length-t.length),n.reduce((e,n)=>(e.some(e=>{let r=(0,t.relative)(e,n);return!r.startsWith(`..`)&&!(0,t.isAbsolute)(r)&&r!==``})||e.push(n),e),[])},a=(e,a)=>{let o=e.build.traversePattern,s=e.compiler.transformPattern,c=e.content.watchedFilesPattern,l=[...o,...r(s)].filter(e=>typeof e==`string`).filter(e=>!e.startsWith(`!`)).map(e=>(0,t.normalize)(e)),u=[...a??[],...c,...o.filter(e=>typeof e==`string`&&e.startsWith(`!`)).map(e=>e.slice(1))].filter(e=>typeof e==`string`).map(e=>(0,t.normalize)(e)),d=i([e.system.baseDir,...e.content.codeDir]).flatMap(e=>n.default.sync(l,{cwd:e,ignore:u,absolute:!0,dot:!0}));return Array.from(new Set(d))};exports.buildComponentFilesList=a;
|
|
2
|
+
//# sourceMappingURL=buildComponentFilesList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildComponentFilesList.cjs","names":["fg"],"sources":["../../../src/utils/buildComponentFilesList.ts"],"sourcesContent":["import { isAbsolute, normalize, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\n/**\n * Remove directories that are subdirectories of others in the list so files\n * are never scanned twice.\n * Example: ['/root', '/root/src'] → ['/root']\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const rel = relative(parent, dir);\n\n return !rel.startsWith('..') && !isAbsolute(rel) && rel !== '';\n });\n if (!isNested) acc.push(dir);\n\n return acc;\n }, []);\n};\n\n/**\n * Builds a deduplicated list of absolute file paths matching the given patterns.\n *\n * Handles multiple root directories (deduplicates overlapping roots), exclude\n * patterns, negation patterns embedded in `transformPattern`, and optional\n * dot-file inclusion.\n *\n * @example\n * // Single root with excludes\n * const files = buildComponentFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // Multiple roots (e.g. baseDir + codeDir), dot files included\n * const files = buildComponentFilesList(config, ['**\\/node_modules\\/**']);\n */\nexport const buildComponentFilesList = (\n config: IntlayerConfig,\n excludePattern?: string[]\n): string[] => {\n const transformPattern = config.build.traversePattern;\n const compilerTransformPattern = config.compiler.transformPattern;\n const contentDeclarationPattern = config.content.watchedFilesPattern;\n\n const patterns = [\n ...transformPattern,\n ...normalizeToArray(compilerTransformPattern),\n ]\n .filter((pattern) => typeof pattern === 'string')\n .filter((pattern) => !pattern.startsWith('!'))\n .map((pattern) => normalize(pattern)); // Ensure it works with Windows\n\n const excludePatterns = [\n ...(excludePattern ?? []),\n ...contentDeclarationPattern,\n // Treat negation entries in transformPattern as additional excludes\n ...transformPattern\n .filter(\n (pattern) => typeof pattern === 'string' && pattern.startsWith('!')\n )\n .map((pattern) => pattern.slice(1)),\n ]\n .filter((pattern) => typeof pattern === 'string')\n .map((pattern) => normalize(pattern)); // Ensure it works with Windows\n\n const roots = getDistinctRootDirs([\n config.system.baseDir,\n ...config.content.codeDir,\n ]);\n\n const fileList = roots.flatMap((root) =>\n fg.sync(patterns, {\n cwd: root,\n ignore: excludePatterns,\n absolute: true,\n dot: true, // include dot files like .next / .intlayer\n })\n );\n\n return Array.from(new Set(fileList));\n};\n"],"mappings":"yLAOA,MAAM,EAAuB,GAC3B,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM,CAOlC,EAAuB,GAA6B,CACxD,IAAM,EAAa,MAAM,KAAK,IAAI,IAAI,EAAK,IAAK,IAAA,EAAA,EAAA,SAAgB,EAAI,CAAC,CAAC,CAAC,CAGvE,OAFA,EAAW,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAEvC,EAAW,QAAQ,EAAe,KACtB,EAAI,KAAM,GAAW,CACpC,IAAM,GAAA,EAAA,EAAA,UAAe,EAAQ,EAAI,CAEjC,MAAO,CAAC,EAAI,WAAW,KAAK,EAAI,EAAA,EAAA,EAAA,YAAY,EAAI,EAAI,IAAQ,IAC5D,EACa,EAAI,KAAK,EAAI,CAErB,GACN,EAAE,CAAC,EAsBK,GACX,EACA,IACa,CACb,IAAM,EAAmB,EAAO,MAAM,gBAChC,EAA2B,EAAO,SAAS,iBAC3C,EAA4B,EAAO,QAAQ,oBAE3C,EAAW,CACf,GAAG,EACH,GAAG,EAAiB,EAAyB,CAC9C,CACE,OAAQ,GAAY,OAAO,GAAY,SAAS,CAChD,OAAQ,GAAY,CAAC,EAAQ,WAAW,IAAI,CAAC,CAC7C,IAAK,IAAA,EAAA,EAAA,WAAsB,EAAQ,CAAC,CAEjC,EAAkB,CACtB,GAAI,GAAkB,EAAE,CACxB,GAAG,EAEH,GAAG,EACA,OACE,GAAY,OAAO,GAAY,UAAY,EAAQ,WAAW,IAAI,CACpE,CACA,IAAK,GAAY,EAAQ,MAAM,EAAE,CAAC,CACtC,CACE,OAAQ,GAAY,OAAO,GAAY,SAAS,CAChD,IAAK,IAAA,EAAA,EAAA,WAAsB,EAAQ,CAAC,CAOjC,EALQ,EAAoB,CAChC,EAAO,OAAO,QACd,GAAG,EAAO,QAAQ,QACnB,CAAC,CAEqB,QAAS,GAC9BA,EAAAA,QAAG,KAAK,EAAU,CAChB,IAAK,EACL,OAAQ,EACR,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAED,OAAO,MAAM,KAAK,IAAI,IAAI,EAAS,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:path`),n=require(`fast-glob`);n=e.__toESM(n);const r=e=>Array.isArray(e)?e:[e],i=e=>{let{transformPattern:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:path`),n=require(`fast-glob`);n=e.__toESM(n);const r=e=>Array.isArray(e)?e:[e],i=e=>{let n=Array.from(new Set(e.map(e=>(0,t.resolve)(e))));return n.sort((e,t)=>e.length-t.length),n.reduce((e,n)=>(e.some(e=>{let r=(0,t.relative)(e,n);return!r.startsWith(`..`)&&!(0,t.isAbsolute)(r)&&r!==``})||e.push(n),e),[])},a=e=>{let{transformPattern:a,excludePattern:o=[],baseDir:s,dot:c=!1}=e,l=r(a).filter(e=>typeof e==`string`&&!e.startsWith(`!`)).map(t.normalize),u=[...r(o),...r(a).filter(e=>typeof e==`string`&&e.startsWith(`!`)).map(e=>e.slice(1))].filter(e=>typeof e==`string`).map(t.normalize),d=i(r(s));return Array.from(new Set(d.flatMap(e=>n.default.sync(l,{cwd:e,ignore:u,absolute:!0,dot:c}))))},o=e=>{let{build:{traversePattern:t},system:{baseDir:n},content:{codeDir:r,fileExtensions:i},compiler:{excludePattern:o}}=e;return a({transformPattern:t,excludePattern:[...i.map(e=>`**/*${e}`),...Array.isArray(o)?o:[o]].filter(e=>typeof e==`string`),baseDir:[n,...r],dot:!0})};exports.buildComponentFilesList=a,exports.buildComponentFilesListFromConfig=o;
|
|
2
2
|
//# sourceMappingURL=buildFilesList.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFilesList.cjs","names":["normalize","fg"],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"buildFilesList.cjs","names":["normalize","fg"],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { isAbsolute, normalize, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildComponentFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern?: string | string[];\n /**\n * Base directory (or directories) for file resolution.\n * When multiple directories are provided, subdirectories of others are\n * automatically deduplicated so files are never scanned twice.\n */\n baseDir: string | string[];\n /**\n * Whether to include dot-prefixed files and directories (default: false)\n */\n dot?: boolean;\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\n/**\n * Remove directories that are subdirectories of others in the list so files\n * are never scanned twice.\n * Example: ['/root', '/root/src'] → ['/root']\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const rel = relative(parent, dir);\n return !rel.startsWith('..') && !isAbsolute(rel) && rel !== '';\n });\n if (!isNested) acc.push(dir);\n return acc;\n }, []);\n};\n\n/**\n * Builds a deduplicated list of absolute file paths matching the given patterns.\n *\n * Handles multiple root directories (deduplicates overlapping roots), exclude\n * patterns, negation patterns embedded in `transformPattern`, and optional\n * dot-file inclusion.\n *\n * @example\n * // Single root with excludes\n * const files = buildComponentFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // Multiple roots (e.g. baseDir + codeDir), dot files included\n * const files = buildComponentFilesList({\n * transformPattern: config.build.traversePattern,\n * baseDir: [config.system.baseDir, ...config.content.codeDir],\n * dot: true,\n * });\n */\nexport const buildComponentFilesList = (\n config: BuildComponentFilesListOptions\n): string[] => {\n const {\n transformPattern,\n excludePattern = [],\n baseDir,\n dot = false,\n } = config;\n\n const patterns = normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && !pattern.startsWith('!')\n )\n .map(normalize); // Ensure it works with Windows\n\n const excludePatterns = [\n ...normalizeToArray(excludePattern),\n // Treat negation entries in transformPattern as additional excludes\n ...normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && pattern.startsWith('!')\n )\n .map((pattern) => pattern.slice(1)),\n ]\n .filter((pattern): pattern is string => typeof pattern === 'string')\n .map(normalize); // Ensure it works with Windows\n\n const roots = getDistinctRootDirs(normalizeToArray(baseDir));\n\n return Array.from(\n new Set(\n roots.flatMap((root) =>\n fg.sync(patterns, {\n cwd: root,\n ignore: excludePatterns,\n absolute: true,\n dot,\n })\n )\n )\n );\n};\n\n/**\n * Convenience wrapper that derives all file-list options directly from an\n * `IntlayerConfig` object.\n *\n * Scans `[baseDir, ...codeDir]` using `build.traversePattern`, excludes\n * content declaration file extensions and any `compiler.excludePattern`\n * entries defined in the configuration, and includes dot files.\n */\nexport const buildComponentFilesListFromConfig = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const {\n build: { traversePattern },\n system: { baseDir },\n content: { codeDir, fileExtensions },\n compiler: { excludePattern },\n } = intlayerConfig;\n\n const excludePatterns = [\n // Exclude content declaration files (e.g. **/*.content.ts)\n ...fileExtensions.map((ext) => `**/*${ext}`),\n ...(Array.isArray(excludePattern) ? excludePattern : [excludePattern]),\n ].filter((p): p is string => typeof p === 'string');\n\n return buildComponentFilesList({\n transformPattern: traversePattern,\n excludePattern: excludePatterns,\n baseDir: [baseDir, ...code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kBACpB,SAAU,CAAE,mBACV,EAQJ,OAAO,EAAwB,CAC7B,iBAAkB,EAClB,eARsB,CAEtB,GAAG,EAAe,IAAK,GAAQ,OAAO,IAAM,CAC5C,GAAI,MAAM,QAAQ,EAAe,CAAG,EAAiB,CAAC,EAAe,CACtE,CAAC,OAAQ,GAAmB,OAAO,GAAM,SAAS,CAKjD,QAAS,CAAC,EAAS,GAAG,EAAQ,CAC9B,IAAK,GACN,CAAC"}
|
package/dist/cjs/utils/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pLimit.cjs`),t=require(`./parallelize.cjs`),n=require(`./getPathHash.cjs`),r=require(`./formatter.cjs`),i=require(`./autoDecorateContent.cjs`),a=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./pLimit.cjs`),t=require(`./parallelize.cjs`),n=require(`./getPathHash.cjs`),r=require(`./formatter.cjs`),i=require(`./autoDecorateContent.cjs`),a=require(`./buildComponentFilesList.cjs`),o=require(`./splitTextByLine.cjs`),s=require(`./getChunk.cjs`),c=require(`./chunkJSON.cjs`),l=require(`./getContentExtension.cjs`),u=require(`./getFormatFromExtension.cjs`),d=require(`./mergeChunks.cjs`),f=require(`./parallelizeGlobal.cjs`),p=require(`./reduceObjectFormat.cjs`),m=require(`./resolveObjectPromises.cjs`),h=require(`./resolveRelativePath.cjs`),g=require(`./runOnce.cjs`),_=require(`./runParallel/index.cjs`),v=require(`./sortAlphabetically.cjs`),y=require(`./verifyIdenticObjectFormat.cjs`);exports.Queue=e.Queue,exports.assembleJSON=c.assembleJSON,exports.autoDecorateContent=i.autoDecorateContent,exports.buildComponentFilesList=a.buildComponentFilesList,exports.chunkJSON=c.chunkJSON,exports.formatLocale=r.formatLocale,exports.formatPath=r.formatPath,exports.getChunk=s.getChunk,exports.getContentExtension=l.getContentExtension,exports.getExtensionFromFormat=u.getExtensionFromFormat,exports.getFormatFromExtension=u.getFormatFromExtension,exports.getGlobalLimiter=f.getGlobalLimiter,exports.getPathHash=n.getPathHash,exports.getTaskLimiter=f.getTaskLimiter,exports.mergeChunks=d.mergeChunks,exports.pLimit=e.pLimit,exports.parallelize=t.parallelize,exports.parallelizeGlobal=f.parallelizeGlobal,exports.reconstructFromSingleChunk=c.reconstructFromSingleChunk,exports.reduceObjectFormat=p.reduceObjectFormat,exports.resolveObjectPromises=m.resolveObjectPromises,exports.resolveRelativePath=h.resolveRelativePath,exports.runOnce=g.runOnce,exports.runParallel=_.runParallel,exports.sortAlphabetically=v.sortAlphabetically,exports.splitTextByLines=o.splitTextByLines,exports.verifyIdenticObjectFormat=y.verifyIdenticObjectFormat;
|
package/dist/esm/init/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{initConfig as e}from"../initConfig/index.mjs";import{updateNextConfig as t,updateViteConfig as n}from"./utils/configManipulation.mjs";import{ensureDirectory as r,exists as i,readFileFromRoot as a,writeFileToRoot as o}from"./utils/fileSystem.mjs";import{parseJSONWithComments as s}from"./utils/jsonParser.mjs";import{findTsConfigFiles as c}from"./utils/tsConfig.mjs";import{join as l}from"node:path";import{ANSIColors as u,colorize as d,colorizePath as f,logger as p,v as m,x as h}from"@intlayer/config/logger";import{getConfiguration as g}from"@intlayer/config/node";import{getAlias as _}from"@intlayer/config/utils";const v={NextJS:`https://intlayer.org/doc/environment/nextjs.md`,NextJS_15:`https://intlayer.org/doc/environment/nextjs/15.md`,NextJS_14:`https://intlayer.org/doc/environment/nextjs/14.md`,CRA:`https://intlayer.org/doc/environment/create-react-app.md`,Astro:`https://intlayer.org/doc/environment/astro.md`,ViteAndReact:`https://intlayer.org/doc/environment/vite-and-react.md`,ViteAndReact_ReactRouterV7:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md`,ViteAndReact_ReactRouterV7_FSRoutes:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md`,ViteAndVue:`https://intlayer.org/doc/environment/vite-and-vue.md`,ViteAndSolid:`https://intlayer.org/doc/environment/vite-and-solid.md`,ViteAndSvelte:`https://intlayer.org/doc/environment/vite-and-svelte.md`,ViteAndPreact:`https://intlayer.org/doc/environment/vite-and-preact.md`,TanStackRouter:`https://intlayer.org/doc/environment/tanstack.md`,NuxtAndVue:`https://intlayer.org/doc/environment/nuxt-and-vue.md`,Angular:`https://intlayer.org/doc/environment/angular.md`,SvelteKit:`https://intlayer.org/doc/environment/sveltekit.md`,ReactNativeAndExpo:`https://intlayer.org/doc/environment/react-native-and-expo.md`,Lynx:`https://intlayer.org/doc/environment/lynx-and-react.md`,Express:`https://intlayer.org/doc/environment/express.md`,NestJS:`https://intlayer.org/doc/environment/nestjs.md`,Fastify:`https://intlayer.org/doc/environment/fastify.md`,Default:`https://intlayer.org/doc/get-started`,NextIntl:`https://intlayer.org/blog/intlayer-with-next-intl.md`,ReactI18Next:`https://intlayer.org/blog/intlayer-with-react-i18next.md`,ReactIntl:`https://intlayer.org/blog/intlayer-with-react-intl.md`,NextI18Next:`https://intlayer.org/blog/intlayer-with-next-i18next.md`,VueI18n:`https://intlayer.org/blog/intlayer-with-vue-i18n.md`},y=e=>{let t={...e.dependencies,...e.devDependencies},n=(e,t)=>!e||typeof e!=`string`?!1:RegExp(`^[\\^~]?${t}(?:\\.|$)`).test(e);if(t[`@lynx-js/react`]||t[`@lynx-js/core`])return v.Lynx;if(t[`react-native`]||t.expo)return v.ReactNativeAndExpo;if(t.next){let e=t.next;return n(e,14)?v.NextJS_14:n(e,15)?v.NextJS_15:v.NextJS}if(t.nuxt)return v.NuxtAndVue;if(t.astro)return v.Astro;if(t[`@sveltejs/kit`])return v.SvelteKit;if(t[`@tanstack/react-router`])return v.TanStackRouter;let r=t[`react-router`];if(r&&typeof r==`string`){if(t[`@react-router/fs-routes`])return v.ViteAndReact_ReactRouterV7_FSRoutes;if(n(r,7))return v.ViteAndReact_ReactRouterV7}return t.vite?t.vue?v.ViteAndVue:t[`solid-js`]?v.ViteAndSolid:t.svelte?v.ViteAndSvelte:t.preact?v.ViteAndPreact:v.ViteAndReact:t[`react-scripts`]?v.CRA:t[`@angular/core`]?v.Angular:t[`@nestjs/core`]?v.NestJS:t.express?v.Express:t.fastify?v.Fastify:t[`next-intl`]?v.NextIntl:t[`react-i18next`]||t.i18next?v.ReactI18Next:t[`react-intl`]?v.ReactIntl:t[`next-i18next`]?v.NextI18Next:t[`vue-i18n`]?v.VueI18n:v.Default},b=async v=>{p(d(`Checking Intlayer configuration...`,u.CYAN));let b=`package.json`;await i(v,b)||(p(`${h} No ${f(`package.json`)} found. Please run this script from the project root.`,{level:`error`}),process.exit(1));let x=await a(v,b),S;try{S=JSON.parse(x)}catch{p(`${h} Could not parse ${f(`package.json`)}.`,{level:`error`}),process.exit(1)}let C=y(S),w=`.gitignore`;if(await i(v,w)){let e=await a(v,w);e.includes(`intlayer`)?p(`${m} ${f(w)} already includes .intlayer`):(await o(v,w,`${e}\n# Intlayer\n.intlayer\n`),p(`${m} Added ${f(`.intlayer`)} to ${f(w)}`))}let T=`.vscode`,E=l(T,`extensions.json`),D=`intlayer.intlayer-vs-code-extension`;try{let e={recommendations:[]};await i(v,E)?e=s(await a(v,E)):await r(v,T),e.recommendations||=[],e.recommendations.includes(D)?p(`${m} ${f(E)} already includes ${d(D,u.MAGENTA)}`):(e.recommendations.push(D),await o(v,E,JSON.stringify(e,null,2)),p(`${m} Added ${d(D,u.MAGENTA)} to ${f(E)}`))}catch{p(`${h} Could not update ${f(E)}. You may need to add ${d(D,u.MAGENTA)} manually.`,{level:`warn`})}let O=await c(v),k=!1;for(let e of O)if(await i(v,e)){k=!0;try{let t=s(await a(v,e)),n=`.intlayer/**/*.ts`,r=!1;t.include&&(Array.isArray(t.include)&&!t.include.some(e=>e.includes(`.intlayer`))?(t.include.push(n),r=!0):t.include.includes(n)&&p(`${m} ${f(e)} already includes intlayer types`)),r&&(await o(v,e,JSON.stringify(t,null,2)),p(`${m} Updated ${f(e)} to include intlayer types`))}catch{p(`${h} Could not parse or update ${f(e)}. You may need to add ${f(`.intlayer/types/**/*.ts`)} manually.`,{level:`warn`})}}await e(k?`intlayer.config.ts`:`intlayer.config.mjs`,v);let A=!1;for(let e of[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`])if(await i(v,e)){A=!0;let t=await a(v,e);t.includes(`vite-intlayer`)||(await o(v,e,n(t,e.split(`.`).pop())),p(`${m} Updated ${f(e)} to include Intlayer plugin`));break}
|
|
1
|
+
import{initConfig as e}from"../initConfig/index.mjs";import{updateNextConfig as t,updateViteConfig as n}from"./utils/configManipulation.mjs";import{ensureDirectory as r,exists as i,readFileFromRoot as a,writeFileToRoot as o}from"./utils/fileSystem.mjs";import{parseJSONWithComments as s}from"./utils/jsonParser.mjs";import{findTsConfigFiles as c}from"./utils/tsConfig.mjs";import{join as l}from"node:path";import{ANSIColors as u,colorize as d,colorizePath as f,logger as p,v as m,x as h}from"@intlayer/config/logger";import{getConfiguration as g}from"@intlayer/config/node";import{getAlias as _}from"@intlayer/config/utils";const v={NextJS:`https://intlayer.org/doc/environment/nextjs.md`,NextJS_15:`https://intlayer.org/doc/environment/nextjs/15.md`,NextJS_14:`https://intlayer.org/doc/environment/nextjs/14.md`,CRA:`https://intlayer.org/doc/environment/create-react-app.md`,Astro:`https://intlayer.org/doc/environment/astro.md`,ViteAndReact:`https://intlayer.org/doc/environment/vite-and-react.md`,ViteAndReact_ReactRouterV7:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md`,ViteAndReact_ReactRouterV7_FSRoutes:`https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md`,ViteAndVue:`https://intlayer.org/doc/environment/vite-and-vue.md`,ViteAndSolid:`https://intlayer.org/doc/environment/vite-and-solid.md`,ViteAndSvelte:`https://intlayer.org/doc/environment/vite-and-svelte.md`,ViteAndPreact:`https://intlayer.org/doc/environment/vite-and-preact.md`,TanStackRouter:`https://intlayer.org/doc/environment/tanstack.md`,NuxtAndVue:`https://intlayer.org/doc/environment/nuxt-and-vue.md`,Angular:`https://intlayer.org/doc/environment/angular.md`,SvelteKit:`https://intlayer.org/doc/environment/sveltekit.md`,ReactNativeAndExpo:`https://intlayer.org/doc/environment/react-native-and-expo.md`,Lynx:`https://intlayer.org/doc/environment/lynx-and-react.md`,Express:`https://intlayer.org/doc/environment/express.md`,NestJS:`https://intlayer.org/doc/environment/nestjs.md`,Fastify:`https://intlayer.org/doc/environment/fastify.md`,Default:`https://intlayer.org/doc/get-started`,NextIntl:`https://intlayer.org/blog/intlayer-with-next-intl.md`,ReactI18Next:`https://intlayer.org/blog/intlayer-with-react-i18next.md`,ReactIntl:`https://intlayer.org/blog/intlayer-with-react-intl.md`,NextI18Next:`https://intlayer.org/blog/intlayer-with-next-i18next.md`,VueI18n:`https://intlayer.org/blog/intlayer-with-vue-i18n.md`},y=e=>{let t={...e.dependencies,...e.devDependencies},n=(e,t)=>!e||typeof e!=`string`?!1:RegExp(`^[\\^~]?${t}(?:\\.|$)`).test(e);if(t[`@lynx-js/react`]||t[`@lynx-js/core`])return v.Lynx;if(t[`react-native`]||t.expo)return v.ReactNativeAndExpo;if(t.next){let e=t.next;return n(e,14)?v.NextJS_14:n(e,15)?v.NextJS_15:v.NextJS}if(t.nuxt)return v.NuxtAndVue;if(t.astro)return v.Astro;if(t[`@sveltejs/kit`])return v.SvelteKit;if(t[`@tanstack/react-router`])return v.TanStackRouter;let r=t[`react-router`];if(r&&typeof r==`string`){if(t[`@react-router/fs-routes`])return v.ViteAndReact_ReactRouterV7_FSRoutes;if(n(r,7))return v.ViteAndReact_ReactRouterV7}return t.vite?t.vue?v.ViteAndVue:t[`solid-js`]?v.ViteAndSolid:t.svelte?v.ViteAndSvelte:t.preact?v.ViteAndPreact:v.ViteAndReact:t[`react-scripts`]?v.CRA:t[`@angular/core`]?v.Angular:t[`@nestjs/core`]?v.NestJS:t.express?v.Express:t.fastify?v.Fastify:t[`next-intl`]?v.NextIntl:t[`react-i18next`]||t.i18next?v.ReactI18Next:t[`react-intl`]?v.ReactIntl:t[`next-i18next`]?v.NextI18Next:t[`vue-i18n`]?v.VueI18n:v.Default},b=async v=>{p(d(`Checking Intlayer configuration...`,u.CYAN));let b=`package.json`;await i(v,b)||(p(`${h} No ${f(`package.json`)} found. Please run this script from the project root.`,{level:`error`}),process.exit(1));let x=await a(v,b),S;try{S=JSON.parse(x)}catch{p(`${h} Could not parse ${f(`package.json`)}.`,{level:`error`}),process.exit(1)}let C=y(S),w=`.gitignore`;if(await i(v,w)){let e=await a(v,w);e.includes(`intlayer`)?p(`${m} ${f(w)} already includes .intlayer`):(await o(v,w,`${e}\n# Intlayer\n.intlayer\n`),p(`${m} Added ${f(`.intlayer`)} to ${f(w)}`))}let T=`.vscode`,E=l(T,`extensions.json`),D=`intlayer.intlayer-vs-code-extension`;try{let e={recommendations:[]};await i(v,E)?e=s(await a(v,E)):await r(v,T),e.recommendations||=[],e.recommendations.includes(D)?p(`${m} ${f(E)} already includes ${d(D,u.MAGENTA)}`):(e.recommendations.push(D),await o(v,E,JSON.stringify(e,null,2)),p(`${m} Added ${d(D,u.MAGENTA)} to ${f(E)}`))}catch{p(`${h} Could not update ${f(E)}. You may need to add ${d(D,u.MAGENTA)} manually.`,{level:`warn`})}let O=await c(v),k=!1;for(let e of O)if(await i(v,e)){k=!0;try{let t=s(await a(v,e)),n=`.intlayer/**/*.ts`,r=!1;t.include&&(Array.isArray(t.include)&&!t.include.some(e=>e.includes(`.intlayer`))?(t.include.push(n),r=!0):t.include.includes(n)&&p(`${m} ${f(e)} already includes intlayer types`)),r&&(await o(v,e,JSON.stringify(t,null,2)),p(`${m} Updated ${f(e)} to include intlayer types`))}catch{p(`${h} Could not parse or update ${f(e)}. You may need to add ${f(`.intlayer/types/**/*.ts`)} manually.`,{level:`warn`})}}await e(k?`intlayer.config.ts`:`intlayer.config.mjs`,v);let A=!1;for(let e of[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`])if(await i(v,e)){A=!0;let t=await a(v,e);t.includes(`vite-intlayer`)||(await o(v,e,n(t,e.split(`.`).pop())),p(`${m} Updated ${f(e)} to include Intlayer plugin`));break}let j=[`next.config.js`,`next.config.mjs`,`next.config.ts`],M=!1;for(let e of j)if(await i(v,e)){M=!0,A=!0;let n=await a(v,e);n.includes(`next-intlayer`)||(await o(v,e,t(n,e.split(`.`).pop())),p(`${m} Updated ${f(e)} to include Intlayer plugin`));break}if(M){let e=S.dependencies?.next||S.devDependencies?.next;if(e&&((e,t)=>{if(!e||typeof e!=`string`)return!1;let n=e.match(/^[^\d]*(\d+)/);return n?parseInt(n[1],10)>=t:!1})(e,16)){let e=S.scripts?.dev,t=`intlayer watch --with 'bun run --bun next dev'`;e&&e!==t&&e.includes(`next dev`)&&(S.scripts.dev=t,await o(v,b,JSON.stringify(S,null,2)),p(`${m} Updated ${f(`package.json`)} dev script for Next.js >= 16`))}}for(let e of[`webpack.config.js`,`webpack.config.ts`,`webpack.config.mjs`,`webpack.config.cjs`])if(await i(v,e)){A=!0,p(`${m} Found ${f(e)}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`);break}if(!A){let e=_({configuration:g({baseDir:v})});if(k&&O.length>0){let t=O.find(e=>e===`tsconfig.json`)||O[0],n=s(await a(v,t));n.compilerOptions??={},n.compilerOptions.paths??={};let r=!1;Object.entries(e).forEach(([e,t])=>{n.compilerOptions.paths[e]||(n.compilerOptions.paths[e]=[t],r=!0)}),r&&(await o(v,t,JSON.stringify(n,null,2)),p(`${m} Updated ${f(t)} to include Intlayer aliases`))}else{let t=`jsconfig.json`;if(await i(v,t)){let n=s(await a(v,t));n.compilerOptions??={},n.compilerOptions.paths??={};let r=!1;Object.entries(e).forEach(([e,t])=>{n.compilerOptions.paths[e]||(n.compilerOptions.paths[e]=[t],r=!0)}),r&&(await o(v,t,JSON.stringify(n,null,2)),p(`${m} Updated ${f(t)} to include Intlayer aliases`))}else{S.imports??={};let t=!1;Object.entries(e).forEach(([e,n])=>{let r=e.replace(`@`,`#`),i=n.startsWith(`.`)?n:`./${n}`;S.imports[r]||(S.imports[r]=i,t=!0)}),t&&(await o(v,b,JSON.stringify(S,null,2)),p(`${m} Updated ${f(b)} to include Intlayer imports`))}}}p(`${m} ${d(`Intlayer init setup complete.`,u.GREEN)}`),p([d(`Next →`,u.MAGENTA),d(`Follow the instructions in the documentation to complete the setup:`,u.GREY_LIGHT),f(C)])};export{b as initIntlayer};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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 for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\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 // 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,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} 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:`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B,MAAM,GAAS,CAAC,EAAK,CAC5C,EAAU,KAEZ,CAEE,IACF,MAAM,EACJ,EACA,EACA,KAAK,UAAU,EAAQ,KAAM,EAAE,CAChC,CACD,EACE,GAAG,EAAE,WAAW,EACd,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,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,3 +1,3 @@
|
|
|
1
1
|
import{formatPath as e}from"./utils/formatter.mjs";import{runOnce as t}from"./utils/runOnce.mjs";import{join as n,relative as r}from"node:path";import{ANSIColors as i,colorize as a,colorizePath as o,getAppLogger as s,x as c}from"@intlayer/config/logger";import{getConfigurationAndFilePath as l,intlayerConfigSchema as u}from"@intlayer/config/node";import{getEnvFilePath as d}from"@intlayer/config/env";const f=f=>{let{configuration:p,customConfiguration:m,numCustomConfiguration:h,configurationFilePath:g}=l(f),_=s(p);t(n(p.system.baseDir,`.intlayer`,`cache`,`intlayer-config-locaded.lock`),()=>{if(h===0)_(`Configuration file not found, using default configuration.`,{isVerbose:!0});else{let t=p.system.baseDir,n=r(t,g);if(h===1){let t=d(f?.env,f?.envFile);_(`Configuration loaded ${e(n)}${t?` - Env: ${e(t)}`:``}`,{isVerbose:!0})}else _(`Multiple configuration files found, using ${e(n)}.`,{isVerbose:!0})}if(m){let e=u.safeParse(m);e.success||_(`${c} Invalid configuration:\n${e.error.issues.map(e=>`${o(` - ${e.path.join(`.`)}:`)} ${a(e.message,i.GREY_DARK)}`).join(`
|
|
2
|
-
`)}`),m.
|
|
2
|
+
`)}`),m.build?.importMode&&_(`${a(`build.importMode`,i.BLUE)} is deprecated, use ${a(`dictionary.importMode`,i.BLUE)} instead`),m.compiler?.transformPattern&&_(`${a(`compiler.transformPattern`,i.BLUE)} is deprecated, use ${a(`build.traversePattern`,i.BLUE)} instead`),m.compiler?.excludePattern&&_(`${a(`compiler.excludePattern`,i.BLUE)} is deprecated, use ${a(`build.traversePattern`,i.BLUE)} instead`)}},{cacheTimeoutMs:1e3*60})};export{f as logConfigDetails};
|
|
3
3
|
//# sourceMappingURL=logConfigDetails.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logConfigDetails.mjs","names":[],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfigurationAndFilePath,\n intlayerConfigSchema,\n} from '@intlayer/config/node';\nimport { formatPath, runOnce } from './utils';\n\nexport const logConfigDetails = (options?: GetConfigurationOptions) => {\n const {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n } = getConfigurationAndFilePath(options);\n const appLogger = getAppLogger(configuration);\n\n runOnce(\n join(\n configuration.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-config-locaded.lock'\n ),\n () => {\n if (numCustomConfiguration === 0) {\n appLogger(\n 'Configuration file not found, using default configuration.',\n {\n isVerbose: true,\n }\n );\n } else {\n const baseDir = configuration.system.baseDir;\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${formatPath(relativeOutputPath)}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n\n if (customConfiguration) {\n const validation = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!validation.success) {\n const errorMessages = validation.error.issues\n .map((error) => {\n const path = colorizePath(` - ${error.path.join('.')}:`);\n const message = colorize(error.message, ANSIColors.GREY_DARK);\n return `${path} ${message}`;\n })\n .join('\\n');\n const errorMessage = `${x} Invalid configuration:\\n${errorMessages}`;\n\n appLogger(errorMessage);\n }\n\n
|
|
1
|
+
{"version":3,"file":"logConfigDetails.mjs","names":[],"sources":["../../src/logConfigDetails.ts"],"sourcesContent":["import { join, relative } from 'node:path';\nimport { getEnvFilePath } from '@intlayer/config/env';\nimport {\n ANSIColors,\n colorize,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfigurationAndFilePath,\n intlayerConfigSchema,\n} from '@intlayer/config/node';\nimport { formatPath, runOnce } from './utils';\n\nexport const logConfigDetails = (options?: GetConfigurationOptions) => {\n const {\n configuration,\n customConfiguration,\n numCustomConfiguration,\n configurationFilePath,\n } = getConfigurationAndFilePath(options);\n const appLogger = getAppLogger(configuration);\n\n runOnce(\n join(\n configuration.system.baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-config-locaded.lock'\n ),\n () => {\n if (numCustomConfiguration === 0) {\n appLogger(\n 'Configuration file not found, using default configuration.',\n {\n isVerbose: true,\n }\n );\n } else {\n const baseDir = configuration.system.baseDir;\n const relativeOutputPath = relative(baseDir, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n const dotEnvFilePath = getEnvFilePath(options?.env, options?.envFile);\n\n appLogger(\n `Configuration loaded ${formatPath(relativeOutputPath)}${dotEnvFilePath ? ` - Env: ${formatPath(dotEnvFilePath)}` : ''}`,\n {\n isVerbose: true,\n }\n );\n } else {\n appLogger(\n `Multiple configuration files found, using ${formatPath(relativeOutputPath)}.`,\n {\n isVerbose: true,\n }\n );\n }\n }\n\n if (customConfiguration) {\n const validation = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!validation.success) {\n const errorMessages = validation.error.issues\n .map((error) => {\n const path = colorizePath(` - ${error.path.join('.')}:`);\n const message = colorize(error.message, ANSIColors.GREY_DARK);\n return `${path} ${message}`;\n })\n .join('\\n');\n const errorMessage = `${x} Invalid configuration:\\n${errorMessages}`;\n\n appLogger(errorMessage);\n }\n\n if (customConfiguration.build?.importMode) {\n appLogger(\n `${colorize('build.importMode', ANSIColors.BLUE)} is deprecated, use ${colorize('dictionary.importMode', ANSIColors.BLUE)} instead`\n );\n }\n if (customConfiguration.compiler?.transformPattern) {\n appLogger(\n `${colorize('compiler.transformPattern', ANSIColors.BLUE)} is deprecated, use ${colorize('build.traversePattern', ANSIColors.BLUE)} instead`\n );\n }\n if (customConfiguration.compiler?.excludePattern) {\n appLogger(\n `${colorize('compiler.excludePattern', ANSIColors.BLUE)} is deprecated, use ${colorize('build.traversePattern', ANSIColors.BLUE)} instead`\n );\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 60, // 1 minute\n }\n );\n};\n"],"mappings":"kZAgBA,MAAa,EAAoB,GAAsC,CACrE,GAAM,CACJ,gBACA,sBACA,yBACA,yBACE,EAA4B,EAAQ,CAClC,EAAY,EAAa,EAAc,CAE7C,EACE,EACE,EAAc,OAAO,QACrB,YACA,QACA,+BACD,KACK,CACJ,GAAI,IAA2B,EAC7B,EACE,6DACA,CACE,UAAW,GACZ,CACF,KACI,CACL,IAAM,EAAU,EAAc,OAAO,QAC/B,EAAqB,EAAS,EAAS,EAAuB,CAEpE,GAAI,IAA2B,EAAG,CAChC,IAAM,EAAiB,EAAe,GAAS,IAAK,GAAS,QAAQ,CAErE,EACE,wBAAwB,EAAW,EAAmB,GAAG,EAAiB,WAAW,EAAW,EAAe,GAAK,KACpH,CACE,UAAW,GACZ,CACF,MAED,EACE,6CAA6C,EAAW,EAAmB,CAAC,GAC5E,CACE,UAAW,GACZ,CACF,CAIL,GAAI,EAAqB,CACvB,IAAM,EAAa,EAAqB,UAAU,EAAoB,CAEjE,EAAW,SAUd,EAFqB,GAAG,EAAE,2BAPJ,EAAW,MAAM,OACpC,IAAK,GAGG,GAFM,EAAa,MAAM,EAAM,KAAK,KAAK,IAAI,CAAC,GAAG,CAEzC,GADC,EAAS,EAAM,QAAS,EAAW,UAAU,GAE7D,CACD,KAAK;EAAK,GAGU,CAGrB,EAAoB,OAAO,YAC7B,EACE,GAAG,EAAS,mBAAoB,EAAW,KAAK,CAAC,sBAAsB,EAAS,wBAAyB,EAAW,KAAK,CAAC,UAC3H,CAEC,EAAoB,UAAU,kBAChC,EACE,GAAG,EAAS,4BAA6B,EAAW,KAAK,CAAC,sBAAsB,EAAS,wBAAyB,EAAW,KAAK,CAAC,UACpI,CAEC,EAAoB,UAAU,gBAChC,EACE,GAAG,EAAS,0BAA2B,EAAW,KAAK,CAAC,sBAAsB,EAAS,wBAAyB,EAAW,KAAK,CAAC,UAClI,GAIP,CACE,eAAgB,IAAO,GACxB,CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isAbsolute as e,normalize as t,relative as n,resolve as r}from"node:path";import i from"fast-glob";const a=e=>Array.isArray(e)?e:[e],o=t=>{let i=Array.from(new Set(t.map(e=>r(e))));return i.sort((e,t)=>e.length-t.length),i.reduce((t,r)=>(t.some(t=>{let i=n(t,r);return!i.startsWith(`..`)&&!e(i)&&i!==``})||t.push(r),t),[])},s=(e,n)=>{let r=e.build.traversePattern,s=e.compiler.transformPattern,c=e.content.watchedFilesPattern,l=[...r,...a(s)].filter(e=>typeof e==`string`).filter(e=>!e.startsWith(`!`)).map(e=>t(e)),u=[...n??[],...c,...r.filter(e=>typeof e==`string`&&e.startsWith(`!`)).map(e=>e.slice(1))].filter(e=>typeof e==`string`).map(e=>t(e)),d=o([e.system.baseDir,...e.content.codeDir]).flatMap(e=>i.sync(l,{cwd:e,ignore:u,absolute:!0,dot:!0}));return Array.from(new Set(d))};export{s as buildComponentFilesList};
|
|
2
|
+
//# sourceMappingURL=buildComponentFilesList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildComponentFilesList.mjs","names":[],"sources":["../../../src/utils/buildComponentFilesList.ts"],"sourcesContent":["import { isAbsolute, normalize, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\n/**\n * Remove directories that are subdirectories of others in the list so files\n * are never scanned twice.\n * Example: ['/root', '/root/src'] → ['/root']\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const rel = relative(parent, dir);\n\n return !rel.startsWith('..') && !isAbsolute(rel) && rel !== '';\n });\n if (!isNested) acc.push(dir);\n\n return acc;\n }, []);\n};\n\n/**\n * Builds a deduplicated list of absolute file paths matching the given patterns.\n *\n * Handles multiple root directories (deduplicates overlapping roots), exclude\n * patterns, negation patterns embedded in `transformPattern`, and optional\n * dot-file inclusion.\n *\n * @example\n * // Single root with excludes\n * const files = buildComponentFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // Multiple roots (e.g. baseDir + codeDir), dot files included\n * const files = buildComponentFilesList(config, ['**\\/node_modules\\/**']);\n */\nexport const buildComponentFilesList = (\n config: IntlayerConfig,\n excludePattern?: string[]\n): string[] => {\n const transformPattern = config.build.traversePattern;\n const compilerTransformPattern = config.compiler.transformPattern;\n const contentDeclarationPattern = config.content.watchedFilesPattern;\n\n const patterns = [\n ...transformPattern,\n ...normalizeToArray(compilerTransformPattern),\n ]\n .filter((pattern) => typeof pattern === 'string')\n .filter((pattern) => !pattern.startsWith('!'))\n .map((pattern) => normalize(pattern)); // Ensure it works with Windows\n\n const excludePatterns = [\n ...(excludePattern ?? []),\n ...contentDeclarationPattern,\n // Treat negation entries in transformPattern as additional excludes\n ...transformPattern\n .filter(\n (pattern) => typeof pattern === 'string' && pattern.startsWith('!')\n )\n .map((pattern) => pattern.slice(1)),\n ]\n .filter((pattern) => typeof pattern === 'string')\n .map((pattern) => normalize(pattern)); // Ensure it works with Windows\n\n const roots = getDistinctRootDirs([\n config.system.baseDir,\n ...config.content.codeDir,\n ]);\n\n const fileList = roots.flatMap((root) =>\n fg.sync(patterns, {\n cwd: root,\n ignore: excludePatterns,\n absolute: true,\n dot: true, // include dot files like .next / .intlayer\n })\n );\n\n return Array.from(new Set(fileList));\n};\n"],"mappings":"0GAOA,MAAM,EAAuB,GAC3B,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM,CAOlC,EAAuB,GAA6B,CACxD,IAAM,EAAa,MAAM,KAAK,IAAI,IAAI,EAAK,IAAK,GAAQ,EAAQ,EAAI,CAAC,CAAC,CAAC,CAGvE,OAFA,EAAW,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAEvC,EAAW,QAAQ,EAAe,KACtB,EAAI,KAAM,GAAW,CACpC,IAAM,EAAM,EAAS,EAAQ,EAAI,CAEjC,MAAO,CAAC,EAAI,WAAW,KAAK,EAAI,CAAC,EAAW,EAAI,EAAI,IAAQ,IAC5D,EACa,EAAI,KAAK,EAAI,CAErB,GACN,EAAE,CAAC,EAsBK,GACX,EACA,IACa,CACb,IAAM,EAAmB,EAAO,MAAM,gBAChC,EAA2B,EAAO,SAAS,iBAC3C,EAA4B,EAAO,QAAQ,oBAE3C,EAAW,CACf,GAAG,EACH,GAAG,EAAiB,EAAyB,CAC9C,CACE,OAAQ,GAAY,OAAO,GAAY,SAAS,CAChD,OAAQ,GAAY,CAAC,EAAQ,WAAW,IAAI,CAAC,CAC7C,IAAK,GAAY,EAAU,EAAQ,CAAC,CAEjC,EAAkB,CACtB,GAAI,GAAkB,EAAE,CACxB,GAAG,EAEH,GAAG,EACA,OACE,GAAY,OAAO,GAAY,UAAY,EAAQ,WAAW,IAAI,CACpE,CACA,IAAK,GAAY,EAAQ,MAAM,EAAE,CAAC,CACtC,CACE,OAAQ,GAAY,OAAO,GAAY,SAAS,CAChD,IAAK,GAAY,EAAU,EAAQ,CAAC,CAOjC,EALQ,EAAoB,CAChC,EAAO,OAAO,QACd,GAAG,EAAO,QAAQ,QACnB,CAAC,CAEqB,QAAS,GAC9B,EAAG,KAAK,EAAU,CAChB,IAAK,EACL,OAAQ,EACR,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAED,OAAO,MAAM,KAAK,IAAI,IAAI,EAAS,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isAbsolute as e,normalize as t,relative as n,resolve as r}from"node:path";import i from"fast-glob";const a=e=>Array.isArray(e)?e:[e],o=t=>{let i=Array.from(new Set(t.map(e=>r(e))));return i.sort((e,t)=>e.length-t.length),i.reduce((t,r)=>(t.some(t=>{let i=n(t,r);return!i.startsWith(`..`)&&!e(i)&&i!==``})||t.push(r),t),[])},s=e=>{let{transformPattern:n,excludePattern:r=[],baseDir:s,dot:c=!1}=e,l=a(n).filter(e=>typeof e==`string`&&!e.startsWith(`!`)).map(t),u=[...a(r),...a(n).filter(e=>typeof e==`string`&&e.startsWith(`!`)).map(e=>e.slice(1))].filter(e=>typeof e==`string`).map(t),d=o(a(s));return Array.from(new Set(d.flatMap(e=>i.sync(l,{cwd:e,ignore:u,absolute:!0,dot:c}))))},c=e=>{let{build:{traversePattern:t},system:{baseDir:n},content:{codeDir:r,fileExtensions:i},compiler:{excludePattern:a}}=e;return s({transformPattern:t,excludePattern:[...i.map(e=>`**/*${e}`),...Array.isArray(a)?a:[a]].filter(e=>typeof e==`string`),baseDir:[n,...r],dot:!0})};export{s as buildComponentFilesList,c as buildComponentFilesListFromConfig};
|
|
2
2
|
//# sourceMappingURL=buildFilesList.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFilesList.mjs","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"buildFilesList.mjs","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"sourcesContent":["import { isAbsolute, normalize, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Options for building the files list\n */\nexport type BuildComponentFilesListOptions = {\n /**\n * Glob patterns to match files\n */\n transformPattern: string | string[];\n /**\n * Glob patterns to exclude files\n */\n excludePattern?: string | string[];\n /**\n * Base directory (or directories) for file resolution.\n * When multiple directories are provided, subdirectories of others are\n * automatically deduplicated so files are never scanned twice.\n */\n baseDir: string | string[];\n /**\n * Whether to include dot-prefixed files and directories (default: false)\n */\n dot?: boolean;\n};\n\n/**\n * Normalizes a pattern value to an array\n */\nconst normalizeToArray = <T>(value: T | T[]): T[] =>\n Array.isArray(value) ? value : [value];\n\n/**\n * Remove directories that are subdirectories of others in the list so files\n * are never scanned twice.\n * Example: ['/root', '/root/src'] → ['/root']\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const rel = relative(parent, dir);\n return !rel.startsWith('..') && !isAbsolute(rel) && rel !== '';\n });\n if (!isNested) acc.push(dir);\n return acc;\n }, []);\n};\n\n/**\n * Builds a deduplicated list of absolute file paths matching the given patterns.\n *\n * Handles multiple root directories (deduplicates overlapping roots), exclude\n * patterns, negation patterns embedded in `transformPattern`, and optional\n * dot-file inclusion.\n *\n * @example\n * // Single root with excludes\n * const files = buildComponentFilesList({\n * transformPattern: 'src/**\\/*.{ts,tsx}',\n * excludePattern: ['**\\/node_modules\\/**'],\n * baseDir: '/path/to/project',\n * });\n *\n * @example\n * // Multiple roots (e.g. baseDir + codeDir), dot files included\n * const files = buildComponentFilesList({\n * transformPattern: config.build.traversePattern,\n * baseDir: [config.system.baseDir, ...config.content.codeDir],\n * dot: true,\n * });\n */\nexport const buildComponentFilesList = (\n config: BuildComponentFilesListOptions\n): string[] => {\n const {\n transformPattern,\n excludePattern = [],\n baseDir,\n dot = false,\n } = config;\n\n const patterns = normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && !pattern.startsWith('!')\n )\n .map(normalize); // Ensure it works with Windows\n\n const excludePatterns = [\n ...normalizeToArray(excludePattern),\n // Treat negation entries in transformPattern as additional excludes\n ...normalizeToArray(transformPattern)\n .filter(\n (pattern): pattern is string =>\n typeof pattern === 'string' && pattern.startsWith('!')\n )\n .map((pattern) => pattern.slice(1)),\n ]\n .filter((pattern): pattern is string => typeof pattern === 'string')\n .map(normalize); // Ensure it works with Windows\n\n const roots = getDistinctRootDirs(normalizeToArray(baseDir));\n\n return Array.from(\n new Set(\n roots.flatMap((root) =>\n fg.sync(patterns, {\n cwd: root,\n ignore: excludePatterns,\n absolute: true,\n dot,\n })\n )\n )\n );\n};\n\n/**\n * Convenience wrapper that derives all file-list options directly from an\n * `IntlayerConfig` object.\n *\n * Scans `[baseDir, ...codeDir]` using `build.traversePattern`, excludes\n * content declaration file extensions and any `compiler.excludePattern`\n * entries defined in the configuration, and includes dot files.\n */\nexport const buildComponentFilesListFromConfig = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const {\n build: { traversePattern },\n system: { baseDir },\n content: { codeDir, fileExtensions },\n compiler: { excludePattern },\n } = intlayerConfig;\n\n const excludePatterns = [\n // Exclude content declaration files (e.g. **/*.content.ts)\n ...fileExtensions.map((ext) => `**/*${ext}`),\n ...(Array.isArray(excludePattern) ? excludePattern : [excludePattern]),\n ].filter((p): p is string => typeof p === 'string');\n\n return buildComponentFilesList({\n transformPattern: traversePattern,\n excludePattern: excludePatterns,\n baseDir: [baseDir, ...codeDir],\n dot: true,\n });\n};\n"],"mappings":"0GA+BA,MAAM,EAAuB,GAC3B,MAAM,QAAQ,EAAM,CAAG,EAAQ,CAAC,EAAM,CAOlC,EAAuB,GAA6B,CACxD,IAAM,EAAa,MAAM,KAAK,IAAI,IAAI,EAAK,IAAK,GAAQ,EAAQ,EAAI,CAAC,CAAC,CAAC,CAGvE,OAFA,EAAW,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAEvC,EAAW,QAAQ,EAAe,KACtB,EAAI,KAAM,GAAW,CACpC,IAAM,EAAM,EAAS,EAAQ,EAAI,CACjC,MAAO,CAAC,EAAI,WAAW,KAAK,EAAI,CAAC,EAAW,EAAI,EAAI,IAAQ,IAC5D,EACa,EAAI,KAAK,EAAI,CACrB,GACN,EAAE,CAAC,EA0BK,EACX,GACa,CACb,GAAM,CACJ,mBACA,iBAAiB,EAAE,CACnB,UACA,MAAM,IACJ,EAEE,EAAW,EAAiB,EAAiB,CAChD,OACE,GACC,OAAO,GAAY,UAAY,CAAC,EAAQ,WAAW,IAAI,CAC1D,CACA,IAAI,EAAU,CAEX,EAAkB,CACtB,GAAG,EAAiB,EAAe,CAEnC,GAAG,EAAiB,EAAiB,CAClC,OACE,GACC,OAAO,GAAY,UAAY,EAAQ,WAAW,IAAI,CACzD,CACA,IAAK,GAAY,EAAQ,MAAM,EAAE,CAAC,CACtC,CACE,OAAQ,GAA+B,OAAO,GAAY,SAAS,CACnE,IAAI,EAAU,CAEX,EAAQ,EAAoB,EAAiB,EAAQ,CAAC,CAE5D,OAAO,MAAM,KACX,IAAI,IACF,EAAM,QAAS,GACb,EAAG,KAAK,EAAU,CAChB,IAAK,EACL,OAAQ,EACR,SAAU,GACV,MACD,CAAC,CACH,CACF,CACF,EAWU,EACX,GACa,CACb,GAAM,CACJ,MAAO,CAAE,mBACT,OAAQ,CAAE,WACV,QAAS,CAAE,UAAS,kBACpB,SAAU,CAAE,mBACV,EAQJ,OAAO,EAAwB,CAC7B,iBAAkB,EAClB,eARsB,CAEtB,GAAG,EAAe,IAAK,GAAQ,OAAO,IAAM,CAC5C,GAAI,MAAM,QAAQ,EAAe,CAAG,EAAiB,CAAC,EAAe,CACtE,CAAC,OAAQ,GAAmB,OAAO,GAAM,SAAS,CAKjD,QAAS,CAAC,EAAS,GAAG,EAAQ,CAC9B,IAAK,GACN,CAAC"}
|
package/dist/esm/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Queue as e,pLimit as t}from"./pLimit.mjs";import{parallelize as n}from"./parallelize.mjs";import{getPathHash as r}from"./getPathHash.mjs";import{formatLocale as i,formatPath as a}from"./formatter.mjs";import{autoDecorateContent as o}from"./autoDecorateContent.mjs";import{
|
|
1
|
+
import{Queue as e,pLimit as t}from"./pLimit.mjs";import{parallelize as n}from"./parallelize.mjs";import{getPathHash as r}from"./getPathHash.mjs";import{formatLocale as i,formatPath as a}from"./formatter.mjs";import{autoDecorateContent as o}from"./autoDecorateContent.mjs";import{buildComponentFilesList as s}from"./buildComponentFilesList.mjs";import{splitTextByLines as c}from"./splitTextByLine.mjs";import{getChunk as l}from"./getChunk.mjs";import{assembleJSON as u,chunkJSON as d,reconstructFromSingleChunk as f}from"./chunkJSON.mjs";import{getContentExtension as p}from"./getContentExtension.mjs";import{getExtensionFromFormat as m,getFormatFromExtension as h}from"./getFormatFromExtension.mjs";import{mergeChunks as g}from"./mergeChunks.mjs";import{getGlobalLimiter as _,getTaskLimiter as v,parallelizeGlobal as y}from"./parallelizeGlobal.mjs";import{reduceObjectFormat as b}from"./reduceObjectFormat.mjs";import{resolveObjectPromises as x}from"./resolveObjectPromises.mjs";import{resolveRelativePath as S}from"./resolveRelativePath.mjs";import{runOnce as C}from"./runOnce.mjs";import{runParallel as w}from"./runParallel/index.mjs";import{sortAlphabetically as T}from"./sortAlphabetically.mjs";import{verifyIdenticObjectFormat as E}from"./verifyIdenticObjectFormat.mjs";export{e as Queue,u as assembleJSON,o as autoDecorateContent,s as buildComponentFilesList,d as chunkJSON,i as formatLocale,a as formatPath,l as getChunk,p as getContentExtension,m as getExtensionFromFormat,h as getFormatFromExtension,_ as getGlobalLimiter,r as getPathHash,v as getTaskLimiter,g as mergeChunks,t as pLimit,n as parallelize,y as parallelizeGlobal,f as reconstructFromSingleChunk,b as reduceObjectFormat,x as resolveObjectPromises,S as resolveRelativePath,C as runOnce,w as runParallel,T as sortAlphabetically,c as splitTextByLines,E as verifyIdenticObjectFormat};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LocalesValues } from "./intlayer/dist/types/index.js";
|
|
2
1
|
import * as _intlayer_types_dictionary0 from "@intlayer/types/dictionary";
|
|
3
2
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
3
|
import * as _intlayer_core_messageFormat0 from "@intlayer/core/messageFormat";
|
|
4
|
+
import * as _intlayer_types_module_augmentation0 from "@intlayer/types/module_augmentation";
|
|
5
5
|
|
|
6
6
|
//#region src/formatDictionary.d.ts
|
|
7
7
|
declare const formatDictionary: (dictionary: Dictionary) => Dictionary;
|
|
@@ -21,7 +21,7 @@ declare const formatDictionaryOutput: (dictionary: Dictionary) => Dictionary | {
|
|
|
21
21
|
version?: string;
|
|
22
22
|
filePath?: string;
|
|
23
23
|
tags?: string[];
|
|
24
|
-
locale?: LocalesValues;
|
|
24
|
+
locale?: _intlayer_types_module_augmentation0.LocalesValues;
|
|
25
25
|
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
26
26
|
fill?: _intlayer_types_dictionary0.Fill;
|
|
27
27
|
filled?: true;
|
|
@@ -45,7 +45,7 @@ declare const formatDictionariesOutput: (dictionaries: Dictionary[]) => (Diction
|
|
|
45
45
|
version?: string;
|
|
46
46
|
filePath?: string;
|
|
47
47
|
tags?: string[];
|
|
48
|
-
locale?: LocalesValues;
|
|
48
|
+
locale?: _intlayer_types_module_augmentation0.LocalesValues;
|
|
49
49
|
contentAutoTransformation?: _intlayer_types_dictionary0.ContentAutoTransformation;
|
|
50
50
|
fill?: _intlayer_types_dictionary0.Fill;
|
|
51
51
|
filled?: true;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/buildComponentFilesList.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Builds a deduplicated list of absolute file paths matching the given patterns.
|
|
6
|
+
*
|
|
7
|
+
* Handles multiple root directories (deduplicates overlapping roots), exclude
|
|
8
|
+
* patterns, negation patterns embedded in `transformPattern`, and optional
|
|
9
|
+
* dot-file inclusion.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Single root with excludes
|
|
13
|
+
* const files = buildComponentFilesList({
|
|
14
|
+
* transformPattern: 'src/**\/*.{ts,tsx}',
|
|
15
|
+
* excludePattern: ['**\/node_modules\/**'],
|
|
16
|
+
* baseDir: '/path/to/project',
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Multiple roots (e.g. baseDir + codeDir), dot files included
|
|
21
|
+
* const files = buildComponentFilesList(config, ['**\/node_modules\/**']);
|
|
22
|
+
*/
|
|
23
|
+
declare const buildComponentFilesList: (config: IntlayerConfig, excludePattern?: string[]) => string[];
|
|
24
|
+
//#endregion
|
|
25
|
+
export { buildComponentFilesList };
|
|
26
|
+
//# sourceMappingURL=buildComponentFilesList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildComponentFilesList.d.ts","names":[],"sources":["../../../src/utils/buildComponentFilesList.ts"],"mappings":";;;;;AAkDA;;;;;;;;;;;;;;;;;cAAa,uBAAA,GACX,MAAA,EAAQ,cAAA,EACR,cAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
|
|
1
3
|
//#region src/utils/buildFilesList.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Options for building the files list
|
|
4
6
|
*/
|
|
5
|
-
type
|
|
7
|
+
type BuildComponentFilesListOptions = {
|
|
6
8
|
/**
|
|
7
9
|
* Glob patterns to match files
|
|
8
10
|
*/
|
|
@@ -10,38 +12,51 @@ type BuildFilesListOptions = {
|
|
|
10
12
|
/**
|
|
11
13
|
* Glob patterns to exclude files
|
|
12
14
|
*/
|
|
13
|
-
excludePattern
|
|
15
|
+
excludePattern?: string | string[];
|
|
14
16
|
/**
|
|
15
|
-
* Base directory for file resolution
|
|
17
|
+
* Base directory (or directories) for file resolution.
|
|
18
|
+
* When multiple directories are provided, subdirectories of others are
|
|
19
|
+
* automatically deduplicated so files are never scanned twice.
|
|
16
20
|
*/
|
|
17
|
-
baseDir: string;
|
|
21
|
+
baseDir: string | string[];
|
|
22
|
+
/**
|
|
23
|
+
* Whether to include dot-prefixed files and directories (default: false)
|
|
24
|
+
*/
|
|
25
|
+
dot?: boolean;
|
|
18
26
|
};
|
|
19
27
|
/**
|
|
20
|
-
* Builds a list of
|
|
21
|
-
*
|
|
22
|
-
* This utility consolidates the file listing logic used across multiple compilers
|
|
23
|
-
* (Vue, Svelte, Vite) to avoid code duplication.
|
|
28
|
+
* Builds a deduplicated list of absolute file paths matching the given patterns.
|
|
24
29
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
30
|
+
* Handles multiple root directories (deduplicates overlapping roots), exclude
|
|
31
|
+
* patterns, negation patterns embedded in `transformPattern`, and optional
|
|
32
|
+
* dot-file inclusion.
|
|
27
33
|
*
|
|
28
34
|
* @example
|
|
29
|
-
* //
|
|
30
|
-
* const files =
|
|
35
|
+
* // Single root with excludes
|
|
36
|
+
* const files = buildComponentFilesList({
|
|
31
37
|
* transformPattern: 'src/**\/*.{ts,tsx}',
|
|
32
|
-
* excludePattern: ['**\/node_modules
|
|
38
|
+
* excludePattern: ['**\/node_modules\/**'],
|
|
33
39
|
* baseDir: '/path/to/project',
|
|
34
40
|
* });
|
|
35
41
|
*
|
|
36
42
|
* @example
|
|
37
|
-
* //
|
|
38
|
-
* const files =
|
|
39
|
-
* transformPattern:
|
|
40
|
-
*
|
|
41
|
-
*
|
|
43
|
+
* // Multiple roots (e.g. baseDir + codeDir), dot files included
|
|
44
|
+
* const files = buildComponentFilesList({
|
|
45
|
+
* transformPattern: config.build.traversePattern,
|
|
46
|
+
* baseDir: [config.system.baseDir, ...config.content.codeDir],
|
|
47
|
+
* dot: true,
|
|
42
48
|
* });
|
|
43
49
|
*/
|
|
44
|
-
declare const
|
|
50
|
+
declare const buildComponentFilesList: (config: BuildComponentFilesListOptions) => string[];
|
|
51
|
+
/**
|
|
52
|
+
* Convenience wrapper that derives all file-list options directly from an
|
|
53
|
+
* `IntlayerConfig` object.
|
|
54
|
+
*
|
|
55
|
+
* Scans `[baseDir, ...codeDir]` using `build.traversePattern`, excludes
|
|
56
|
+
* content declaration file extensions and any `compiler.excludePattern`
|
|
57
|
+
* entries defined in the configuration, and includes dot files.
|
|
58
|
+
*/
|
|
59
|
+
declare const buildComponentFilesListFromConfig: (intlayerConfig: IntlayerConfig) => string[];
|
|
45
60
|
//#endregion
|
|
46
|
-
export {
|
|
61
|
+
export { BuildComponentFilesListOptions, buildComponentFilesList, buildComponentFilesListFromConfig };
|
|
47
62
|
//# sourceMappingURL=buildFilesList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildFilesList.d.ts","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildFilesList.d.ts","names":[],"sources":["../../../src/utils/buildFilesList.ts"],"mappings":";;;;;AAOA;KAAY,8BAAA;;;;EAIV,gBAAA;EAUA;;;EANA,cAAA;EA6DW;;;;;EAvDX,OAAA;EAmID;;;EA/HC,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;cAmDW,uBAAA,GACX,MAAA,EAAQ,8BAAA;;;;;;;;;cAqDG,iCAAA,GACX,cAAA,EAAgB,cAAA"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Extension, Format, getExtensionFromFormat, getFormatFromExtension } from "./getFormatFromExtension.js";
|
|
2
2
|
import { autoDecorateContent } from "./autoDecorateContent.js";
|
|
3
|
-
import {
|
|
3
|
+
import { buildComponentFilesList } from "./buildComponentFilesList.js";
|
|
4
4
|
import { JSONObject, JsonChunk, assembleJSON, chunkJSON, reconstructFromSingleChunk } from "./chunkJSON.js";
|
|
5
5
|
import { formatLocale, formatPath } from "./formatter.js";
|
|
6
6
|
import { getChunk } from "./getChunk.js";
|
|
7
|
-
import { getComponentTransformPattern, getComponentTransformPatternSync } from "./getComponentTransformPattern.js";
|
|
8
7
|
import { getContentExtension } from "./getContentExtension.js";
|
|
9
8
|
import { getPathHash } from "./getPathHash.js";
|
|
10
9
|
import { mergeChunks } from "./mergeChunks.js";
|
|
@@ -19,4 +18,4 @@ import { ParallelHandle, runParallel } from "./runParallel/index.js";
|
|
|
19
18
|
import { sortAlphabetically } from "./sortAlphabetically.js";
|
|
20
19
|
import { splitTextByLines } from "./splitTextByLine.js";
|
|
21
20
|
import { verifyIdenticObjectFormat } from "./verifyIdenticObjectFormat.js";
|
|
22
|
-
export {
|
|
21
|
+
export { Extension, Format, JSONObject, JsonChunk, ParallelHandle, Queue, assembleJSON, autoDecorateContent, buildComponentFilesList, chunkJSON, formatLocale, formatPath, getChunk, getContentExtension, getExtensionFromFormat, getFormatFromExtension, getGlobalLimiter, getPathHash, getTaskLimiter, mergeChunks, pLimit, parallelize, parallelizeGlobal, reconstructFromSingleChunk, reduceObjectFormat, resolveObjectPromises, resolveRelativePath, runOnce, runParallel, sortAlphabetically, splitTextByLines, verifyIdenticObjectFormat };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.2",
|
|
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.2",
|
|
106
|
+
"@intlayer/config": "8.3.2",
|
|
107
|
+
"@intlayer/core": "8.3.2",
|
|
108
|
+
"@intlayer/dictionaries-entry": "8.3.2",
|
|
109
|
+
"@intlayer/remote-dictionaries-entry": "8.3.2",
|
|
110
|
+
"@intlayer/types": "8.3.2",
|
|
111
|
+
"@intlayer/unmerged-dictionaries-entry": "8.3.2",
|
|
112
112
|
"chokidar": "3.6.0",
|
|
113
113
|
"defu": "6.1.4",
|
|
114
114
|
"fast-glob": "3.3.3",
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
"zod-to-ts": "2.0.0"
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
|
-
"@types/node": "25.
|
|
120
|
+
"@types/node": "25.5.0",
|
|
121
121
|
"@utils/ts-config": "1.0.4",
|
|
122
122
|
"@utils/ts-config-types": "1.0.4",
|
|
123
123
|
"@utils/tsdown-config": "1.0.4",
|
|
124
124
|
"rimraf": "6.1.3",
|
|
125
125
|
"tsdown": "0.21.2",
|
|
126
126
|
"typescript": "5.9.3",
|
|
127
|
-
"vitest": "4.0
|
|
127
|
+
"vitest": "4.1.0",
|
|
128
128
|
"zod": "4.3.6"
|
|
129
129
|
},
|
|
130
130
|
"engines": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`node:path`),n=require(`fast-glob`);n=e.__toESM(n);const r=e=>{let n=Array.from(new Set(e.map(e=>(0,t.resolve)(e))));return n.sort((e,t)=>e.length-t.length),n.reduce((e,n)=>(e.some(e=>{let r=(0,t.relative)(e,n);return!r.startsWith(`..`)&&!(0,t.isAbsolute)(r)&&r!==``})||e.push(n),e),[])},i=async e=>{let{baseDir:t}=e.system,{codeDir:i}=e.content,{traversePattern:a}=e.build,o=r([t,...i]).map(e=>(0,n.default)(a,{cwd:e,absolute:!0,dot:!0})),s=(await Promise.all(o)).flat();return Array.from(new Set(s))},a=e=>{let{baseDir:t}=e.system,{codeDir:i}=e.content,{traversePattern:a}=e.build,o=r([t,...i]).flatMap(e=>n.default.sync(a,{cwd:e,absolute:!0,dot:!0}));return Array.from(new Set(o))};exports.getComponentTransformPattern=i,exports.getComponentTransformPatternSync=a;
|
|
2
|
-
//# sourceMappingURL=getComponentTransformPattern.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentTransformPattern.cjs","names":["fg"],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import { isAbsolute, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n\n // Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relativePath = relative(parent, dir);\n return (\n !relativePath.startsWith('..') && // It is inside the parent\n !isAbsolute(relativePath) && // It is not a different drive/root\n relativePath !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir } = intlayerConfig.system;\n const { codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir } = intlayerConfig.system;\n const { codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":"yLASA,MAAM,EAAuB,GAA6B,CAExD,IAAM,EAAa,MAAM,KAAK,IAAI,IAAI,EAAK,IAAK,IAAA,EAAA,EAAA,SAAgB,EAAI,CAAC,CAAC,CAAC,CAMvE,OAHA,EAAW,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAGvC,EAAW,QAAQ,EAAe,KACtB,EAAI,KAAM,GAAW,CACpC,IAAM,GAAA,EAAA,EAAA,UAAwB,EAAQ,EAAI,CAC1C,MACE,CAAC,EAAa,WAAW,KAAK,EAC9B,EAAA,EAAA,EAAA,YAAY,EAAa,EACzB,IAAiB,IAEnB,EAGA,EAAI,KAAK,EAAI,CAER,GACN,EAAE,CAAC,EAGK,EAA+B,KAC1C,IACsB,CACtB,GAAM,CAAE,WAAY,EAAe,OAC7B,CAAE,WAAY,EAAe,QAC7B,CAAE,mBAAoB,EAAe,MAKrC,EAFgB,EAAoB,CAAC,EAAS,GAAG,EAAQ,CAAC,CAEjB,IAAK,IAAA,EAAA,EAAA,SAC/C,EAAiB,CAClB,MACA,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAEK,GAAa,MAAM,QAAQ,IAAI,EAAyB,EAAE,MAAM,CAGtE,OAAO,MAAM,KAAK,IAAI,IAAI,EAAU,CAAC,EAG1B,EACX,GACa,CACb,GAAM,CAAE,WAAY,EAAe,OAC7B,CAAE,WAAY,EAAe,QAC7B,CAAE,mBAAoB,EAAe,MAKrC,EAFgB,EAAoB,CAAC,EAAS,GAAG,EAAQ,CAAC,CAEhC,QAAS,GACvCA,EAAAA,QAAG,KAAK,EAAiB,CACvB,MACA,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAED,OAAO,MAAM,KAAK,IAAI,IAAI,EAAU,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{isAbsolute as e,relative as t,resolve as n}from"node:path";import r from"fast-glob";const i=r=>{let i=Array.from(new Set(r.map(e=>n(e))));return i.sort((e,t)=>e.length-t.length),i.reduce((n,r)=>(n.some(n=>{let i=t(n,r);return!i.startsWith(`..`)&&!e(i)&&i!==``})||n.push(r),n),[])},a=async e=>{let{baseDir:t}=e.system,{codeDir:n}=e.content,{traversePattern:a}=e.build,o=i([t,...n]).map(e=>r(a,{cwd:e,absolute:!0,dot:!0})),s=(await Promise.all(o)).flat();return Array.from(new Set(s))},o=e=>{let{baseDir:t}=e.system,{codeDir:n}=e.content,{traversePattern:a}=e.build,o=i([t,...n]).flatMap(e=>r.sync(a,{cwd:e,absolute:!0,dot:!0}));return Array.from(new Set(o))};export{a as getComponentTransformPattern,o as getComponentTransformPatternSync};
|
|
2
|
-
//# sourceMappingURL=getComponentTransformPattern.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentTransformPattern.mjs","names":[],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import { isAbsolute, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n\n // Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relativePath = relative(parent, dir);\n return (\n !relativePath.startsWith('..') && // It is inside the parent\n !isAbsolute(relativePath) && // It is not a different drive/root\n relativePath !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir } = intlayerConfig.system;\n const { codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir } = intlayerConfig.system;\n const { codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":"2FASA,MAAM,EAAuB,GAA6B,CAExD,IAAM,EAAa,MAAM,KAAK,IAAI,IAAI,EAAK,IAAK,GAAQ,EAAQ,EAAI,CAAC,CAAC,CAAC,CAMvE,OAHA,EAAW,MAAM,EAAG,IAAM,EAAE,OAAS,EAAE,OAAO,CAGvC,EAAW,QAAQ,EAAe,KACtB,EAAI,KAAM,GAAW,CACpC,IAAM,EAAe,EAAS,EAAQ,EAAI,CAC1C,MACE,CAAC,EAAa,WAAW,KAAK,EAC9B,CAAC,EAAW,EAAa,EACzB,IAAiB,IAEnB,EAGA,EAAI,KAAK,EAAI,CAER,GACN,EAAE,CAAC,EAGK,EAA+B,KAC1C,IACsB,CACtB,GAAM,CAAE,WAAY,EAAe,OAC7B,CAAE,WAAY,EAAe,QAC7B,CAAE,mBAAoB,EAAe,MAKrC,EAFgB,EAAoB,CAAC,EAAS,GAAG,EAAQ,CAAC,CAEjB,IAAK,GAClD,EAAG,EAAiB,CAClB,MACA,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAEK,GAAa,MAAM,QAAQ,IAAI,EAAyB,EAAE,MAAM,CAGtE,OAAO,MAAM,KAAK,IAAI,IAAI,EAAU,CAAC,EAG1B,EACX,GACa,CACb,GAAM,CAAE,WAAY,EAAe,OAC7B,CAAE,WAAY,EAAe,QAC7B,CAAE,mBAAoB,EAAe,MAKrC,EAFgB,EAAoB,CAAC,EAAS,GAAG,EAAQ,CAAC,CAEhC,QAAS,GACvC,EAAG,KAAK,EAAiB,CACvB,MACA,SAAU,GACV,IAAK,GACN,CAAC,CACH,CAED,OAAO,MAAM,KAAK,IAAI,IAAI,EAAU,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/getComponentTransformPattern.d.ts
|
|
4
|
-
declare const getComponentTransformPattern: (intlayerConfig: IntlayerConfig) => Promise<string[]>;
|
|
5
|
-
declare const getComponentTransformPatternSync: (intlayerConfig: IntlayerConfig) => string[];
|
|
6
|
-
//#endregion
|
|
7
|
-
export { getComponentTransformPattern, getComponentTransformPatternSync };
|
|
8
|
-
//# sourceMappingURL=getComponentTransformPattern.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentTransformPattern.d.ts","names":[],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"mappings":";;;cAkCa,4BAAA,GACX,cAAA,EAAgB,cAAA,KACf,OAAA;AAAA,cAsBU,gCAAA,GACX,cAAA,EAAgB,cAAA"}
|