@yunarch/config-web 0.2.1 → 0.2.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.
@@ -1,143 +1,6 @@
1
- import {
2
- createBaseProgram
3
- } from "../chunk-ARUHQWVA.js";
4
-
5
- // src/cli/bun-run-all/index.ts
6
- import { styleText as styleText2 } from "util";
7
-
8
- // src/cli/bun-run-all/utils.ts
9
- import { styleText } from "util";
10
- var COLORS = ["blue", "green", "yellow", "grey", "white", "cyan"];
11
- var getExecutionTime = (start) => {
12
- const durationMs = Number(Bun.nanoseconds() - start) / 1e6;
13
- return `${(durationMs / 1e3).toFixed(2)}s`;
14
- };
15
- function reportExecutionLog({
16
- start,
17
- tasks,
18
- failedTasks
19
- }) {
20
- const successTasks = tasks - failedTasks;
21
- const executionTime = getExecutionTime(start);
22
- const failedTasksText = failedTasks > 0 ? styleText("red", `${failedTasks} failed`) : "";
23
- const successTasksText = successTasks > 0 ? styleText("green", `${successTasks} successful`) : "";
24
- console.log("");
25
- console.log(
26
- styleText("bold", "Tasks: "),
27
- `${failedTasksText}${successTasksText}`,
28
- styleText("gray", `-- ${tasks} total`)
29
- );
30
- console.log(
31
- styleText(["white", "bold"], "Time: "),
32
- styleText("gray", executionTime)
33
- );
34
- }
35
- function spawnProc({
36
- index,
37
- script,
38
- continueOnError,
39
- reportTime
40
- }) {
41
- const color = COLORS[index % COLORS.length];
42
- const start = Bun.nanoseconds();
43
- const proc = Bun.spawn(["bun", "run", script], {
44
- stdout: "pipe",
45
- stderr: "pipe",
46
- env: {
47
- ...Bun.env,
48
- FORCE_COLOR: "1"
49
- },
50
- onExit(_, exitCode) {
51
- if (exitCode === 1 && !continueOnError) process.exit(1);
52
- }
53
- });
54
- proc.stdout.pipeTo(
55
- new WritableStream({
56
- write(chunk) {
57
- const lines = new TextDecoder().decode(chunk).split("\n");
58
- for (const line of lines) {
59
- console.log(styleText([color, "bold"], `${script}:`), line);
60
- }
61
- }
62
- })
63
- );
64
- proc.stderr.pipeTo(
65
- new WritableStream({
66
- write(chunk) {
67
- const lines = new TextDecoder().decode(chunk).split("\n");
68
- for (const line of lines) {
69
- console.log(styleText([color, "bold"], `${script}:`), line);
70
- }
71
- }
72
- })
73
- );
74
- proc.exited.then((code) => {
75
- if (code === 0 && reportTime) {
76
- console.log(
77
- styleText([color, "bold"], `${script}:`),
78
- styleText(["gray"], "Finished in"),
79
- styleText(["white", "bold"], getExecutionTime(start))
80
- );
81
- }
82
- });
83
- return proc;
84
- }
85
- async function runParallel(scripts, options) {
86
- const { continueOnError, reportTime } = options;
87
- const start = Bun.nanoseconds();
88
- const procs = scripts.map(
89
- (script, index) => spawnProc({ index, script, continueOnError, reportTime })
90
- );
91
- const promises = await Promise.allSettled(procs.map((proc) => proc.exited));
92
- reportExecutionLog({
93
- start,
94
- tasks: scripts.length,
95
- failedTasks: promises.filter(
96
- (promise) => promise.status === "rejected" || promise.value !== 0
97
- ).length
98
- });
99
- }
100
- async function runSequential(scripts, options) {
101
- const { continueOnError, reportTime } = options;
102
- const start = Bun.nanoseconds();
103
- let failedTasks = 0;
104
- for (const [index, script] of scripts.entries()) {
105
- const proc = spawnProc({ index, script, continueOnError, reportTime });
106
- const exitCode = await proc.exited;
107
- if (exitCode !== 0) failedTasks++;
108
- }
109
- reportExecutionLog({ start, tasks: scripts.length, failedTasks });
110
- }
111
-
112
- // src/cli/bun-run-all/index.ts
113
- createBaseProgram().name("bun-run-all").description(
114
- "Run given package scripts in parallel or sequential by using bun."
115
- ).argument("<scripts...>", "A list of package scripts' names.").option(
116
- "-c, --continue-on-error",
117
- "Continue executing other/subsequent tasks even if a task threw an error"
118
- ).option("-p, --parallel", "Run a group of tasks in parallel.").option("-s, --sequential", "Run a group of tasks sequentially.").option("-t, --time", "Report execution time for each task.").action(
119
- async (scripts, options) => {
120
- try {
121
- console.log(styleText2("magenta", "\n\u{1F680} bun-run-all\n"));
122
- const sequential = options.sequential ?? false;
123
- const parallel = options.parallel ?? !sequential;
124
- const continueOnError = options.continueOnError ?? false;
125
- const reportTime = options.time ?? false;
126
- if (parallel === sequential) {
127
- console.error(
128
- "You cannot use both --parallel and --sequential options at the same time."
129
- );
130
- process.exit(1);
131
- }
132
- if (sequential) {
133
- await runSequential(scripts, { continueOnError, reportTime });
134
- process.exit(0);
135
- }
136
- await runParallel(scripts, { continueOnError, reportTime });
137
- process.exit(0);
138
- } catch (error) {
139
- console.error(error);
140
- process.exit(1);
141
- }
142
- }
143
- ).parseAsync(process.argv);
1
+ #!/usr/bin/env bun
2
+ import{c as p}from"../chunk-PWSW557X.js";import{styleText as h}from"util";import{styleText as a}from"util";var d=["blue","green","yellow","grey","white","cyan"],m=t=>`${(Number(Bun.nanoseconds()-t)/1e6/1e3).toFixed(2)}s`;function b({start:t,tasks:e,failedTasks:n}){let i=e-n,r=m(t),s=n>0?a("red",`${n} failed`):"",l=i>0?a("green",`${i} successful`):"";console.log(""),console.log(a("bold","Tasks: "),`${s}${l}`,a("gray",`-- ${e} total`)),console.log(a(["white","bold"],"Time: "),a("gray",r))}function g({index:t,script:e,continueOnError:n,reportTime:i}){let r=d[t%d.length],s=Bun.nanoseconds(),l=Bun.spawn(["bun","run",e],{stdout:"pipe",stderr:"pipe",env:{...Bun.env,FORCE_COLOR:"1"},onExit(o,c){c===1&&!n&&process.exit(1)}});return l.stdout.pipeTo(new WritableStream({write(o){let c=new TextDecoder().decode(o).split(`
3
+ `);for(let u of c)console.log(a([r,"bold"],`${e}:`),u)}})),l.stderr.pipeTo(new WritableStream({write(o){let c=new TextDecoder().decode(o).split(`
4
+ `);for(let u of c)console.log(a([r,"bold"],`${e}:`),u)}})),l.exited.then(o=>{o===0&&i&&console.log(a([r,"bold"],`${e}:`),a(["gray"],"Finished in"),a(["white","bold"],m(s)))}),l}async function f(t,e){let{continueOnError:n,reportTime:i}=e,r=Bun.nanoseconds(),s=t.map((o,c)=>g({index:c,script:o,continueOnError:n,reportTime:i})),l=await Promise.allSettled(s.map(o=>o.exited));b({start:r,tasks:t.length,failedTasks:l.filter(o=>o.status==="rejected"||o.value!==0).length})}async function x(t,e){let{continueOnError:n,reportTime:i}=e,r=Bun.nanoseconds(),s=0;for(let[l,o]of t.entries())await g({index:l,script:o,continueOnError:n,reportTime:i}).exited!==0&&s++;b({start:r,tasks:t.length,failedTasks:s})}p().name("bun-run-all").description("Run given package scripts in parallel or sequential by using bun.").argument("<scripts...>","A list of package scripts' names.").option("-c, --continue-on-error","Continue executing other/subsequent tasks even if a task threw an error").option("-p, --parallel","Run a group of tasks in parallel.").option("-s, --sequential","Run a group of tasks sequentially.").option("-t, --time","Report execution time for each task.").action(async(t,e)=>{try{console.log(h("magenta",`
5
+ \u{1F680} bun-run-all
6
+ `));let n=e.sequential??!1,i=e.parallel??!n,r=e.continueOnError??!1,s=e.time??!1;i===n&&(console.error("You cannot use both --parallel and --sequential options at the same time."),process.exit(1)),n&&(await x(t,{continueOnError:r,reportTime:s}),process.exit(0)),await f(t,{continueOnError:r,reportTime:s}),process.exit(0)}catch(n){console.error(n),process.exit(1)}}).parseAsync(process.argv);
@@ -0,0 +1 @@
1
+ import{exec as a}from"child_process";import{promisify as m,styleText as e,types as c}from"util";import{Command as p}from"commander";import u from"ora";var l=m(a);async function w(o){let{command:t,name:i}=o,s=u(i);s.spinner="aesthetic",s.start();try{let r=typeof t=="string"?await l(t):c.isPromise(t)?await t:await t();return s.succeed(),await new Promise(n=>{setTimeout(n,0)}),typeof r=="object"&&r&&"stdout"in r?r.stdout:r}catch(r){let n=r;throw s.fail(e("red",n.stderr??n.message??"")),r}}function P(){let o=new p;return o.configureHelp({styleTitle:t=>e("bold",t),styleCommandText:t=>e("cyan",t),styleCommandDescription:t=>e("magenta",t),styleDescriptionText:t=>e("italic",t),styleOptionText:t=>e("green",t),styleArgumentText:t=>e("yellow",t),styleSubcommandText:t=>e("blue",t)}).configureOutput({outputError:(t,i)=>{i(e("red",t))}}),o}export{l as a,w as b,P as c};
@@ -1,27 +1,4 @@
1
- import {
2
- asyncExec,
3
- createBaseProgram,
4
- runTask
5
- } from "../chunk-ARUHQWVA.js";
6
-
7
- // src/cli/openapi-sync/index.ts
8
- import { writeFile as writeFile3 } from "fs/promises";
9
- import { styleText } from "util";
10
- import confirm from "@inquirer/confirm";
11
-
12
- // src/cli/openapi-sync/codegen-models/index.ts
13
- async function run(input, outputDirectory) {
14
- await runTask({
15
- name: "Generating models",
16
- command: `npx openapi-typescript-codegen --input ${input} --output ${outputDirectory} --client fetch`
17
- });
18
- }
19
-
20
- // src/cli/openapi-sync/codegen-msw-utils/index.ts
21
- import { writeFile } from "fs/promises";
22
-
23
- // src/cli/openapi-sync/codegen-msw-utils/openapi-msw-http.ts
24
- var TEMPLATE = `
1
+ import{a as l,b as o,c as y}from"../chunk-PWSW557X.js";import{writeFile as O}from"fs/promises";import{styleText as f}from"util";import S from"@inquirer/confirm";async function g(e,t){await o({name:"Generating models",command:`npx openapi-typescript-codegen --input ${e} --output ${t} --client fetch`})}import{writeFile as R}from"fs/promises";var w=`
25
2
  import {
26
3
  http as mswHttp,
27
4
  type DefaultBodyType,
@@ -143,186 +120,15 @@ export function http<P extends keyof paths, M extends Methods<P>>(
143
120
  }
144
121
  return handlers[method as keyof typeof handlers];
145
122
  }
146
- `;
147
-
148
- // src/cli/openapi-sync/codegen-msw-utils/index.ts
149
- async function run2(outputDirectory) {
150
- await runTask({
151
- name: "Generating openapi MSW utils",
152
- command: async () => {
153
- await writeFile(`${outputDirectory}/openapi-msw-http.ts`, TEMPLATE);
154
- }
155
- });
156
- }
157
-
158
- // src/cli/openapi-sync/codegen-schema-typedef/index.ts
159
- import { readFile, writeFile as writeFile2 } from "fs/promises";
160
- async function run3(input, output) {
161
- await runTask({
162
- name: "Generating schema types",
163
- command: async () => {
164
- await asyncExec(`npx openapi-typescript ${input} -o ${output}`);
165
- const content = await readFile(output, "utf8");
166
- await writeFile2(
167
- output,
168
- `/* eslint-disable -- Autogenerated file */
169
- ${content}`
170
- );
171
- }
172
- });
173
- }
174
-
175
- // src/cli/openapi-sync/utils.ts
176
- import { existsSync } from "fs";
177
- import { mkdir, readFile as readFile2 } from "fs/promises";
178
- import path from "path";
179
- async function prepareOutputDirectory(output) {
180
- if (path.extname(output) !== "") {
181
- throw new Error("Output must be a directory.");
182
- }
183
- const cwdPath = process.cwd();
184
- const absolutePath = path.resolve(output);
185
- const isInsideCwd = absolutePath.startsWith(cwdPath);
186
- const dir = isInsideCwd ? absolutePath : path.resolve(cwdPath, path.relative(path.parse(output).root, output));
187
- if (!existsSync(dir)) {
188
- await runTask({
189
- name: "Generating output directory",
190
- command: async () => {
191
- await mkdir(dir, { recursive: true });
192
- }
193
- });
194
- }
195
- return dir;
196
- }
197
- async function readOpenapiSchemas(inputSchemaPath, outputSchemaPath) {
198
- const [inputSchema, outputSchema] = await Promise.all([
199
- runTask({
200
- name: "Reading input openapi schema",
201
- command: async () => {
202
- if (!inputSchemaPath.endsWith(".json")) {
203
- throw new Error(`Input file must be a JSON file: ${inputSchemaPath}`);
204
- }
205
- if (inputSchemaPath.startsWith("http")) {
206
- try {
207
- const { stdout } = await asyncExec(
208
- `curl -s ${inputSchemaPath} --fail`
209
- );
210
- return stdout;
211
- } catch {
212
- throw new Error(
213
- `Failed to fetch remote OpenAPI file: ${inputSchemaPath}`
214
- );
215
- }
216
- }
217
- if (!existsSync(inputSchemaPath)) {
218
- throw new Error(`Input file does not exist: ${inputSchemaPath}`);
219
- }
220
- return await readFile2(inputSchemaPath, "utf8");
221
- }
222
- }),
223
- runTask({
224
- name: "Reading output openapi schema",
225
- command: async () => {
226
- if (!outputSchemaPath.endsWith(".json")) {
227
- throw new Error(
228
- `Output file must be a JSON file: ${outputSchemaPath}`
229
- );
230
- }
231
- if (!existsSync(outputSchemaPath)) return false;
232
- return await readFile2(outputSchemaPath, "utf8");
233
- }
234
- })
235
- ]);
236
- return [
237
- JSON.stringify(JSON.parse(inputSchema)),
238
- outputSchema ? JSON.stringify(JSON.parse(outputSchema)) : false
239
- ];
240
- }
241
-
242
- // src/cli/openapi-sync/index.ts
243
- createBaseProgram().name("openapi-sync").description(
244
- "A CLI tool to convert OpenAPI 3.0/3.1 schemas to TypeScript types and create type-safe fetching based on a openapi file and keep them in sync."
245
- ).requiredOption(
246
- "-i, --input <path>",
247
- "The input (local or remote) openapi schema (JSON)."
248
- ).requiredOption(
249
- "-o, --output <folder>",
250
- "The output folder to save the generated models and openapi schema and type definitions."
251
- ).option(
252
- "-f, --force-gen",
253
- "Force generation of typescript schemas and fetching code even if the input and output schemas are identical."
254
- ).option(
255
- "--include-msw-utils",
256
- "Include MSW mocking utilities based on the generated typescript types."
257
- ).option(
258
- "--post-script <script>",
259
- "A package.json script to run after the code generation."
260
- ).action(
261
- async ({
262
- input,
263
- output,
264
- forceGen,
265
- includeMswUtils,
266
- postScript
267
- }) => {
268
- try {
269
- console.log(styleText("magenta", "\n\u{1F680} openapi-sync\n"));
270
- const outputDirectory = await prepareOutputDirectory(output);
271
- const outputSchemaPath = `${outputDirectory}/openapi.json`;
272
- const outputSchemaTypeDefs = `${outputDirectory}/schema.d.ts`;
273
- const [inputSchema, outputSchema] = await readOpenapiSchemas(
274
- input,
275
- outputSchemaPath
276
- );
277
- if (outputSchema && inputSchema === outputSchema && !forceGen) {
278
- console.log(styleText("blue", "\nNo updates required.\n"));
279
- process.exit(0);
280
- } else if (!outputSchema) {
281
- await runTask({
282
- name: "Creating local schema",
283
- command: writeFile3(outputSchemaPath, inputSchema)
284
- });
285
- } else if (outputSchema && inputSchema !== outputSchema) {
286
- console.log(
287
- styleText(
288
- "yellow",
289
- "\n\u26A0\uFE0F Local and remote schemas does not match!\n"
290
- )
291
- );
292
- const confirmed = await confirm({
293
- message: "Do you want to use the remote schema? (y/n)?"
294
- });
295
- if (confirmed) {
296
- await runTask({
297
- name: "Replacing local schema with input schema",
298
- command: writeFile3(outputSchemaPath, inputSchema)
299
- });
300
- } else {
301
- console.log(
302
- styleText("yellow", "\n\u26A0\uFE0F Sync remote schemas skipped.\n")
303
- );
304
- if (!forceGen) process.exit(0);
305
- }
306
- }
307
- await Promise.all([
308
- run3(outputSchemaPath, outputSchemaTypeDefs),
309
- run(outputSchemaPath, outputDirectory)
310
- ]);
311
- if (includeMswUtils) {
312
- await run2(outputDirectory);
313
- }
314
- if (postScript) {
315
- await runTask({
316
- name: "Running post script",
317
- command: `node --run ${postScript}`
318
- });
319
- }
320
- console.log(
321
- styleText("green", "\n\u2705 openapi-sync process completed!\n")
322
- );
323
- } catch (error) {
324
- console.error(error);
325
- process.exit(1);
326
- }
327
- }
328
- ).parseAsync(process.argv);
123
+ `;async function x(e){await o({name:"Generating openapi MSW utils",command:async()=>{await R(`${e}/openapi-msw-http.ts`,w)}})}import{readFile as H,writeFile as B}from"fs/promises";async function P(e,t){await o({name:"Generating schema types",command:async()=>{await l(`npx openapi-typescript ${e} -o ${t}`);let n=await H(t,"utf8");await B(t,`/* eslint-disable -- Autogenerated file */
124
+ ${n}`)}})}import{existsSync as u}from"fs";import{mkdir as E,readFile as T}from"fs/promises";import m from"path";async function M(e){if(m.extname(e)!=="")throw new Error("Output must be a directory.");let t=process.cwd(),n=m.resolve(e),a=n.startsWith(t)?n:m.resolve(t,m.relative(m.parse(e).root,e));return u(a)||await o({name:"Generating output directory",command:async()=>{await E(a,{recursive:!0})}}),a}async function k(e,t){let[n,s]=await Promise.all([o({name:"Reading input openapi schema",command:async()=>{if(!e.endsWith(".json"))throw new Error(`Input file must be a JSON file: ${e}`);if(e.startsWith("http"))try{let{stdout:a}=await l(`curl -s ${e} --fail`);return a}catch{throw new Error(`Failed to fetch remote OpenAPI file: ${e}`)}if(!u(e))throw new Error(`Input file does not exist: ${e}`);return await T(e,"utf8")}}),o({name:"Reading output openapi schema",command:async()=>{if(!t.endsWith(".json"))throw new Error(`Output file must be a JSON file: ${t}`);return u(t)?await T(t,"utf8"):!1}})]);return[JSON.stringify(JSON.parse(n)),s?JSON.stringify(JSON.parse(s)):!1]}y().name("openapi-sync").description("A CLI tool to convert OpenAPI 3.0/3.1 schemas to TypeScript types and create type-safe fetching based on a openapi file and keep them in sync.").requiredOption("-i, --input <path>","The input (local or remote) openapi schema (JSON).").requiredOption("-o, --output <folder>","The output folder to save the generated models and openapi schema and type definitions.").option("-f, --force-gen","Force generation of typescript schemas and fetching code even if the input and output schemas are identical.").option("--include-msw-utils","Include MSW mocking utilities based on the generated typescript types.").option("--post-script <script>","A package.json script to run after the code generation.").action(async({input:e,output:t,forceGen:n,includeMswUtils:s,postScript:a})=>{try{console.log(f("magenta",`
125
+ \u{1F680} openapi-sync
126
+ `));let r=await M(t),p=`${r}/openapi.json`,v=`${r}/schema.d.ts`,[h,i]=await k(e,p);i&&h===i&&!n?(console.log(f("blue",`
127
+ No updates required.
128
+ `)),process.exit(0)):i?i&&h!==i&&(console.log(f("yellow",`
129
+ \u26A0\uFE0F Local and remote schemas does not match!
130
+ `)),await S({message:"Do you want to use the remote schema? (y/n)?"})?await o({name:"Replacing local schema with input schema",command:O(p,h)}):(console.log(f("yellow",`
131
+ \u26A0\uFE0F Sync remote schemas skipped.
132
+ `)),n||process.exit(0))):await o({name:"Creating local schema",command:O(p,h)}),await Promise.all([P(p,v),g(p,r)]),s&&await x(r),a&&await o({name:"Running post script",command:`node --run ${a}`}),console.log(f("green",`
133
+ \u2705 openapi-sync process completed!
134
+ `))}catch(r){console.error(r),process.exit(1)}}).parseAsync(process.argv);
@@ -1,59 +1,5 @@
1
- import {
2
- createBaseProgram
3
- } from "../chunk-ARUHQWVA.js";
4
-
5
- // src/cli/turbo-select/index.ts
6
- import { execSync as execSync2 } from "child_process";
7
- import { styleText } from "util";
8
-
9
- // src/cli/turbo-select/utils.ts
10
- import { execSync } from "child_process";
11
- import select from "@inquirer/select";
12
- async function selectTurboPackages() {
13
- const packages = execSync("npx turbo ls", {
14
- encoding: "utf8",
15
- stdio: "pipe"
16
- });
17
- const packageList = packages.split("\n").slice(1).map((line) => line.trim()).filter(Boolean).map((line) => line.split(" ")[0]);
18
- return await select({
19
- message: "Select a package to run the script:",
20
- choices: packageList.map((opt) => ({ name: opt, value: opt }))
21
- });
22
- }
23
- async function selectEnvironmentMode() {
24
- return await select({
25
- message: "Select a mode to load different env files:",
26
- choices: [
27
- { name: "development", value: "development" },
28
- { name: "staging", value: "staging" },
29
- { name: "production", value: "production" }
30
- ]
31
- });
32
- }
33
-
34
- // src/cli/turbo-select/index.ts
35
- createBaseProgram().name("turbo-select").description(
36
- "A CLI tool to filter and select a single package from the Turborepo package list and run a script command.\nAdditionally, allow to prompt environment mode (development, staging, production), for example, when using Vite."
37
- ).requiredOption(
38
- "--run <script>",
39
- "The package script command to execute (e.g., --run=dev)."
40
- ).option(
41
- "--select-env",
42
- "An environment mode (development, staging, production) If using for example vite."
43
- ).action(async ({ run, selectEnv }) => {
44
- try {
45
- console.log(styleText("magenta", "\n\u{1F680} Turbo-Select\n"));
46
- const filter = await selectTurboPackages();
47
- const environment = selectEnv ? await selectEnvironmentMode() : void 0;
48
- execSync2(
49
- `turbo run ${run} --ui stream ${filter ? `--filter=${filter}` : ""} ${environment ? `-- --mode ${environment}` : ""}`,
50
- {
51
- encoding: "utf8",
52
- stdio: "inherit"
53
- }
54
- );
55
- } catch (error) {
56
- console.error(error);
57
- process.exit(1);
58
- }
59
- }).parseAsync(process.argv);
1
+ import{c as r}from"../chunk-PWSW557X.js";import{execSync as p}from"child_process";import{styleText as u}from"util";import{execSync as l}from"child_process";import a from"@inquirer/select";async function i(){let t=l("npx turbo ls",{encoding:"utf8",stdio:"pipe"}).split(`
2
+ `).slice(1).map(e=>e.trim()).filter(Boolean).map(e=>e.split(" ")[0]);return await a({message:"Select a package to run the script:",choices:t.map(e=>({name:e,value:e}))})}async function c(){return await a({message:"Select a mode to load different env files:",choices:[{name:"development",value:"development"},{name:"staging",value:"staging"},{name:"production",value:"production"}]})}r().name("turbo-select").description(`A CLI tool to filter and select a single package from the Turborepo package list and run a script command.
3
+ Additionally, allow to prompt environment mode (development, staging, production), for example, when using Vite.`).requiredOption("--run <script>","The package script command to execute (e.g., --run=dev).").option("--select-env","An environment mode (development, staging, production) If using for example vite.").action(async({run:o,selectEnv:t})=>{try{console.log(u("magenta",`
4
+ \u{1F680} Turbo-Select
5
+ `));let e=await i(),n=t?await c():void 0;p(`turbo run ${o} --ui stream ${e?`--filter=${e}`:""} ${n?`-- --mode ${n}`:""}`,{encoding:"utf8",stdio:"inherit"})}catch(e){console.error(e),process.exit(1)}}).parseAsync(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "name": "@yunarch/config-web",
5
5
  "description": "Shared configurations for web projects.",
6
6
  "license": "MIT",
@@ -1,47 +0,0 @@
1
- // src/cli/utils.ts
2
- import { exec } from "child_process";
3
- import { promisify, styleText, types } from "util";
4
- import { Command } from "commander";
5
- import ora from "ora";
6
- var asyncExec = promisify(exec);
7
- async function runTask(task) {
8
- const { command, name } = task;
9
- const spinner = ora(name);
10
- spinner.spinner = "aesthetic";
11
- spinner.start();
12
- try {
13
- const result = typeof command === "string" ? await asyncExec(command) : types.isPromise(command) ? await command : await command();
14
- spinner.succeed();
15
- await new Promise((resolve) => {
16
- setTimeout(resolve, 0);
17
- });
18
- return typeof result === "object" && result && "stdout" in result ? result.stdout : result;
19
- } catch (error) {
20
- const e = error;
21
- spinner.fail(styleText("red", e.stderr ?? e.message ?? ""));
22
- throw error;
23
- }
24
- }
25
- function createBaseProgram() {
26
- const program = new Command();
27
- program.configureHelp({
28
- styleTitle: (str) => styleText("bold", str),
29
- styleCommandText: (str) => styleText("cyan", str),
30
- styleCommandDescription: (str) => styleText("magenta", str),
31
- styleDescriptionText: (str) => styleText("italic", str),
32
- styleOptionText: (str) => styleText("green", str),
33
- styleArgumentText: (str) => styleText("yellow", str),
34
- styleSubcommandText: (str) => styleText("blue", str)
35
- }).configureOutput({
36
- outputError: (str, write) => {
37
- write(styleText("red", str));
38
- }
39
- });
40
- return program;
41
- }
42
-
43
- export {
44
- asyncExec,
45
- runTask,
46
- createBaseProgram
47
- };