@flatjs/evolve 2.1.0-next.17 → 2.1.0-next.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/helpers/custom-listr-renderer.js +1 -1
- package/dist/helpers/format-spinner-text.d.ts +7 -0
- package/dist/helpers/format-spinner-text.js +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +1 -1
- package/dist/main/start-build-dynamic.js +1 -1
- package/dist/main/start-build.js +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
import logUpdate from"log-update";import process from"node:process";import{chalk}from"@flatjs/common";const startFrames="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];let startIndex=0;export class CustomListrRenderer{constructor(t){this._tasks=[],this.renderTask=()=>{const t=[];startIndex=++startIndex%startFrames.length;const e=startFrames[startIndex];for(const s of this._tasks)s.isCompleted()?t.push(`${chalk(["green"])("✔")} ${this.formatTextByTemp(s.title,"successfully")}`):s.hasFailed()?t.push(`${chalk(["red"])("✘")} ${this.formatTextByTemp(s.title,"failed")}`):s.isSkipped()?t.push(`${chalk(["gray"])("ℹ")} ${this.formatTextByTemp(s.title,"skipped")}`):t.push(`${chalk(["cyan"])(e)} ${this.formatTextByTemp(s.title,"building")}`);logUpdate(t.join("\n"))},this._tasks=t}static get nonTTY(){return!0}render(){this._id||(this._id=setInterval((()=>{this.renderTask()}),100))}end(){this._id&&(clearInterval(this._id),this._id=void 0),this.renderTask(),logUpdate.done()}formatTextByTemp(t,e,s="$STATUS"){const r={successfully
|
1
|
+
import logUpdate from"log-update";import process from"node:process";import{chalk}from"@flatjs/common";const startFrames="win32"===process.platform?["-","\\","|","/"]:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"];let startIndex=0;export class CustomListrRenderer{constructor(t){this._tasks=[],this.renderTask=()=>{const t=[];startIndex=++startIndex%startFrames.length;const e=startFrames[startIndex];for(const s of this._tasks)s.isCompleted()?t.push(`${chalk(["green"])("✔")} ${this.formatTextByTemp(s.title,"successfully")}`):s.hasFailed()?t.push(`${chalk(["red"])("✘")} ${this.formatTextByTemp(s.title,"failed")}`):s.isSkipped()?t.push(`${chalk(["gray"])("ℹ")} ${this.formatTextByTemp(s.title,"skipped")}`):t.push(`${chalk(["cyan"])(e)} ${this.formatTextByTemp(s.title,"building")}`);logUpdate(t.join("\n"))},this._tasks=t}static get nonTTY(){return!0}render(){this._id||(this._id=setInterval((()=>{this.renderTask()}),100))}end(){this._id&&(clearInterval(this._id),this._id=void 0),this.renderTask(),logUpdate.done()}formatTextByTemp(t,e,s="$STATUS"){const r={successfully:`${chalk(["green"])("done")}`,failed:`builded ${chalk(["red"])("failed")}`,skipped:`builded ${chalk(["gray"])("skipped")}`,building:chalk(["white"])("compiling...")};return t.replace(s,r[e])}}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{chalk}from"@flatjs/common";export const formatSpinnerText=(n=[])=>{if(1===n.length)return` ${chalk(["blue"])("●")} ${n[0]} \n`;return n.map(((t,e)=>{let r="├";return 0===e?r="┌":e===n.length-1&&(r="└"),` ${chalk(["blue"])(r)} ${t} \n`})).join("")};
|
package/dist/helpers/index.d.ts
CHANGED
@@ -6,6 +6,7 @@ export * from './custom-listr-renderer.js';
|
|
6
6
|
export * from './delete-object-keys.js';
|
7
7
|
export * from './enable-bundle-hashname-for-module.js';
|
8
8
|
export * from './flat-entry-map.js';
|
9
|
+
export * from './format-spinner-text.js';
|
9
10
|
export * from './get-bundle-file-name.js';
|
10
11
|
export * from './get-html-plugin-config.js';
|
11
12
|
export * from './get-pacakge-dir.js';
|
package/dist/helpers/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export*from"./allow-px2rem-for-module.js";export*from"./assert-group-entry-item.js";export*from"./assert-single-compiler.js";export*from"./chunk-entry-map.js";export*from"./custom-listr-renderer.js";export*from"./delete-object-keys.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./flat-entry-map.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./get-runtime-cdn-base.js";export*from"./is-deep-equal.js";export*from"./json-serializer.js";export*from"./merge-babel-options.js";export*from"./normalize-check-entry-options.js";export*from"./normalize-entry-map.js";export*from"./normalize-group-name.js";export*from"./normalize-page-proxy.js";export*from"./normalize-resolve-alias.js";export*from"./normalize-template-inject-tokens.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-entry-group.js";export*from"./verify-group-entry-options.js";
|
1
|
+
export*from"./allow-px2rem-for-module.js";export*from"./assert-group-entry-item.js";export*from"./assert-single-compiler.js";export*from"./chunk-entry-map.js";export*from"./custom-listr-renderer.js";export*from"./delete-object-keys.js";export*from"./enable-bundle-hashname-for-module.js";export*from"./flat-entry-map.js";export*from"./format-spinner-text.js";export*from"./get-bundle-file-name.js";export*from"./get-html-plugin-config.js";export*from"./get-pacakge-dir.js";export*from"./get-runtime-cdn-base.js";export*from"./is-deep-equal.js";export*from"./json-serializer.js";export*from"./merge-babel-options.js";export*from"./normalize-check-entry-options.js";export*from"./normalize-entry-map.js";export*from"./normalize-group-name.js";export*from"./normalize-page-proxy.js";export*from"./normalize-resolve-alias.js";export*from"./normalize-template-inject-tokens.js";export*from"./open-page.js";export*from"./print-log.js";export*from"./refresh-evolve-mock-options.js";export*from"./script-injects.js";export*from"./should-enable-react-fast-refresh.js";export*from"./split-to-entry-group.js";export*from"./verify-group-entry-options.js";
|
@@ -1 +1 @@
|
|
1
|
-
import Listr from"listr";import{isAbsolute,join}from"node:path";import{getCommitIdOfBranch,getDiffFiles}from"@armit/git";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys,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{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";export async function getBuildEntryFiles(e,r,t,o,i){const n=[],s=[];for(const e of t)r.includes(e)?n.push(e):s.push(e);if(i&&logger.info("Use custom graph traverse filter",moduleName),s.length){const t=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:i||(()=>!0),lessImportOptions:{projectCwd:e,aliases:o}});if(!t)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(t,null,2)}`);for(const e of s){const o=t[e]||[];arraysIntersect(o,r)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,r,t,o,i){const n={projectCwd:e,command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,o,i);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 ..."),!r){const e=s.ci?.basedBranch||"origin/master";r=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${r}" ...`)}let a=r?await getDiffFiles(r,t):[];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
|
1
|
+
import Listr from"listr";import{isAbsolute,join}from"node:path";import{getCommitIdOfBranch,getDiffFiles}from"@armit/git";import{arraysIntersect,chalk,logger,requireResolve}from"@flatjs/common";import{traverseGraph}from"@flatjs/graph";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys,moduleName}from"../constants.js";import{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByEntryInputs,filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{formatSpinnerText}from"../helpers/format-spinner-text.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{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{resolveEntryMapInputFiles}from"../helpers/resolve-entry-map-input-files.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";export async function getBuildEntryFiles(e,r,t,o,i){const n=[],s=[];for(const e of t)r.includes(e)?n.push(e):s.push(e);if(i&&logger.info("Use custom graph traverse filter",moduleName),s.length){const t=await traverseGraph({input:s,projectCwd:e,treeNodeFilter:i||(()=>!0),lessImportOptions:{projectCwd:e,aliases:o}});if(!t)return n;logger.debug(`DependencyGraph:\n${JSON.stringify(t,null,2)}`);for(const e of s){const o=t[e]||[];arraysIntersect(o,r)&&n.push(e)}}return n}export async function dynamicCheckBuildEntryMap(e,r,t,o,i){const n={projectCwd:e,command:"build",resolve:requireResolve},s=await loadEvolveConfig(n,e,o,i);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 ..."),!r){const e=s.ci?.basedBranch||"origin/master";r=await getCommitIdOfBranch(e),logger.info(`Resolving base branch "${e}" commit hash "${r}" ...`)}let a=r?await getDiffFiles(r,t):[];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 p=await resolveEntryMapInputFiles(e,s.entryMap),c=await getBuildEntryFiles(e,a,p,s.webpack?.resolve?.alias,s.ci?.graphTreeNodeFilter);logger.debug(`To build entry files: \n${JSON.stringify(c,null,2)}`);return{buildEntries:await filterActivedEntriesByEntryInputs(e,s.entryMap,c),newEvolveOptions:s}}export const startDynamicBuild=async(e,r,t,o={},i)=>{const{buildEntries:n,newEvolveOptions:s}=await dynamicCheckBuildEntryMap(e,r,t,o,i);await envVerify(e,s);const a=normalizeEvolveEntryMap(n,s.entryMap),l=splitToEntryGroup(a,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:p={}}=s,c=getMaxProcessTasks(l.length,p?.maxThreads);logger.info(`Start dynamic build with (${chalk(["magenta"])(String(c))}) workers`);const m=createThreadWorker({...p,maxThreads:c}),d=new Listr([],{concurrent:c,exitOnError:!0,renderer:CustomListrRenderer}),f=[];for(const r of l){const t=Object.values(r)?.[0]?.groupName||"",n=Object.keys(r);d.add({title:`Group ${chalk(["magenta"])(t)} $STATUS \n${formatSpinnerText(n)}`,task:async()=>{const r=await m.startBuildWorker({projectCwd:e,entryKeys:n,serializedEvolveOptions:jsonSerializer.stringify(o),configLoaderOptions:i});f.push(r)}})}if(d.tasks.length)try{await d.run()}catch(e){throw m.terminate(),e}return m.terminate(),f};
|
package/dist/main/start-build.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import Listr from"listr";import{chalk,logger,requireResolve}from"@flatjs/common";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys}from"../constants.js";import{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";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{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";export const startBuild=async(r,e,t={},o)=>{const i={projectCwd:r,command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,r,t,o);await envVerify(r,s);const a=filterActivedEntriesByModule(s.entryMap,e),n=normalizeEvolveEntryMap(a,s.entryMap),l=splitToEntryGroup(n,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:m={}}=s,p=getMaxProcessTasks(l.length,m?.maxThreads);logger.info(`Start standard build with (${chalk(["magenta"])(String(p))}) workers`);const c=createThreadWorker({...m,maxThreads:p}),d=new Listr([],{concurrent:p,exitOnError:!0,renderer:CustomListrRenderer}),f=[];for(const e of l){const i=Object.values(e)?.[0]?.groupName||"",s=Object.keys(e)
|
1
|
+
import Listr from"listr";import{chalk,logger,requireResolve}from"@flatjs/common";import{createGlobalCompiler}from"../compiler/create-global-compiler.js";import{ignoreEntryOptionKeys}from"../constants.js";import{CustomListrRenderer}from"../helpers/custom-listr-renderer.js";import{filterActivedEntriesByModule}from"../helpers/filter-actived-entries.js";import{formatSpinnerText}from"../helpers/format-spinner-text.js";import{getMaxProcessTasks}from"../helpers/get-max-process-tasks.js";import{jsonSerializer}from"../helpers/json-serializer.js";import{normalizeEvolveEntryMap}from"../helpers/normalize-entry-map.js";import{splitToEntryGroup}from"../helpers/split-to-entry-group.js";import{loadEvolveConfig}from"../load-config/load-evolve-config.js";import{createThreadWorker}from"./create-thread-worker.js";import{envVerify}from"./env-verify.js";export const startBuild=async(r,e,t={},o)=>{const i={projectCwd:r,command:"build",resolve:requireResolve},s=await loadEvolveConfig(i,r,t,o);await envVerify(r,s);const a=filterActivedEntriesByModule(s.entryMap,e),n=normalizeEvolveEntryMap(a,s.entryMap),l=splitToEntryGroup(n,s,ignoreEntryOptionKeys,!1);if(!l.length)return logger.warn("No build entries provided!"),[];await createGlobalCompiler(!1,s);const{threads:m={}}=s,p=getMaxProcessTasks(l.length,m?.maxThreads);logger.info(`Start standard build with (${chalk(["magenta"])(String(p))}) workers`);const c=createThreadWorker({...m,maxThreads:p}),d=new Listr([],{concurrent:p,exitOnError:!0,renderer:CustomListrRenderer}),f=[];for(const e of l){const i=Object.values(e)?.[0]?.groupName||"",s=Object.keys(e);d.add({title:`Group ${chalk(["magenta"])(i)} $STATUS \n${formatSpinnerText(s)}`,task:async()=>{const e=await c.startBuildWorker({projectCwd:r,entryKeys:s,serializedEvolveOptions:jsonSerializer.stringify(t),configLoaderOptions:o});f.push(e)}})}if(d.tasks.length)try{await d.run()}catch(r){throw c.terminate(),r}return c.terminate(),f};
|