@xylabs/ts-scripts-yarn3 4.0.1 → 4.0.3
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/actions/build.mjs +3 -1
- package/dist/actions/build.mjs.map +1 -1
- package/dist/actions/compile.mjs +9 -7
- package/dist/actions/compile.mjs.map +1 -1
- package/dist/actions/index.mjs +29 -21
- package/dist/actions/index.mjs.map +1 -1
- package/dist/actions/package/compile/compile.mjs +17 -13
- package/dist/actions/package/compile/compile.mjs.map +1 -1
- package/dist/actions/package/compile/index.mjs +17 -13
- package/dist/actions/package/compile/index.mjs.map +1 -1
- package/dist/actions/package/compile/packageCompileTsup.mjs +15 -11
- package/dist/actions/package/compile/packageCompileTsup.mjs.map +1 -1
- package/dist/actions/package/index.mjs +17 -13
- package/dist/actions/package/index.mjs.map +1 -1
- package/dist/actions/package/recompile.mjs +17 -13
- package/dist/actions/package/recompile.mjs.map +1 -1
- package/dist/bin/package/build.mjs +551 -0
- package/dist/bin/package/build.mjs.map +1 -0
- package/dist/bin/package/compile-only.mjs +17 -13
- package/dist/bin/package/compile-only.mjs.map +1 -1
- package/dist/bin/package/compile-tsup.mjs +15 -11
- package/dist/bin/package/compile-tsup.mjs.map +1 -1
- package/dist/bin/package/compile.mjs +17 -13
- package/dist/bin/package/compile.mjs.map +1 -1
- package/dist/bin/package/recompile.mjs +17 -13
- package/dist/bin/package/recompile.mjs.map +1 -1
- package/dist/bin/xy-ts.mjs +26 -12
- package/dist/bin/xy-ts.mjs.map +1 -1
- package/dist/bin/xy.mjs +26 -12
- package/dist/bin/xy.mjs.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.mjs +43 -25
- package/dist/index.mjs.map +1 -1
- package/dist/xy/index.mjs +26 -12
- package/dist/xy/index.mjs.map +1 -1
- package/dist/xy/xy.mjs +26 -12
- package/dist/xy/xy.mjs.map +1 -1
- package/dist/xy/xyBuildCommands.mjs +17 -12
- package/dist/xy/xyBuildCommands.mjs.map +1 -1
- package/dist/xy/xyParseOptions.mjs +9 -0
- package/dist/xy/xyParseOptions.mjs.map +1 -1
- package/package.json +5 -4
- package/src/actions/build.ts +1 -1
- package/src/actions/compile.ts +22 -7
- package/src/actions/package/compile/compile.ts +2 -2
- package/src/actions/package/compile/packageCompileTsup.ts +18 -4
- package/src/bin/package/build.ts +16 -0
- package/src/xy/xyBuildCommands.ts +5 -4
- package/src/xy/xyParseOptions.ts +7 -0
package/dist/actions/build.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/build.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runStepsAsync.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runStepsAsync } from '../lib/index.ts'\n\nexport interface BuildParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const build = async ({\n incremental, jobs, target, verbose, pkg,\n}: BuildParams) => {\n const start = Date.now()\n const pkgOptions = pkg ? [pkg] : [] // must go first\n const incrementalOptions = incremental ? ['-i'] : []\n const verboseOptions = verbose ? ['-v'] : []\n const targetOptions = target ? ['-t', target] : []\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = await runStepsAsync(`Build${incremental ? '-Incremental' : ''} [${pkg ?? 'All'}]`, [\n ['yarn', ['xy', 'compile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'lint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'deps', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ])\n console.log(`${chalk.gray('Built in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => ex.name !== undefined && ex.message !== undefined,\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport type { ScriptStep } from './runSteps.ts'\nimport { safeExitAsync } from './safeExit.ts'\n\nexport const runStepAsync = (name: string, step: ScriptStep, exitOnFail = true, message?: string) => {\n return new Promise<number>((resolve) => {\n const [command, args, config] = step\n if (message) {\n console.log(chalk.gray(message))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n spawn(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).on('close', (code) => {\n if (code) {\n console.error(\n chalk.red(\n `Command Exited With Non-Zero Result [${chalk.gray(code)}] | ${chalk.yellow(command)} ${chalk.white(\n Array.isArray(args) ? args.join(' ') : args,\n )}`,\n ),\n )\n checkResult(name, code, 'error', exitOnFail)\n resolve(code)\n } else {\n resolve(0)\n }\n })\n })\n}\n\nexport const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {\n return await safeExitAsync(async () => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let result = 0\n for (const [i, step] of steps.entries()) {\n result += await runStepAsync(name, step, exitOnFail, messages?.[i])\n }\n return result\n })\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxD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AACDI,UAAQC,IAAI,GAAGC,OAAMI,KAAK,UAAA,CAAA,KAAgBJ,OAAMK,UAAUd,KAAKC,IAAG,IAAKF,SAAS,KAAMgB,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AAC7H,SAAOF;AACT,GApBqB;","names":["chalk","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","undefined","message","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExitAsync","func","exitOnFail","result","process","exit","ex","processEx","spawn","existsSync","chalk","runStepAsync","name","step","exitOnFail","message","Promise","resolve","command","args","config","console","log","chalk","gray","argList","Array","isArray","split","existsSync","Error","spawn","env","FORCE_COLOR","process","shell","stdio","on","code","error","red","yellow","white","join","checkResult","runStepsAsync","steps","messages","safeExitAsync","pkgName","npm_package_name","green","result","i","entries","build","incremental","jobs","target","verbose","pkg","start","Date","now","pkgOptions","incrementalOptions","verboseOptions","targetOptions","jobsOptions","console","log","chalk","blue","result","runStepsAsync","gray","magenta","toFixed"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/build.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runStepsAsync.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runStepsAsync } from '../lib/index.ts'\n\nexport interface BuildParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const build = async ({\n incremental, jobs, target, verbose, pkg,\n}: BuildParams) => {\n const start = Date.now()\n const pkgOptions = pkg ? [pkg] : [] // must go first\n const incrementalOptions = incremental ? ['-i'] : []\n const verboseOptions = verbose ? ['-v'] : []\n const targetOptions = target ? ['-t', target] : []\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = await runStepsAsync(`Build${incremental ? '-Incremental' : ''} [${pkg ?? 'All'}]`, [\n ['yarn', ['xy', 'compile', ...pkgOptions, ...targetOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions, '--types', 'tsc']],\n ['yarn', ['xy', 'lint', ...pkgOptions, ...verboseOptions, ...incrementalOptions]],\n ['yarn', ['xy', 'deps', ...pkgOptions, ...verboseOptions, ...jobsOptions, ...incrementalOptions]],\n ])\n console.log(`${chalk.gray('Built in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => ex.name !== undefined && ex.message !== undefined,\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import { spawn } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport type { ScriptStep } from './runSteps.ts'\nimport { safeExitAsync } from './safeExit.ts'\n\nexport const runStepAsync = (name: string, step: ScriptStep, exitOnFail = true, message?: string) => {\n return new Promise<number>((resolve) => {\n const [command, args, config] = step\n if (message) {\n console.log(chalk.gray(message))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n spawn(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).on('close', (code) => {\n if (code) {\n console.error(\n chalk.red(\n `Command Exited With Non-Zero Result [${chalk.gray(code)}] | ${chalk.yellow(command)} ${chalk.white(\n Array.isArray(args) ? args.join(' ') : args,\n )}`,\n ),\n )\n checkResult(name, code, 'error', exitOnFail)\n resolve(code)\n } else {\n resolve(0)\n }\n })\n })\n}\n\nexport const runStepsAsync = async (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]) => {\n return await safeExitAsync(async () => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let result = 0\n for (const [i, step] of steps.entries()) {\n result += await runStepAsync(name, step, exitOnFail, messages?.[i])\n }\n return result\n })\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxDC,YAAQP,KAAAA,EAAOG,UAAU,GAAGL,IAAAA,QAAYC,MAAAA,aAAmBG,OAAAA,EAAS,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAUA,IAAGG,SAASC,UAAaJ,IAAGK,YAAYD,WAAS;AAExE,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWI;AACjD,GAPyB;;;ACElB,IAAME,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAAQL,MAAMM,OAAMC,IAAI,IAAIP,OAAMQ,IAAI,cAAc,CAAA;IACtD,OAAO;AACLH,cAAQL,MAAMM,OAAMC,IAAI,UAAUP,OAAM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U,cAAcX,OAAO;IAAC;IAAM,GAAGA,IAAAA;MAAU,CAAA;AAC/C,MAAIA,MAAM;AACRY,YAAQC,IAAIC,OAAMC,KAAK,gBAAgBf,IAAAA,GAAO,CAAA;EAChD;AAEA,QAAMgB,SAAS,MAAMC,cAAc,QAAQlB,cAAc,iBAAiB,EAAA,KAAOI,OAAO,KAAA,KAAU;IAChG;MAAC;MAAQ;QAAC;QAAM;WAAcI;WAAeG;WAAkBD;WAAmBE;WAAgBH;QAAoB;QAAW;;;IACjI;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBD;;;IAC7D;MAAC;MAAQ;QAAC;QAAM;WAAWD;WAAeE;WAAmBE;WAAgBH;;;GAC9E;AACDI,UAAQC,IAAI,GAAGC,OAAMI,KAAK,UAAA,CAAA,KAAgBJ,OAAMK,UAAUd,KAAKC,IAAG,IAAKF,SAAS,KAAMgB,QAAQ,CAAA,CAAA,CAAA,KAAQN,OAAMI,KAAK,SAAA,CAAA,EAAY;AAC7H,SAAOF;AACT,GApBqB;","names":["chalk","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","undefined","message","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExitAsync","func","exitOnFail","result","process","exit","ex","processEx","spawn","existsSync","chalk","runStepAsync","name","step","exitOnFail","message","Promise","resolve","command","args","config","console","log","chalk","gray","argList","Array","isArray","split","existsSync","Error","spawn","env","FORCE_COLOR","process","shell","stdio","on","code","error","red","yellow","white","join","checkResult","runStepsAsync","steps","messages","safeExitAsync","pkgName","npm_package_name","green","result","i","entries","build","incremental","jobs","target","verbose","pkg","start","Date","now","pkgOptions","incrementalOptions","verboseOptions","targetOptions","jobsOptions","console","log","chalk","blue","result","runStepsAsync","gray","magenta","toFixed"]}
|
package/dist/actions/compile.mjs
CHANGED
|
@@ -98,21 +98,23 @@ var runSteps = /* @__PURE__ */ __name((name, steps, exitOnFail = true, messages)
|
|
|
98
98
|
}, "runSteps");
|
|
99
99
|
|
|
100
100
|
// src/actions/compile.ts
|
|
101
|
-
var compile = /* @__PURE__ */ __name(({ verbose, target, pkg, incremental, publint, jobs }) => {
|
|
101
|
+
var compile = /* @__PURE__ */ __name(({ verbose, target, pkg, incremental, publint, jobs, types }) => {
|
|
102
102
|
return pkg ? compilePackage({
|
|
103
103
|
pkg,
|
|
104
104
|
publint,
|
|
105
105
|
target,
|
|
106
|
-
verbose
|
|
106
|
+
verbose,
|
|
107
|
+
types
|
|
107
108
|
}) : compileAll({
|
|
108
109
|
incremental,
|
|
109
110
|
publint,
|
|
110
111
|
target,
|
|
111
112
|
verbose,
|
|
112
|
-
jobs
|
|
113
|
+
jobs,
|
|
114
|
+
types
|
|
113
115
|
});
|
|
114
116
|
}, "compile");
|
|
115
|
-
var compilePackage = /* @__PURE__ */ __name(({ target, pkg }) => {
|
|
117
|
+
var compilePackage = /* @__PURE__ */ __name(({ target, pkg, types }) => {
|
|
116
118
|
const targetOptions = target ? [
|
|
117
119
|
"-t",
|
|
118
120
|
target
|
|
@@ -124,13 +126,13 @@ var compilePackage = /* @__PURE__ */ __name(({ target, pkg }) => {
|
|
|
124
126
|
"workspace",
|
|
125
127
|
pkg,
|
|
126
128
|
"run",
|
|
127
|
-
"package-compile",
|
|
129
|
+
types === "tsup" ? "package-compile" : "package-build",
|
|
128
130
|
...targetOptions
|
|
129
131
|
]
|
|
130
132
|
]
|
|
131
133
|
]);
|
|
132
134
|
}, "compilePackage");
|
|
133
|
-
var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental }) => {
|
|
135
|
+
var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental, types }) => {
|
|
134
136
|
const start = Date.now();
|
|
135
137
|
const verboseOptions = verbose ? [
|
|
136
138
|
"--verbose"
|
|
@@ -167,7 +169,7 @@ var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental })
|
|
|
167
169
|
...jobsOptions,
|
|
168
170
|
...verboseOptions,
|
|
169
171
|
"run",
|
|
170
|
-
"package-compile",
|
|
172
|
+
types === "tsup" ? "package-compile" : "package-build",
|
|
171
173
|
...targetOptions
|
|
172
174
|
]
|
|
173
175
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/actions/compile.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runSteps } from '../lib/index.ts'\n\nexport interface CompileParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\ninterface CompilePackageParams {\n pkg: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n verbose?: boolean\n}\n\nexport const compile = ({\n verbose, target, pkg, incremental, publint, jobs,\n}: CompileParams) => {\n return pkg\n ? compilePackage({\n pkg, publint, target, verbose,\n })\n : compileAll({\n incremental, publint, target, verbose, jobs,\n })\n}\n\nexport const compilePackage = ({ target, pkg }: CompilePackageParams) => {\n const targetOptions = target ? ['-t', target] : []\n\n return runSteps(`Compile [${pkg}]`, [['yarn', ['workspace', pkg, 'run', 'package-compile', ...targetOptions]]])\n}\n\nexport const compileAll = ({\n jobs, verbose, target, incremental,\n}: CompileParams) => {\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const targetOptions = target ? ['-t', target] : []\n const incrementalOptions = incremental ? ['--since', '-Apt', '--topological-dev'] : ['--parallel', '-Apt', '--topological-dev']\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = runSteps(`Compile${incremental ? '-Incremental' : ''} [All]`, [\n ['yarn', ['workspaces', 'foreach', ...incrementalOptions, ...jobsOptions, ...verboseOptions, 'run', 'package-compile', ...targetOptions]],\n ])\n console.log(`${chalk.gray('Compiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => ex.name !== undefined && ex.message !== undefined,\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aA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G,KAAK,SAAA,CAAA,EAAY;AAChI,SAAOD;AACT,GAjB0B;","names":["chalk","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","undefined","message","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","compile","verbose","target","pkg","incremental","publint","jobs","compilePackage","compileAll","targetOptions","runSteps","start","Date","now","verboseOptions","incrementalOptions","jobsOptions","console","log","chalk","blue","result","gray","magenta","toFixed"]}
|
|
1
|
+
{"version":3,"sources":["../../src/actions/compile.ts","../../src/lib/checkResult.ts","../../src/lib/processEx.ts","../../src/lib/withError.ts","../../src/lib/withErrnoException.ts","../../src/lib/safeExit.ts","../../src/lib/runSteps.ts"],"sourcesContent":["import chalk from 'chalk'\n\nimport { runSteps } from '../lib/index.ts'\n\nexport interface CompileParams {\n incremental?: boolean\n jobs?: number\n pkg?: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n types?: 'tsc' | 'tsup'\n verbose?: boolean\n}\n\ninterface CompilePackageParams {\n pkg: string\n publint?: boolean\n target?: 'esm' | 'cjs'\n types?: 'tsc' | 'tsup'\n verbose?: boolean\n}\n\nexport const compile = ({\n verbose, target, pkg, incremental, publint, jobs, types,\n}: CompileParams) => {\n return pkg\n ? compilePackage({\n pkg, publint, target, verbose, types,\n })\n : compileAll({\n incremental, publint, target, verbose, jobs, types,\n })\n}\n\nexport const compilePackage = ({\n target, pkg, types,\n}: CompilePackageParams) => {\n const targetOptions = target ? ['-t', target] : []\n\n return runSteps(\n `Compile [${pkg}]`,\n [['yarn', ['workspace', pkg, 'run', types === 'tsup' ? 'package-compile' : 'package-build', ...targetOptions]]],\n )\n}\n\nexport const compileAll = ({\n jobs, verbose, target, incremental, types,\n}: CompileParams) => {\n const start = Date.now()\n const verboseOptions = verbose ? ['--verbose'] : ['--no-verbose']\n const targetOptions = target ? ['-t', target] : []\n const incrementalOptions = incremental ? ['--since', '-Apt', '--topological-dev'] : ['--parallel', '-Apt', '--topological-dev']\n const jobsOptions = jobs ? ['-j', `${jobs}`] : []\n if (jobs) {\n console.log(chalk.blue(`Jobs set to [${jobs}]`))\n }\n\n const result = runSteps(`Compile${incremental ? '-Incremental' : ''} [All]`, [\n ['yarn', ['workspaces',\n 'foreach',\n ...incrementalOptions,\n ...jobsOptions,\n ...verboseOptions,\n 'run',\n types === 'tsup' ? 'package-compile' : 'package-build',\n ...targetOptions,\n ]],\n ])\n console.log(`${chalk.gray('Compiled in')} [${chalk.magenta(((Date.now() - start) / 1000).toFixed(2))}] ${chalk.gray('seconds')}`)\n return result\n}\n","import chalk from 'chalk'\n\nexport const checkResult = (name: string, result: number, level: 'error' | 'warn' = 'error', exitOnFail = false) => {\n if (result) {\n const exiting = exitOnFail ? '[Exiting Process]' : '[Continuing]'\n const chalkFunc = level === 'error' ? chalk.red : chalk.yellow\n console[level](chalkFunc(`${name} had ${result} failures ${exiting}`))\n if (exitOnFail) {\n process.exit(result)\n }\n }\n}\n","import chalk from 'chalk'\n\nimport { withErrnoException } from './withErrnoException.ts'\nimport { withError } from './withError.ts'\n\nexport const processEx = (ex: unknown) => {\n const error = typeof ex === 'string' ? new Error(ex) : ex\n const exitCode\n = withErrnoException(error, (error) => {\n if (error.code === 'ENOENT') {\n console.error(chalk.red(`'${error.path}' not found.`))\n } else {\n console.error(chalk.red(`Errno: ${error.code}`))\n }\n return error.errno ?? -1\n })\n ?? withError(error, (error) => {\n console.error(chalk.red(`${error.name}: ${error.message}`))\n return -1\n })\n ?? (() => {\n console.error(chalk.red(`Unexpected Error: ${JSON.stringify(ex, null, 2)}`))\n return -1\n })()\n // This allows us to use a previously set exit code\n process.exit(process.exitCode ?? exitCode)\n}\n","export const withError = <T extends Error = Error>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ex: any,\n closure: (error: T) => number,\n predicate = (ex: T) => ex.name !== undefined && ex.message !== undefined,\n) => {\n return predicate(ex as T) ? closure(ex as T) : undefined\n}\n","import { withError } from './withError.ts'\n\nexport const withErrnoException = <T extends NodeJS.ErrnoException = NodeJS.ErrnoException>(\n ex: unknown, closure: (error: T) => number,\n) => {\n return withError<T>(ex, closure, (ex: unknown) => (ex as NodeJS.ErrnoException).errno !== undefined)\n}\n","/** Catch child process a crash and returns the code */\n\nimport { processEx } from './processEx.ts'\n\nconst safeExit = (func: () => number, exitOnFail = true): number => {\n try {\n const result = func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nconst safeExitAsync = async (func: () => Promise<number>, exitOnFail = true): Promise<number> => {\n try {\n const result = await func()\n if (result && exitOnFail) {\n process.exit(result)\n }\n return result\n } catch (ex) {\n return processEx(ex)\n }\n}\n\nexport { safeExit, safeExitAsync }\n","import type { SpawnSyncOptionsWithBufferEncoding } from 'node:child_process'\nimport { spawnSync } from 'node:child_process'\nimport { existsSync } from 'node:fs'\n\nimport chalk from 'chalk'\n\nimport { checkResult } from './checkResult.ts'\nimport { safeExit } from './safeExit.ts'\n\nexport type ScriptStep =\n | [/* command */ 'yarn' | 'node' | 'ts-node-script' | 'tsc' | 'jest', /* arg */ string | string[]]\n | [/* command */ string, /* arg */ string | string[], /* config */ SpawnSyncOptionsWithBufferEncoding]\n\nexport const runSteps = (name: string, steps: ScriptStep[], exitOnFail = true, messages?: string[]): number => {\n return safeExit(() => {\n const pkgName = process.env.npm_package_name\n console.log(chalk.green(`${name} [${pkgName}]`))\n let totalStatus = 0\n for (const [i, [command, args, config]] of steps.entries()) {\n if (messages?.[i]) {\n console.log(chalk.gray(messages?.[i]))\n }\n const argList = Array.isArray(args) ? args : args.split(' ')\n if (command === 'node' && !existsSync(argList[0])) {\n throw new Error(`File not found [${argList[0]}]`)\n }\n const status\n = spawnSync(command, Array.isArray(args) ? args : args.split(' '), {\n ...config,\n encoding: 'utf8',\n env: { FORCE_COLOR: '3', ...process.env },\n shell: true,\n stdio: 'inherit',\n }).status ?? 0\n checkResult(name, status, 'error', exitOnFail)\n totalStatus += status ?? 0\n }\n return totalStatus\n }, !!exitOnFail)\n}\n"],"mappings":";;;;AAAA,OAAOA,YAAW;;;ACAlB,OAAOC,WAAW;AAEX,IAAMC,cAAc,wBAACC,MAAcC,QAAgBC,QAA0B,SAASC,aAAa,UAAK;AAC7G,MAAIF,QAAQ;AACV,UAAMG,UAAUD,aAAa,sBAAsB;AACnD,UAAME,YAAYH,UAAU,UAAUI,MAAMC,MAAMD,MAAME;AACxDC,YAAQP,KAAAA,EAAOG,UAAU,GAAGL,IAAAA,QAAYC,MAAAA,aAAmBG,OAAAA,EAAS,CAAA;AACpE,QAAID,YAAY;AACdO,cAAQC,KAAKV,MAAAA;IACf;EACF;AACF,GAT2B;;;ACF3B,OAAOW,YAAW;;;ACAX,IAAMC,YAAY,wBAEvBC,IACAC,SACAC,YAAY,CAACF,QAAUA,IAAGG,SAASC,UAAaJ,IAAGK,YAAYD,WAAS;AAExE,SAAOF,UAAUF,EAAAA,IAAWC,QAAQD,EAAAA,IAAWI;AACjD,GAPyB;;;ACElB,IAAME,qBAAqB,wBAChCC,IAAaC,YAAAA;AAEb,SAAOC,UAAaF,IAAIC,SAAS,CAACD,QAAiBA,IAA6BG,UAAUC,MAAAA;AAC5F,GAJkC;;;AFG3B,IAAMC,YAAY,wBAACC,OAAAA;AACxB,QAAMC,QAAQ,OAAOD,OAAO,WAAW,IAAIE,MAAMF,EAAAA,IAAMA;AACvD,QAAMG,WACFC,mBAAmBH,OAAO,CAACA,WAAAA;AAC3B,QAAIA,OAAMI,SAAS,UAAU;AAC3BC,cAA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,CAAA;AAChD,QAAMc,qBAAqBZ,cAAc;IAAC;IAAW;IAAQ;MAAuB;IAAC;IAAc;IAAQ;;AAC3G,QAAMa,cAAcX,OAAO;IAAC;IAAM,GAAGA,IAAAA;MAAU,CAAA;AAC/C,MAAIA,MAAM;AACRY,YAAQC,IAAIC,OAAMC,KAAK,gBAAgBf,IAAAA,GAAO,CAAA;EAChD;AAEA,QAAMgB,SAASX,SAAS,UAAUP,cAAc,iBAAiB,EAAA,UAAY;IAC3E;MAAC;MAAQ;QAAC;QACR;WACGY;WACAC;WACAF;QACH;QACAR,UAAU,SAAS,oBAAoB;WACpCG;;;GAEN;AACDQ,UAAQC,IAAI,GAAGC,OAAMG,KAAK,aAAA,CAAA,KAAmBH,OAAMI,UAAUX,KAAKC,IAAG,IAAKF,SAAS,KAAMa,QAAQ,CAAA,CAAA,CAAA,KAAQL,OAAMG,KAAK,SAAA,CAAA,EAAY;AAChI,SAAOD;AACT,GAzB0B;","names":["chalk","chalk","checkResult","name","result","level","exitOnFail","exiting","chalkFunc","chalk","red","yellow","console","process","exit","chalk","withError","ex","closure","predicate","name","undefined","message","withErrnoException","ex","closure","withError","errno","undefined","processEx","ex","error","Error","exitCode","withErrnoException","code","console","chalk","red","path","errno","withError","name","message","JSON","stringify","process","exit","safeExit","func","exitOnFail","result","process","exit","ex","processEx","spawnSync","existsSync","chalk","runSteps","name","steps","exitOnFail","messages","safeExit","pkgName","process","env","npm_package_name","console","log","chalk","green","totalStatus","i","command","args","config","entries","gray","argList","Array","isArray","split","existsSync","Error","status","spawnSync","encoding","FORCE_COLOR","shell","stdio","checkResult","compile","verbose","target","pkg","incremental","publint","jobs","types","compilePackage","compileAll","targetOptions","runSteps","start","Date","now","verboseOptions","incrementalOptions","jobsOptions","console","log","chalk","blue","result","gray","magenta","toFixed"]}
|
package/dist/actions/index.mjs
CHANGED
|
@@ -606,7 +606,9 @@ var build = /* @__PURE__ */ __name(async ({ incremental, jobs, target, verbose,
|
|
|
606
606
|
...targetOptions,
|
|
607
607
|
...verboseOptions,
|
|
608
608
|
...jobsOptions,
|
|
609
|
-
...incrementalOptions
|
|
609
|
+
...incrementalOptions,
|
|
610
|
+
"--types",
|
|
611
|
+
"tsc"
|
|
610
612
|
]
|
|
611
613
|
],
|
|
612
614
|
[
|
|
@@ -690,21 +692,23 @@ var cleanDocs = /* @__PURE__ */ __name(() => {
|
|
|
690
692
|
|
|
691
693
|
// src/actions/compile.ts
|
|
692
694
|
import chalk10 from "chalk";
|
|
693
|
-
var compile = /* @__PURE__ */ __name(({ verbose, target, pkg, incremental, publint: publint2, jobs }) => {
|
|
695
|
+
var compile = /* @__PURE__ */ __name(({ verbose, target, pkg, incremental, publint: publint2, jobs, types }) => {
|
|
694
696
|
return pkg ? compilePackage({
|
|
695
697
|
pkg,
|
|
696
698
|
publint: publint2,
|
|
697
699
|
target,
|
|
698
|
-
verbose
|
|
700
|
+
verbose,
|
|
701
|
+
types
|
|
699
702
|
}) : compileAll({
|
|
700
703
|
incremental,
|
|
701
704
|
publint: publint2,
|
|
702
705
|
target,
|
|
703
706
|
verbose,
|
|
704
|
-
jobs
|
|
707
|
+
jobs,
|
|
708
|
+
types
|
|
705
709
|
});
|
|
706
710
|
}, "compile");
|
|
707
|
-
var compilePackage = /* @__PURE__ */ __name(({ target, pkg }) => {
|
|
711
|
+
var compilePackage = /* @__PURE__ */ __name(({ target, pkg, types }) => {
|
|
708
712
|
const targetOptions = target ? [
|
|
709
713
|
"-t",
|
|
710
714
|
target
|
|
@@ -716,13 +720,13 @@ var compilePackage = /* @__PURE__ */ __name(({ target, pkg }) => {
|
|
|
716
720
|
"workspace",
|
|
717
721
|
pkg,
|
|
718
722
|
"run",
|
|
719
|
-
"package-compile",
|
|
723
|
+
types === "tsup" ? "package-compile" : "package-build",
|
|
720
724
|
...targetOptions
|
|
721
725
|
]
|
|
722
726
|
]
|
|
723
727
|
]);
|
|
724
728
|
}, "compilePackage");
|
|
725
|
-
var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental }) => {
|
|
729
|
+
var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental, types }) => {
|
|
726
730
|
const start = Date.now();
|
|
727
731
|
const verboseOptions = verbose ? [
|
|
728
732
|
"--verbose"
|
|
@@ -759,7 +763,7 @@ var compileAll = /* @__PURE__ */ __name(({ jobs, verbose, target, incremental })
|
|
|
759
763
|
...jobsOptions,
|
|
760
764
|
...verboseOptions,
|
|
761
765
|
"run",
|
|
762
|
-
"package-compile",
|
|
766
|
+
types === "tsup" ? "package-compile" : "package-build",
|
|
763
767
|
...targetOptions
|
|
764
768
|
]
|
|
765
769
|
]
|
|
@@ -1638,7 +1642,7 @@ var packageCompileTscTypes = /* @__PURE__ */ __name((folder = "src", { verbose }
|
|
|
1638
1642
|
}, "packageCompileTscTypes");
|
|
1639
1643
|
|
|
1640
1644
|
// src/actions/package/compile/packageCompileTsup.ts
|
|
1641
|
-
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options, verbose) => {
|
|
1645
|
+
var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single", options, types = "tsup", verbose) => {
|
|
1642
1646
|
const outDir = options?.outDir ?? "dist";
|
|
1643
1647
|
const entry = buildEntries(folder, entryMode);
|
|
1644
1648
|
const optionsResult = defineConfig({
|
|
@@ -1652,7 +1656,7 @@ var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single",
|
|
|
1652
1656
|
],
|
|
1653
1657
|
outDir,
|
|
1654
1658
|
silent: true,
|
|
1655
|
-
sourcemap:
|
|
1659
|
+
sourcemap: types === "tsup",
|
|
1656
1660
|
splitting: false,
|
|
1657
1661
|
tsconfig: "tsconfig.json",
|
|
1658
1662
|
...options
|
|
@@ -1668,13 +1672,17 @@ var compileFolder = /* @__PURE__ */ __name(async (folder, entryMode = "single",
|
|
|
1668
1672
|
];
|
|
1669
1673
|
}))).flat();
|
|
1670
1674
|
await Promise.all(optionsList.map((options2) => build2(options2)));
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1675
|
+
if (types === "tsc") {
|
|
1676
|
+
return packageCompileTscTypes(folder, {
|
|
1677
|
+
verbose
|
|
1678
|
+
}, {
|
|
1679
|
+
outDir
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
return 0;
|
|
1676
1683
|
}, "compileFolder");
|
|
1677
|
-
var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
1684
|
+
var packageCompileTsup = /* @__PURE__ */ __name(async (config2, types = "tsup") => {
|
|
1685
|
+
console.warn("packageCompileTsup-types", types);
|
|
1678
1686
|
const compile2 = config2?.compile;
|
|
1679
1687
|
const publint2 = config2?.publint ?? true;
|
|
1680
1688
|
const verbose = config2?.verbose ?? false;
|
|
@@ -1726,7 +1734,7 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
1726
1734
|
platform: "node",
|
|
1727
1735
|
...compile2?.tsup?.options,
|
|
1728
1736
|
...typeof options === "object" ? options : {}
|
|
1729
|
-
}, verbose) : 0;
|
|
1737
|
+
}, types, verbose) : 0;
|
|
1730
1738
|
}))).reduce((prev, value) => prev + value, 0) || (await Promise.all(Object.entries(compileForBrowser).map(async ([folder, options]) => {
|
|
1731
1739
|
const inEsBuildOptions = typeof compile2?.browser?.esbuildOptions === "object" ? compile2?.browser?.esbuildOptions : {};
|
|
1732
1740
|
return folder ? await compileFolder(folder, compile2?.entryMode, {
|
|
@@ -1739,7 +1747,7 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
1739
1747
|
platform: "browser",
|
|
1740
1748
|
...compile2?.tsup?.options,
|
|
1741
1749
|
...typeof options === "object" ? options : {}
|
|
1742
|
-
}, verbose) : 0;
|
|
1750
|
+
}, types, verbose) : 0;
|
|
1743
1751
|
}))).reduce((prev, value) => prev + value, 0) || (await Promise.all(Object.entries(compileForNeutral).map(async ([folder, options]) => {
|
|
1744
1752
|
const inEsBuildOptions = typeof compile2?.neutral?.esbuildOptions === "object" ? compile2?.neutral?.esbuildOptions : {};
|
|
1745
1753
|
return folder ? await compileFolder(folder, compile2?.entryMode, {
|
|
@@ -1752,12 +1760,12 @@ var packageCompileTsup = /* @__PURE__ */ __name(async (config2) => {
|
|
|
1752
1760
|
platform: "neutral",
|
|
1753
1761
|
...compile2?.tsup?.options,
|
|
1754
1762
|
...typeof options === "object" ? options : {}
|
|
1755
|
-
}, verbose) : 0;
|
|
1763
|
+
}, types, verbose) : 0;
|
|
1756
1764
|
}))).reduce((prev, value) => prev + value, 0) || (publint2 ? await packagePublint() : 0);
|
|
1757
1765
|
}, "packageCompileTsup");
|
|
1758
1766
|
|
|
1759
1767
|
// src/actions/package/compile/compile.ts
|
|
1760
|
-
var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
|
|
1768
|
+
var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}, types) => {
|
|
1761
1769
|
const pkg = process.env.INIT_CWD;
|
|
1762
1770
|
console.log(chalk23.green(`Compiling ${pkg}`));
|
|
1763
1771
|
const config2 = await loadConfig(inConfig);
|
|
@@ -1770,7 +1778,7 @@ var packageCompile = /* @__PURE__ */ __name(async (inConfig = {}) => {
|
|
|
1770
1778
|
break;
|
|
1771
1779
|
}
|
|
1772
1780
|
case "tsup": {
|
|
1773
|
-
result += await packageCompileTsup(config2);
|
|
1781
|
+
result += await packageCompileTsup(config2, types);
|
|
1774
1782
|
break;
|
|
1775
1783
|
}
|
|
1776
1784
|
}
|