@flatjs/evolve 1.8.1-next.104 → 1.8.1-next.105
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# @flatjs/evolve
|
2
2
|
|
3
|
+
## 1.8.1-next.105
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 9be1d2d: expose `defineConfig` with correct typings export
|
8
|
+
- Updated dependencies [9be1d2d]
|
9
|
+
- @flatjs/mock@1.8.1-next.79
|
10
|
+
- @flatjs/graph@1.8.1-next.55
|
11
|
+
|
3
12
|
## 1.8.1-next.104
|
4
13
|
|
5
14
|
### Patch Changes
|
@@ -21,4 +21,6 @@ export interface EvolveConfigBase extends ConfigEnvBase {
|
|
21
21
|
*/
|
22
22
|
resolve: typeof requireResolve;
|
23
23
|
}
|
24
|
-
|
24
|
+
type DefineConfigFn = (userConfig: UserConfigExport<PartialDeep<FlatEvolveOptions>, EvolveConfigBase>) => UserConfigExport<PartialDeep<FlatEvolveOptions>, EvolveConfigBase>;
|
25
|
+
export declare const defineConfig: DefineConfigFn;
|
26
|
+
export {};
|
@@ -1 +1 @@
|
|
1
|
-
import{isAbsolute,join}from"node:path";import{getDiffFiles,getCommitIdOfBranch}from"@armit/git";import{createThreadPool}from"@armit/worker-threads";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import Listr from"listr";import{filterActivedEntriesByEntryInputs,filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getGitRoot}from"../helpers/get-git-root.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export async function getBuildEntryFiles(e,t,r,i,o){const n=[],s=[];for(const e of r)t.includes(e)?n.push(e):s.push(e);if(s.length){const r=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:o||(()=>!0),lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of s){const i=r[e]||[];arraysIntersect(i,t)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,t,r,i,o){const n={command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,i,o);if(s.ci?.fixedBuildModules&&s.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(s.entryMap,s.ci?.fixedBuildModules),newEvolveOptions:s}}if(logger.info("Dynamicly checking code changed modules ..."),!t){const e=s.ci?.basedBranch||"origin/master";t=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${t}" ...`)}let a=t?await getDiffFiles(t,r):[];const l=getGitRoot(e);if(!l)throw new Error(`No .git root (${e}) found`);if(a=a.map((e=>isAbsolute(e)?e:join(l,e))),logger.debug(`Diff files: \n${JSON.stringify(a,null,2)}`),!a.length)return logger.warn("It seems that there are no code files changed."),{buildEntries:{},newEvolveOptions:s};const c=await resolveEntryMapInputFiles(e,s.entryMap),d=await getBuildEntryFiles(e,a,c,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(d,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,d),newEvolveOptions:s}}export const startDynamicBuild=async(e,t,r,i={},o)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,t,r,i,o);await envVerify(e,s);const a=Object.keys(n);if(!a.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(a.length,s.maxProcesses);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:a},null,2)}`);const c=getWorkerPath(),d=await createThreadPool(c,{size:l}),f=new Listr([],{concurrent:l,exitOnError:!0}),g=[];for(const[t]of Object.entries(n))f.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await d.startBuildWorker(e,t,jsonSerializer.stringify(i),o);g.push(r)}});return f.tasks.length&&await f.run(),d.pool.terminate(),g};
|
1
|
+
import{isAbsolute,join}from"node:path";import{getDiffFiles,getCommitIdOfBranch}from"@armit/git";import{createThreadPool}from"@armit/worker-threads";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import Listr from"listr";import{moduleName}from"../constants.js";import{filterActivedEntriesByEntryInputs,filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getGitRoot}from"../helpers/get-git-root.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export async function getBuildEntryFiles(e,t,r,i,o){const n=[],s=[];for(const e of r)t.includes(e)?n.push(e):s.push(e);if(o&&logger.info("Use custom graph traverse filter",moduleName),s.length){const r=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:o||(()=>!0),lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of s){const i=r[e]||[];arraysIntersect(i,t)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,t,r,i,o){const n={command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,i,o);if(s.ci?.fixedBuildModules&&s.ci?.fixedBuildModules.length){logger.info("Use `fixedBuildModules` configuration to build...");return{buildEntries:filterActivedEntriesByModule(s.entryMap,s.ci?.fixedBuildModules),newEvolveOptions:s}}if(logger.info("Dynamicly checking code changed modules ..."),!t){const e=s.ci?.basedBranch||"origin/master";t=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${t}" ...`)}let a=t?await getDiffFiles(t,r):[];const l=getGitRoot(e);if(!l)throw new Error(`No .git root (${e}) found`);if(a=a.map((e=>isAbsolute(e)?e:join(l,e))),logger.debug(`Diff files: \n${JSON.stringify(a,null,2)}`),!a.length)return logger.warn("It seems that there are no code files changed."),{buildEntries:{},newEvolveOptions:s};const c=await resolveEntryMapInputFiles(e,s.entryMap),d=await getBuildEntryFiles(e,a,c,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(d,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,d),newEvolveOptions:s}}export const startDynamicBuild=async(e,t,r,i={},o)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,t,r,i,o);await envVerify(e,s);const a=Object.keys(n);if(!a.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(a.length,s.maxProcesses);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:a},null,2)}`);const c=getWorkerPath(),d=await createThreadPool(c,{size:l}),f=new Listr([],{concurrent:l,exitOnError:!0}),g=[];for(const[t]of Object.entries(n))f.add({title:`Build module ${chalk(["magenta"])(t)} ...`,task:async()=>{const r=await d.startBuildWorker(e,t,jsonSerializer.stringify(i),o);g.push(r)}});return f.tasks.length&&await f.run(),d.pool.terminate(),g};
|
package/dist/types/types-ci.d.ts
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
export type FlatEvolveCI = {
|
8
8
|
/**
|
9
9
|
* A function used to determine if a module (also include root node) should be included in the dependency tree
|
10
|
+
* it should not work if you have `fixedBuildModules` definition.
|
10
11
|
* @param moduleId The imported module
|
11
12
|
* @default `() => true`
|
12
13
|
*/
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@flatjs/evolve",
|
3
|
-
"version": "1.8.1-next.
|
3
|
+
"version": "1.8.1-next.105",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -46,8 +46,8 @@
|
|
46
46
|
"@flatjs/common": "1.8.1-next.37",
|
47
47
|
"@flatjs/evolve-preset-babel": "1.8.1-next.22",
|
48
48
|
"@flatjs/forge-postcss-plugin-pixel": "1.8.1-next.37",
|
49
|
-
"@flatjs/graph": "1.8.1-next.
|
50
|
-
"@flatjs/mock": "1.8.1-next.
|
49
|
+
"@flatjs/graph": "1.8.1-next.55",
|
50
|
+
"@flatjs/mock": "1.8.1-next.79",
|
51
51
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
52
52
|
"@types/babel__core": "7.20.1",
|
53
53
|
"babel-loader": "9.1.3",
|