@withstudiocms/buildkit 0.1.0 → 0.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @withstudiocms/buildkit
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1254](https://github.com/withstudiocms/studiocms/pull/1254) [`180b959`](https://github.com/withstudiocms/studiocms/commit/180b95972f9d51731eb570685e251532cbae2f62) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Replaces chalk with node:util's styleText
8
+
3
9
  ## 0.1.0
4
10
 
5
11
  ## 0.1.0-beta.6
@@ -1,6 +1,6 @@
1
1
  import { execFileSync } from 'node:child_process';
2
2
  import fs from 'node:fs/promises';
3
- import chalk from 'chalk';
3
+ import { styleText } from 'node:util';
4
4
  import esbuild from 'esbuild';
5
5
  import { glob } from 'tinyglobby';
6
6
 
@@ -92,7 +92,7 @@ const dtsGen = (buildTsConfig, outdir) => ({
92
92
  build.onEnd((result) => {
93
93
  if (result.errors.length > 0) return;
94
94
  const date = dt.format(new Date());
95
- console.log(`${chalk.dim(`[${date}]`)} Generating TypeScript declarations...`);
95
+ console.log(`${styleText('dim', `[${date}]`)} Generating TypeScript declarations...`);
96
96
  try {
97
97
  const res = execFileSync(
98
98
  'tsc',
@@ -100,7 +100,9 @@ const dtsGen = (buildTsConfig, outdir) => ({
100
100
  { encoding: 'utf8', shell: true }
101
101
  );
102
102
  if (res) console.log(res);
103
- console.log(chalk.dim(`[${date}] `) + chalk.green('√ Generated TypeScript declarations'));
103
+ console.log(
104
+ styleText('dim', `[${date}] `) + styleText('green', '√ Generated TypeScript declarations')
105
+ );
104
106
  /* v8 ignore start */
105
107
  } catch (error) {
106
108
  const msg =
@@ -109,7 +111,7 @@ const dtsGen = (buildTsConfig, outdir) => ({
109
111
  // stdout/stderr may be Buffer or string depending on exec options
110
112
  (typeof error?.stdout === 'string' ? error.stdout : (error?.stdout?.toString?.() ?? '')) +
111
113
  (typeof error?.stderr === 'string' ? error.stderr : (error?.stderr?.toString?.() ?? ''));
112
- console.error(chalk.dim(`[${date}] `) + chalk.red(msg));
114
+ console.error(styleText('dim', `[${date}] `) + styleText('red', msg));
113
115
  }
114
116
  /* v8 ignore stop */
115
117
  });
@@ -124,7 +126,10 @@ const dtsGen = (buildTsConfig, outdir) => ({
124
126
  */
125
127
  async function clean(outdir, date, skip = []) {
126
128
  const files = await glob([`${outdir}/**`, ...skip], { filesOnly: true });
127
- console.log(chalk.dim(`[${date}] `) + chalk.dim(`Cleaning ${files.length} files from ${outdir}`));
129
+ console.log(
130
+ styleText('dim', `[${date}] `) +
131
+ styleText('dim', `Cleaning ${files.length} files from ${outdir}`)
132
+ );
128
133
  await Promise.all(files.map((file) => fs.rm(file, { force: true })));
129
134
  }
130
135
 
@@ -191,7 +196,7 @@ export default async function builder(cmd, args) {
191
196
  case 'dev': {
192
197
  if (!noClean) {
193
198
  console.log(
194
- `${chalk.dim(`[${date}]`)} Cleaning ${outdir} directory... ${chalk.dim(`(${entryPoints.length} files found)`)}`
199
+ `${styleText('dim', `[${date}]`)} Cleaning ${outdir} directory... ${styleText('dim', `(${entryPoints.length} files found)`)}`
195
200
  );
196
201
  await clean(outdir, date, [`!${outdir}/**/*.d.ts`]);
197
202
  }
@@ -213,7 +218,9 @@ export default async function builder(cmd, args) {
213
218
  kind: 'error',
214
219
  color: true,
215
220
  });
216
- console.error(chalk.dim(`[${date}] `) + chalk.red(formatted.join('\n')));
221
+ console.error(
222
+ styleText('dim', `[${date}] `) + styleText('red', formatted.join('\n'))
223
+ );
217
224
  return;
218
225
  }
219
226
  if (result.warnings.length) {
@@ -222,12 +229,12 @@ export default async function builder(cmd, args) {
222
229
  color: true,
223
230
  });
224
231
  console.info(
225
- chalk.dim(`[${date}] `) +
226
- chalk.yellow(`! updated with warnings:\n${formattedWarns.join('\n')}`)
232
+ styleText('dim', `[${date}] `) +
233
+ styleText('yellow', `! updated with warnings:\n${formattedWarns.join('\n')}`)
227
234
  );
228
235
  }
229
236
  /* v8 ignore stop */
230
- console.info(chalk.dim(`[${date}] `) + chalk.green('√ updated'));
237
+ console.info(styleText('dim', `[${date}] `) + styleText('green', '√ updated'));
231
238
  });
232
239
  },
233
240
  };
@@ -242,7 +249,7 @@ export default async function builder(cmd, args) {
242
249
  });
243
250
 
244
251
  console.log(
245
- `${chalk.dim(`[${date}] `) + chalk.gray('Watching for changes...')} ${chalk.dim(`(${entryPoints.length} files found)`)}`
252
+ `${styleText('dim', `[${date}] `) + styleText('gray', 'Watching for changes...')} ${styleText('dim', `(${entryPoints.length} files found)`)}`
246
253
  );
247
254
  await builder.watch();
248
255
 
@@ -256,12 +263,12 @@ export default async function builder(cmd, args) {
256
263
  case 'build': {
257
264
  if (!noClean) {
258
265
  console.log(
259
- `${chalk.dim(`[${date}]`)} Cleaning ${outdir} directory... ${chalk.dim(`(${entryPoints.length} files found)`)}`
266
+ `${styleText('dim', `[${date}]`)} Cleaning ${outdir} directory... ${styleText('dim', `(${entryPoints.length} files found)`)}`
260
267
  );
261
268
  await clean(outdir, date, [`!${outdir}/**/*.d.ts`]);
262
269
  }
263
270
  console.log(
264
- `${chalk.dim(`[${date}]`)} Building...${bundle ? '(Bundling)' : ''} ${chalk.dim(`(${entryPoints.length} files found)`)}`
271
+ `${styleText('dim', `[${date}]`)} Building...${bundle ? '(Bundling)' : ''} ${styleText('dim', `(${entryPoints.length} files found)`)}`
265
272
  );
266
273
  await esbuild.build({
267
274
  ...config,
@@ -282,10 +289,10 @@ export default async function builder(cmd, args) {
282
289
  `\nExternal: ${externals ? JSON.stringify(externals) : 'n/a'}` +
283
290
  `\nFormat: ${format}` +
284
291
  `\nOutExtension: ${JSON.stringify(outExt)}\n\n`;
285
- console.log(chalk.dim(`[${date}] `) + chalk.gray(message));
292
+ console.log(styleText('dim', `[${date}] `) + styleText('gray', message));
286
293
  }
287
294
 
288
- console.log(chalk.dim(`[${date}] `) + chalk.green('√ Build Complete'));
295
+ console.log(styleText('dim', `[${date}] `) + styleText('green', '√ Build Complete'));
289
296
  break;
290
297
  }
291
298
  }
package/lib/cmds/help.js CHANGED
@@ -1,28 +1,28 @@
1
- import chalk from 'chalk';
1
+ import { styleText } from 'node:util';
2
2
 
3
3
  /**
4
4
  * Show the help message for the buildkit CLI.
5
5
  */
6
6
  export default function showHelp() {
7
7
  console.log(`
8
- ${chalk.green('StudioCMS Buildkit')} - Build tool for StudioCMS packages
8
+ ${styleText('green', 'StudioCMS Buildkit')} - Build tool for StudioCMS packages
9
9
 
10
- ${chalk.yellow('Usage:')}
10
+ ${styleText('yellow', 'Usage:')}
11
11
  buildkit <command> [...files] [...options]
12
12
 
13
- ${chalk.yellow('Commands:')}
13
+ ${styleText('yellow', 'Commands:')}
14
14
  dev Watch files and rebuild on changes
15
15
  build Perform a one-time build
16
16
  help Show this help message
17
17
 
18
- ${chalk.yellow('Dev and Build Options:')}
18
+ ${styleText('yellow', 'Dev and Build Options:')}
19
19
  --no-clean-dist Skip cleaning the dist directory
20
20
  --bundle Enable bundling mode
21
21
  --force-cjs Force CommonJS output format
22
22
  --tsconfig=<path> Specify TypeScript config file (default: tsconfig.json)
23
23
  --outdir=<path> Specify output directory (default: dist)
24
24
 
25
- ${chalk.yellow('Examples:')}
25
+ ${styleText('yellow', 'Examples:')}
26
26
  - buildkit dev "src/**/*.ts" --no-clean-dist
27
27
  - buildkit build "src/**/*.ts"
28
28
  - buildkit build "src/**/*.ts" --bundle --force-cjs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withstudiocms/buildkit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Build kit based on esbuild for the withstudiocms github org",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -29,8 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "esbuild": "^0.25.8",
32
- "tinyglobby": "^0.2.15",
33
- "chalk": "^5.6.2"
32
+ "tinyglobby": "^0.2.15"
34
33
  },
35
34
  "devDependencies": {
36
35
  "strip-ansi": "^7.1.2"