@flatjs/evolve 1.8.1-next.86 → 1.8.1-next.88
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/define-config/define-config.d.ts +17 -0
- package/dist/main/start-build-dynamic.js +1 -1
- package/dist/main/start-build-worker.js +1 -1
- package/dist/main/start-build.js +1 -1
- package/dist/main/start-serve.js +1 -1
- package/dist/main/start-static.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @flatjs/evolve
|
2
2
|
|
3
|
+
## 1.8.1-next.88
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- b4f60b0: Expose `env`.`resolve` to allow dynamic resolve `esm` node modules from `flatjs-evolve.config.ts`
|
8
|
+
|
9
|
+
## 1.8.1-next.87
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- 9561920: bump `armit/git`` fix wrong requirements check issue
|
14
|
+
|
3
15
|
## 1.8.1-next.86
|
4
16
|
|
5
17
|
### Patch Changes
|
@@ -1,7 +1,24 @@
|
|
1
1
|
import { type UserConfigExport, type ConfigEnvBase } from '@armit/config-loader';
|
2
|
+
import { type requireResolve } from '@flatjs/common';
|
2
3
|
import { type PartialDeep } from 'type-fest';
|
3
4
|
import { type FlatEvolveOptions } from '../types/types-options.js';
|
4
5
|
export interface EvolveConfigBase extends ConfigEnvBase {
|
5
6
|
command: 'build' | 'serve' | 'static';
|
7
|
+
/**
|
8
|
+
* Expose `env`.`resolve` to allow dynamic resolve `esm` node modules from `flatjs-evolve.config.ts`
|
9
|
+
* @example
|
10
|
+
* ```ts
|
11
|
+
* export default defineConfig((env) => {
|
12
|
+
* console.log(env.resolve(import.meta.url, 'tailwindcss'));
|
13
|
+
* ...
|
14
|
+
* }
|
15
|
+
* // Note may you need to change `module` to `ESNext` at your `tsconfig.json`
|
16
|
+
* `tsconfig.json`
|
17
|
+
* {
|
18
|
+
* "module": "ESNext"
|
19
|
+
* }
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
resolve: typeof requireResolve;
|
6
23
|
}
|
7
24
|
export declare const defineConfig: (userConfig: UserConfigExport<PartialDeep<FlatEvolveOptions>, EvolveConfigBase>) => UserConfigExport<import("type-fest/source/partial-deep.js").PartialObjectDeep<FlatEvolveOptions, {}>, EvolveConfigBase>;
|
@@ -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}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){const o=[],n=[];for(const e of r)t.includes(e)?o.push(e):n.push(e);if(n.length){const r=await traverseGraph({input:n,projectCwd:e,treeNodeFilter:()=>!0,lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return o;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of n){const i=r[e]||[];arraysIntersect(i,t)&&o.push(e)}}return o}export async function dynamicCheckBuildEntryMap(e,t,r,i,o){const n=
|
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){const o=[],n=[];for(const e of r)t.includes(e)?o.push(e):n.push(e);if(n.length){const r=await traverseGraph({input:n,projectCwd:e,treeNodeFilter:()=>!0,lessImportOptions:{projectCwd:e,aliases:i}});if(!r)return o;logger.debug(`DependencyGraph:\n${JSON.stringify(r,null,2)}`);for(const e of n){const i=r[e]||[];arraysIntersect(i,t)&&o.push(e)}}return o}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||"master";logger.info(`Resolving base branch "${e}" commit hash ...`),t=await getCommitIdOfBranch(e)}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);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 +1 @@
|
|
1
|
-
import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export const startBuildWorker=async(e,r,o,i)=>{const t=jsonSerializer.parse(o)||{},
|
1
|
+
import{requireResolve}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareBuild}from"./prepare-build.js";export const startBuildWorker=async(e,r,o,i)=>{const l={command:"build",resolve:requireResolve},t=jsonSerializer.parse(o)||{},n=await loadEvolveConfig(l,e,t,i),a=filterActivedEntriesByModule(n.entryMap,[new RegExp(`^${r}$`)]);if(!Object.keys(a).length)throw new Error(`No build entry resolved via "${r}" on "startBuildWorker"!`);const s=normalizeEvolveEntryMap(a,n.entryMap)[r];return prepareBuild([r,s],n)};
|
package/dist/main/start-build.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{createThreadPool}from"@armit/worker-threads";import{chalk,logger}from"@flatjs/common";import Listr from"listr";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export const startBuild=async(r,
|
1
|
+
import{createThreadPool}from"@armit/worker-threads";import{chalk,logger,requireResolve}from"@flatjs/common";import Listr from"listr";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{envVerify}from"./env-verify.js";import{getWorkerPath}from"./get-worker-path.js";export const startBuild=async(e,r,t={},o)=>{const i={command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,e,t,o);await envVerify(e,s);const a=filterActivedEntriesByModule(s.entryMap,r),n=Object.keys(a);if(!n.length)return logger.warn("No build entries providered!"),[];const l=getMaxProcessTasks(n.length,s.maxProcesses);logger.info(`Start standard build with (${chalk(["magenta"])(String(l))}) workers:\n${JSON.stringify({buildEntries:n},null,2)}`);const c=getWorkerPath(),m=await createThreadPool(c,{size:l}),d=new Listr([],{concurrent:l,exitOnError:!0}),f=[];for(const[r]of Object.entries(a))d.add({title:`Build module ${chalk(["magenta"])(r)} ...`,task:async()=>{const i=await m.startBuildWorker(e,r,jsonSerializer.stringify(t),o);f.push(i)}});return d.tasks.length&&await d.run(),m.pool.terminate(),f};
|
package/dist/main/start-serve.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{logger}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareServe}from"./prepare-serve.js";export const startServe=async(e,r,o={},t)=>{const
|
1
|
+
import{logger,requireResolve}from"@flatjs/common";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareServe}from"./prepare-serve.js";export const startServe=async(e,r,o={},t)=>{const i={command:"serve",resolve:requireResolve},n=await loadEvolveConfig(i,e,o,t),l=filterActivedEntriesByModule(n.entryMap,r),s=Object.keys(l);if(!s.length)return logger.warn("No served entries providered!"),[];logger.info({servedEntries:s});const v=normalizeEvolveEntryMap(l,n.entryMap);return prepareServe(e,v,n)};
|
@@ -1 +1 @@
|
|
1
|
-
import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,
|
1
|
+
import{requireResolve}from"@flatjs/common";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{prepareStatic}from"./prepare-static.js";export const startStatic=async(o,e={},r)=>{const t={command:"static",resolve:requireResolve},a=await loadEvolveConfig(t,o,e,r);return prepareStatic(o,a)};
|
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.88",
|
4
4
|
"license": "MIT",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"dependencies": {
|
40
40
|
"@armit/config-loader": "^0.0.48",
|
41
41
|
"@armit/file-utility": "^0.0.27",
|
42
|
-
"@armit/git": "^0.0.
|
42
|
+
"@armit/git": "^0.0.34",
|
43
43
|
"@armit/package": "^0.0.42",
|
44
44
|
"@armit/worker-threads": "^0.0.4",
|
45
45
|
"@babel/core": "7.22.9",
|