jiek 1.1.11 → 1.1.12

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/cli.cjs CHANGED
@@ -149,7 +149,7 @@ async function getSelectedProjectsGraph(filter = commander.program.getOptionValu
149
149
 
150
150
  var name = "jiek";
151
151
  var type = "module";
152
- var version = "1.1.11";
152
+ var version = "1.1.12";
153
153
  var description$1 = "YiJie's personal kits.";
154
154
  var bin = {
155
155
  jiek: "bin/jiek.js",
@@ -493,6 +493,8 @@ commander.program.command("build").description(description).option("-o, --outdir
493
493
  }
494
494
  });
495
495
  const bars = {};
496
+ const times = {};
497
+ const locks = {};
496
498
  let inputMaxLen = 10;
497
499
  child.on("message", (e) => {
498
500
  if (e.type === "debug")
@@ -518,7 +520,7 @@ commander.program.command("build").description(description).option("-o, --outdir
518
520
  return;
519
521
  bars[key] = multiBars.create(50, 0, {
520
522
  pkgName: manifest.name,
521
- input: input.padEnd(inputMaxLen),
523
+ input: input.padEnd(inputMaxLen + 5),
522
524
  status: "waiting".padEnd(10)
523
525
  }, {
524
526
  barsize: 20,
@@ -537,6 +539,7 @@ commander.program.command("build").description(description).option("-o, --outdir
537
539
  const bar = bars[`${input}:${path2}`];
538
540
  if (!bar)
539
541
  return;
542
+ const time = times[`${input}:${path2}`];
540
543
  bar.update(
541
544
  {
542
545
  start: 0,
@@ -544,12 +547,36 @@ commander.program.command("build").description(description).option("-o, --outdir
544
547
  end: 50
545
548
  }[event ?? "start"] ?? 0,
546
549
  {
547
- input: input.padEnd(inputMaxLen),
550
+ input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
548
551
  status: event?.padEnd(10),
549
552
  message: `${tags?.join(", ")}: ${message}`
550
553
  }
551
554
  );
552
555
  }
556
+ if (e.type === "watchChange") {
557
+ const {
558
+ path: path2,
559
+ input
560
+ } = e.data;
561
+ const key = `${input}:${path2}`;
562
+ const bar = bars[key];
563
+ if (!bar)
564
+ return;
565
+ let time = times[key] ?? 1;
566
+ if (!locks[key]) {
567
+ time += 1;
568
+ times[key] = time;
569
+ setTimeout(() => {
570
+ locks[key] = false;
571
+ }, 100);
572
+ bar.update(0, {
573
+ input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
574
+ status: "watching".padEnd(10),
575
+ message: "watching..."
576
+ });
577
+ }
578
+ locks[key] = true;
579
+ }
553
580
  });
554
581
  await new Promise((resolve, reject) => {
555
582
  let errorStr = "";
package/dist/cli.js CHANGED
@@ -118,7 +118,7 @@ async function getSelectedProjectsGraph(filter = program.getOptionValue("filter"
118
118
 
119
119
  var name = "jiek";
120
120
  var type = "module";
121
- var version = "1.1.11";
121
+ var version = "1.1.12";
122
122
  var description$1 = "YiJie's personal kits.";
123
123
  var bin = {
124
124
  jiek: "bin/jiek.js",
@@ -462,6 +462,8 @@ program.command("build").description(description).option("-o, --outdir <OUTDIR>"
462
462
  }
463
463
  });
464
464
  const bars = {};
465
+ const times = {};
466
+ const locks = {};
465
467
  let inputMaxLen = 10;
466
468
  child.on("message", (e) => {
467
469
  if (e.type === "debug")
@@ -487,7 +489,7 @@ program.command("build").description(description).option("-o, --outdir <OUTDIR>"
487
489
  return;
488
490
  bars[key] = multiBars.create(50, 0, {
489
491
  pkgName: manifest.name,
490
- input: input.padEnd(inputMaxLen),
492
+ input: input.padEnd(inputMaxLen + 5),
491
493
  status: "waiting".padEnd(10)
492
494
  }, {
493
495
  barsize: 20,
@@ -506,6 +508,7 @@ program.command("build").description(description).option("-o, --outdir <OUTDIR>"
506
508
  const bar = bars[`${input}:${path2}`];
507
509
  if (!bar)
508
510
  return;
511
+ const time = times[`${input}:${path2}`];
509
512
  bar.update(
510
513
  {
511
514
  start: 0,
@@ -513,12 +516,36 @@ program.command("build").description(description).option("-o, --outdir <OUTDIR>"
513
516
  end: 50
514
517
  }[event ?? "start"] ?? 0,
515
518
  {
516
- input: input.padEnd(inputMaxLen),
519
+ input: (time ? `${input}(x${time.toString().padStart(2, "0")})` : input).padEnd(inputMaxLen + 5),
517
520
  status: event?.padEnd(10),
518
521
  message: `${tags?.join(", ")}: ${message}`
519
522
  }
520
523
  );
521
524
  }
525
+ if (e.type === "watchChange") {
526
+ const {
527
+ path: path2,
528
+ input
529
+ } = e.data;
530
+ const key = `${input}:${path2}`;
531
+ const bar = bars[key];
532
+ if (!bar)
533
+ return;
534
+ let time = times[key] ?? 1;
535
+ if (!locks[key]) {
536
+ time += 1;
537
+ times[key] = time;
538
+ setTimeout(() => {
539
+ locks[key] = false;
540
+ }, 100);
541
+ bar.update(0, {
542
+ input: `${input}(x${time.toString().padStart(2, "0")})`.padEnd(inputMaxLen + 5),
543
+ status: "watching".padEnd(10),
544
+ message: "watching..."
545
+ });
546
+ }
547
+ locks[key] = true;
548
+ }
522
549
  });
523
550
  await new Promise((resolve, reject) => {
524
551
  let errorStr = "";
@@ -4652,6 +4652,7 @@ const generateConfigs = (context, options = {}) => {
4652
4652
  const tsOutputSuffix = jsOutputSuffix.replace(/(\.[cm]?)js$/, ".d$1ts");
4653
4653
  const { js: jsOutput, dts: dtsOutput } = resolveOutputControls(context, build.output);
4654
4654
  const rollupOptions = [];
4655
+ const commonPlugins = [];
4655
4656
  if (jsOutput && !WITHOUT_JS) {
4656
4657
  rollupOptions.push({
4657
4658
  input: inputObj,
@@ -4668,6 +4669,7 @@ const generateConfigs = (context, options = {}) => {
4668
4669
  })
4669
4670
  ],
4670
4671
  plugins: [
4672
+ ...commonPlugins,
4671
4673
  pluginNodeResolve.nodeResolve({ exportConditions }),
4672
4674
  import('rollup-plugin-postcss').then(
4673
4675
  ({ default: postcss }) => postcss({
@@ -4704,6 +4706,7 @@ const generateConfigs = (context, options = {}) => {
4704
4706
  }
4705
4707
  ],
4706
4708
  plugins: [
4709
+ ...commonPlugins,
4707
4710
  pluginNodeResolve.nodeResolve({ exportConditions }),
4708
4711
  skip({ patterns: [STYLE_REGEXP] }),
4709
4712
  rollupPluginDts.dts({
@@ -4733,6 +4736,18 @@ const generateConfigs = (context, options = {}) => {
4733
4736
  ]
4734
4737
  });
4735
4738
  }
4739
+ rollupOptions[0].plugins = [
4740
+ {
4741
+ name: "jiek-plugin-watcher",
4742
+ watchChange: (id) => execa.sendMessage(
4743
+ {
4744
+ type: "watchChange",
4745
+ data: { id, name: JIEK_NAME, path: path$1, input }
4746
+ }
4747
+ )
4748
+ },
4749
+ ...rollupOptions[0].plugins
4750
+ ];
4736
4751
  return rollupOptions;
4737
4752
  };
4738
4753
  function template(packageJSON) {
@@ -4637,6 +4637,7 @@ const generateConfigs = (context, options = {}) => {
4637
4637
  const tsOutputSuffix = jsOutputSuffix.replace(/(\.[cm]?)js$/, ".d$1ts");
4638
4638
  const { js: jsOutput, dts: dtsOutput } = resolveOutputControls(context, build.output);
4639
4639
  const rollupOptions = [];
4640
+ const commonPlugins = [];
4640
4641
  if (jsOutput && !WITHOUT_JS) {
4641
4642
  rollupOptions.push({
4642
4643
  input: inputObj,
@@ -4653,6 +4654,7 @@ const generateConfigs = (context, options = {}) => {
4653
4654
  })
4654
4655
  ],
4655
4656
  plugins: [
4657
+ ...commonPlugins,
4656
4658
  nodeResolve({ exportConditions }),
4657
4659
  import('rollup-plugin-postcss').then(
4658
4660
  ({ default: postcss }) => postcss({
@@ -4689,6 +4691,7 @@ const generateConfigs = (context, options = {}) => {
4689
4691
  }
4690
4692
  ],
4691
4693
  plugins: [
4694
+ ...commonPlugins,
4692
4695
  nodeResolve({ exportConditions }),
4693
4696
  skip({ patterns: [STYLE_REGEXP] }),
4694
4697
  dts({
@@ -4718,6 +4721,18 @@ const generateConfigs = (context, options = {}) => {
4718
4721
  ]
4719
4722
  });
4720
4723
  }
4724
+ rollupOptions[0].plugins = [
4725
+ {
4726
+ name: "jiek-plugin-watcher",
4727
+ watchChange: (id) => sendMessage(
4728
+ {
4729
+ type: "watchChange",
4730
+ data: { id, name: JIEK_NAME, path, input }
4731
+ }
4732
+ )
4733
+ },
4734
+ ...rollupOptions[0].plugins
4735
+ ];
4721
4736
  return rollupOptions;
4722
4737
  };
4723
4738
  function template(packageJSON) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jiek",
3
3
  "type": "module",
4
- "version": "1.1.11",
4
+ "version": "1.1.12",
5
5
  "description": "YiJie's personal kits.",
6
6
  "bin": {
7
7
  "jiek": "bin/jiek.js",
@@ -184,6 +184,8 @@ program
184
184
  }
185
185
  })
186
186
  const bars: Record<string, ReturnType<typeof multiBars.create>> = {}
187
+ const times: Record<string, number> = {}
188
+ const locks: Record<string, boolean> = {}
187
189
  let inputMaxLen = 10
188
190
  child.on('message', (e: RollupProgressEvent) => {
189
191
  if (e.type === 'debug') console.log(...(Array.isArray(e.data) ? e.data : [e.data]))
@@ -209,7 +211,7 @@ program
209
211
  if (bars[key]) return
210
212
  bars[key] = multiBars.create(50, 0, {
211
213
  pkgName: manifest.name,
212
- input: input.padEnd(inputMaxLen),
214
+ input: input.padEnd(inputMaxLen + 5),
213
215
  status: 'waiting'.padEnd(10)
214
216
  }, {
215
217
  barsize: 20,
@@ -227,6 +229,7 @@ program
227
229
  } = e.data
228
230
  const bar = bars[`${input}:${path}`]
229
231
  if (!bar) return
232
+ const time = times[`${input}:${path}`]
230
233
  bar.update(
231
234
  {
232
235
  start: 0,
@@ -234,12 +237,39 @@ program
234
237
  end: 50
235
238
  }[event ?? 'start'] ?? 0,
236
239
  {
237
- input: input.padEnd(inputMaxLen),
240
+ input: (
241
+ time
242
+ ? `${input}(x${time.toString().padStart(2, '0')})`
243
+ : input
244
+ ).padEnd(inputMaxLen + 5),
238
245
  status: event?.padEnd(10),
239
246
  message: `${tags?.join(', ')}: ${message}`
240
247
  }
241
248
  )
242
249
  }
250
+ if (e.type === 'watchChange') {
251
+ const {
252
+ path,
253
+ input
254
+ } = e.data
255
+ const key = `${input}:${path}`
256
+ const bar = bars[key]
257
+ if (!bar) return
258
+ let time = times[key] ?? 1
259
+ if (!locks[key]) {
260
+ time += 1
261
+ times[key] = time
262
+ setTimeout(() => {
263
+ locks[key] = false
264
+ }, 100)
265
+ bar.update(0, {
266
+ input: `${input}(x${time.toString().padStart(2, '0')})`.padEnd(inputMaxLen + 5),
267
+ status: 'watching'.padEnd(10),
268
+ message: 'watching...'
269
+ })
270
+ }
271
+ locks[key] = true
272
+ }
243
273
  })
244
274
  await new Promise<void>((resolve, reject) => {
245
275
  let errorStr = ''
@@ -65,6 +65,15 @@ export type RollupProgressEvent =
65
65
  targetsLength: number
66
66
  }
67
67
  }
68
+ | {
69
+ type: 'watchChange'
70
+ data: {
71
+ id: string
72
+ name: string
73
+ path: string
74
+ input: string
75
+ }
76
+ }
68
77
  | {
69
78
  type: 'debug'
70
79
  data: unknown
@@ -11,7 +11,7 @@ import { nodeResolve } from '@rollup/plugin-node-resolve'
11
11
  import terser from '@rollup/plugin-terser'
12
12
  import { sendMessage } from 'execa'
13
13
  import { isMatch } from 'micromatch'
14
- import type { InputPluginOption, OutputOptions, OutputPlugin, RollupOptions } from 'rollup'
14
+ import type { InputPluginOption, OutputOptions, OutputPlugin, Plugin, RollupOptions } from 'rollup'
15
15
  import esbuild from 'rollup-plugin-esbuild'
16
16
  import ts from 'typescript'
17
17
 
@@ -245,6 +245,8 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
245
245
  const tsOutputSuffix = jsOutputSuffix.replace(/(\.[cm]?)js$/, '.d$1ts')
246
246
  const { js: jsOutput, dts: dtsOutput } = resolveOutputControls(context, build.output)
247
247
  const rollupOptions: RollupOptions[] = []
248
+
249
+ const commonPlugins: Plugin[] = []
248
250
  if (jsOutput && !WITHOUT_JS) {
249
251
  rollupOptions.push({
250
252
  input: inputObj,
@@ -277,6 +279,7 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
277
279
  })
278
280
  ],
279
281
  plugins: [
282
+ ...commonPlugins,
280
283
  nodeResolve({ exportConditions }),
281
284
  import('rollup-plugin-postcss')
282
285
  .then(({ default: postcss }) =>
@@ -303,6 +306,7 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
303
306
  ]
304
307
  })
305
308
  }
309
+
306
310
  if (dtsOutput && !WITHOUT_DTS) {
307
311
  rollupOptions.push({
308
312
  input: inputObj,
@@ -328,6 +332,7 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
328
332
  }
329
333
  ],
330
334
  plugins: [
335
+ ...commonPlugins,
331
336
  nodeResolve({ exportConditions }),
332
337
  skip({ patterns: [STYLE_REGEXP] }),
333
338
  dts({
@@ -358,6 +363,20 @@ const generateConfigs = (context: ConfigGenerateContext, options: TemplateOption
358
363
  ]
359
364
  })
360
365
  }
366
+ // only push the first one a watcher plugin
367
+ rollupOptions[0].plugins = [
368
+ {
369
+ name: 'jiek-plugin-watcher',
370
+ watchChange: (id) =>
371
+ sendMessage(
372
+ {
373
+ type: 'watchChange',
374
+ data: { id, name: JIEK_NAME!, path, input }
375
+ } satisfies RollupProgressEvent
376
+ )
377
+ },
378
+ ...(rollupOptions[0].plugins as any)
379
+ ]
361
380
  return rollupOptions
362
381
  }
363
382