@done-coding/cli-extract 0.1.1-alpha.0 → 0.1.1

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/es/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as m } from "./index-7b2a1d96.js";
2
+ import { c as m } from "./index-ab366c48.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:path";
5
5
  import "node:fs";
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { log as r, _get as O, _curry as I, createSubcommand as h, getConfigFileCommonOptions as R, initHandlerCommon as v, readConfigFile as G, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
3
- import D from "node:path";
2
+ import { log as r, _get as O, _curry as I, createSubcommand as T, getConfigFileCommonOptions as R, initHandlerCommon as v, readConfigFile as G, _set as H, createMainCommand as V } from "@done-coding/cli-utils";
3
+ import j from "node:path";
4
4
  import N from "node:fs";
5
5
  import { OutputModeEnum as L, batchCompileHandler as W } from "@done-coding/cli-template";
6
6
  var u = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(u || {}), d = /* @__PURE__ */ ((e) => (e.REG = "reg", e.JSON_INJECT = "json-inject", e))(d || {}), p = /* @__PURE__ */ ((e) => (e.INIT = "init", e.GENERATE = "generate", e))(p || {}), s = /* @__PURE__ */ ((e) => (e.REG = "reg", e.FIXED = "fixed", e.READ = "read", e))(s || {});
7
- const j = ({
7
+ const D = ({
8
8
  sourceJson: e,
9
9
  targetKey: n,
10
10
  keyConfig: t
@@ -33,7 +33,7 @@ const j = ({
33
33
  return;
34
34
  }
35
35
  }
36
- }, F = {
36
+ }, U = {
37
37
  sourceFilePath: "./package.json",
38
38
  keyConfigMap: {
39
39
  name: {
@@ -47,27 +47,27 @@ const j = ({
47
47
  }
48
48
  },
49
49
  injectFilePath: "./src/injectInfo.json"
50
- }, J = {
50
+ }, F = U, J = {
51
51
  name: "@done-coding/cli-inject",
52
- version: "0.5.2-alpha.0",
52
+ version: "0.5.2",
53
53
  description: "信息(JSON)注入命令行工具",
54
54
  cliConfig: {
55
55
  namespaceDir: ".done-coding",
56
56
  moduleName: "inject"
57
57
  }
58
58
  }, {
59
- cliConfig: { namespaceDir: U, moduleName: X }
60
- } = J, K = `./${U}/${X}`, $ = `${K}.json`, q = () => R({
59
+ cliConfig: { namespaceDir: X, moduleName: K }
60
+ } = J, q = `./${X}/${K}`, $ = `${q}.json`, z = () => R({
61
61
  configPathDefault: $
62
- }), z = async (e) => v(F, e, {
62
+ }), B = async (e) => v(F, e, {
63
63
  onFileGenerated: () => {
64
64
  r.info("文件生成成功");
65
65
  }
66
- }), B = () => ({
66
+ }), Q = () => ({
67
67
  ...R({
68
68
  configPathDefault: $
69
69
  })
70
- }), Q = async ({
70
+ }), Y = async ({
71
71
  rootDir: e = process.cwd(),
72
72
  config: n = F,
73
73
  keyConfigMap: t = {}
@@ -84,13 +84,13 @@ const j = ({
84
84
  return r.error("源文件必须是json"), process.exit(1);
85
85
  if (!a.endsWith(".json"))
86
86
  return r.error("注入文件必须是json"), process.exit(1);
87
- const E = D.resolve(e, o), g = N.readFileSync(E, "utf-8"), l = JSON.parse(g), i = Object.entries(f).reduce(
88
- (C, [T, P]) => {
89
- const M = j({ sourceJson: l, targetKey: T, keyConfig: P });
90
- return H(C, T, M), C;
87
+ const E = j.resolve(e, o), g = N.readFileSync(E, "utf-8"), l = JSON.parse(g), i = Object.entries(f).reduce(
88
+ (C, [h, P]) => {
89
+ const M = D({ sourceJson: l, targetKey: h, keyConfig: P });
90
+ return H(C, h, M), C;
91
91
  },
92
92
  {}
93
- ), m = D.resolve(e, a), y = JSON.stringify(i, null, 2);
93
+ ), m = j.resolve(e, a), y = JSON.stringify(i, null, 2);
94
94
  if (N.existsSync(m)) {
95
95
  const C = N.readFileSync(m, "utf-8");
96
96
  if (y === C)
@@ -99,39 +99,39 @@ const j = ({
99
99
  } else
100
100
  r.stage("开始注入文件");
101
101
  N.writeFileSync(m, y), r.success(`文件注入成功: ${m}`), r.info(y);
102
- }, Y = async (e) => {
102
+ }, Z = async (e) => {
103
103
  const n = await G(e);
104
104
  if (!n)
105
105
  return r.error("配置文件为空"), process.exit(1);
106
106
  const { rootDir: t } = e;
107
- await Q({ rootDir: t, config: n });
108
- }, w = async (e, n) => e === p.INIT ? z(n) : e === p.GENERATE ? Y(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
109
- version: Z,
110
- description: ee,
107
+ await Y({ rootDir: t, config: n });
108
+ }, w = async (e, n) => e === p.INIT ? B(n) : e === p.GENERATE ? Z(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
109
+ version: ee,
110
+ description: ne,
111
111
  cliConfig: { moduleName: he }
112
- } = J, ne = {
112
+ } = J, te = {
113
113
  command: p.INIT,
114
114
  describe: "初始化提取配置文件",
115
- options: q(),
115
+ options: z(),
116
116
  handler: I(w)(
117
117
  p.INIT
118
118
  )
119
- }, te = {
119
+ }, oe = {
120
120
  command: p.GENERATE,
121
121
  describe: "提取信息",
122
- options: B(),
122
+ options: Q(),
123
123
  handler: I(w)(
124
124
  p.GENERATE
125
125
  )
126
126
  };
127
- [ne, te].map(
128
- h
127
+ [te, oe].map(
128
+ T
129
129
  );
130
- const oe = {
130
+ const re = {
131
131
  name: "${name}",
132
132
  version: "${version}",
133
133
  description: "${description}"
134
- }, re = {
134
+ }, se = {
135
135
  extractInput: {
136
136
  "./package.json": {
137
137
  name: {
@@ -170,34 +170,34 @@ const oe = {
170
170
  list: [
171
171
  {
172
172
  mode: L.OVERWRITE,
173
- inputData: JSON.stringify(oe, null, 2),
173
+ inputData: JSON.stringify(re, null, 2),
174
174
  output: "./src/extractInfo.json"
175
175
  }
176
176
  ]
177
177
  }
178
178
  }, x = {
179
179
  name: "@done-coding/cli-extract",
180
- version: "0.1.1-alpha.0",
180
+ version: "0.1.1",
181
181
  description: "信息提取命令行工具",
182
182
  cliConfig: {
183
183
  namespaceDir: ".done-coding",
184
184
  moduleName: "extract"
185
185
  }
186
186
  }, {
187
- cliConfig: { namespaceDir: se, moduleName: ie }
188
- } = x, ce = `./${se}/${ie}`, S = `${ce}.json5`, ae = () => R({
187
+ cliConfig: { namespaceDir: ie, moduleName: ce }
188
+ } = x, ae = `./${ie}/${ce}`, S = `${ae}.json5`, de = () => R({
189
189
  configPathDefault: S
190
- }), de = async (e) => v(re, e, {
190
+ }), ue = async (e) => v(se, e, {
191
191
  onFileGenerated: () => {
192
192
  r.info("文件生成成功");
193
193
  }
194
- }), ue = ({
194
+ }), pe = ({
195
195
  input: e,
196
196
  rootDir: n
197
197
  }) => {
198
- const t = D.resolve(n, e), o = N.readFileSync(t, "utf-8");
198
+ const t = j.resolve(n, e), o = N.readFileSync(t, "utf-8");
199
199
  return e.endsWith(".json") || e.endsWith(".json5") ? JSON.parse(o) : o;
200
- }, pe = (e) => typeof e == "object" && !!e, le = ({
200
+ }, le = (e) => typeof e == "object" && !!e, me = ({
201
201
  content: e,
202
202
  targetKey: n,
203
203
  keyConfig: t
@@ -207,7 +207,7 @@ const oe = {
207
207
  case d.REG: {
208
208
  if (typeof e != "string")
209
209
  throw new Error(`${o} 类型的keyConfig需要content为字符串`);
210
- return j({
210
+ return D({
211
211
  sourceJson: {
212
212
  [n]: e
213
213
  },
@@ -220,9 +220,9 @@ const oe = {
220
220
  });
221
221
  }
222
222
  case d.JSON_INJECT: {
223
- if (!pe(e))
223
+ if (!le(e))
224
224
  throw new Error(`${o} 类型的keyConfig需要content为json`);
225
- return j({
225
+ return D({
226
226
  sourceJson: e,
227
227
  targetKey: n,
228
228
  keyConfig: t.inject
@@ -231,23 +231,23 @@ const oe = {
231
231
  default:
232
232
  throw new Error(`不支持的类型${o}`);
233
233
  }
234
- }, me = () => ({
234
+ }, fe = () => ({
235
235
  ...R({
236
236
  configPathDefault: S
237
237
  })
238
- }), fe = async ({
238
+ }), Ee = async ({
239
239
  rootDir: e = process.cwd(),
240
240
  config: n
241
241
  }) => {
242
242
  const { extractInput: t, extractOutput: o } = n, c = Object.entries(t).reduce(
243
243
  (a, [f, E]) => {
244
- const g = ue({
244
+ const g = pe({
245
245
  rootDir: e,
246
246
  input: f
247
247
  });
248
248
  return Object.entries(E).reduce(
249
249
  (l, [i, m]) => {
250
- const y = le({
250
+ const y = me({
251
251
  content: g,
252
252
  targetKey: i,
253
253
  keyConfig: m
@@ -266,51 +266,51 @@ const oe = {
266
266
  },
267
267
  o
268
268
  );
269
- }, Ee = async (e) => {
269
+ }, ge = async (e) => {
270
270
  const n = await G(e);
271
271
  if (!n)
272
272
  return r.error("配置文件为空"), process.exit(1);
273
273
  const { rootDir: t } = e;
274
- await fe({ rootDir: t, config: n });
275
- }, b = async (e, n) => e === u.INIT ? de(n) : e === u.GENERATE ? Ee(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
276
- version: ge,
277
- description: ye,
274
+ await Ee({ rootDir: t, config: n });
275
+ }, b = async (e, n) => e === u.INIT ? ue(n) : e === u.GENERATE ? ge(n) : (r.error(`无效的命令: ${e}`), process.exit(1)), {
276
+ version: ye,
277
+ description: Ne,
278
278
  cliConfig: { moduleName: A }
279
- } = x, Ne = {
279
+ } = x, Ce = {
280
280
  command: u.INIT,
281
281
  describe: "初始化提取配置文件",
282
- options: ae(),
282
+ options: de(),
283
283
  handler: I(b)(
284
284
  u.INIT
285
285
  )
286
- }, Ce = {
286
+ }, Ie = {
287
287
  command: u.GENERATE,
288
288
  describe: "提取信息",
289
- options: me(),
289
+ options: fe(),
290
290
  handler: I(b)(
291
291
  u.GENERATE
292
292
  )
293
293
  }, _ = {
294
- describe: ye,
295
- version: ge,
296
- subcommands: [Ne, Ce].map(
297
- h
294
+ describe: Ne,
295
+ version: ye,
296
+ subcommands: [Ce, Ie].map(
297
+ T
298
298
  ),
299
299
  demandCommandCount: 1
300
300
  }, k = (e = !1) => {
301
301
  const n = e ? A : void 0, t = `$0${e ? ` ${A}` : ""} <command> [options]`;
302
302
  return { command: n, usage: t };
303
- }, Te = async () => V({
303
+ }, Oe = async () => V({
304
304
  ..._,
305
305
  ...k()
306
- }), Oe = () => h({
306
+ }), Ae = () => T({
307
307
  ..._,
308
308
  ...k(!0)
309
309
  });
310
310
  export {
311
311
  d as E,
312
312
  u as S,
313
- Oe as a,
314
- Te as c,
313
+ Ae as a,
314
+ Oe as c,
315
315
  b as h
316
316
  };
package/es/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { E as e, S as p, a as s, h as i } from "./index-7b2a1d96.js";
2
+ import { E as e, S as p, a as s, h as i } from "./index-ab366c48.js";
3
3
  import "@done-coding/cli-utils";
4
4
  import "node:path";
5
5
  import "node:fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/cli-extract",
3
- "version": "0.1.1-alpha.0",
3
+ "version": "0.1.1",
4
4
  "description": "信息提取命令行工具",
5
5
  "private": false,
6
6
  "module": "es/index.mjs",
@@ -51,7 +51,7 @@
51
51
  "license": "MIT",
52
52
  "sideEffects": false,
53
53
  "devDependencies": {
54
- "@done-coding/cli-inject": "^0.5.2-alpha.0",
54
+ "@done-coding/cli-inject": "^0.5.2",
55
55
  "@types/node": "^18.0.0",
56
56
  "@types/yargs": "^17.0.28",
57
57
  "rimraf": "^6.0.1",
@@ -63,8 +63,8 @@
63
63
  "node": ">=18.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "@done-coding/cli-template": "0.7.3-alpha.0",
67
- "@done-coding/cli-utils": "^0.3.2-alpha.0"
66
+ "@done-coding/cli-template": "0.7.3",
67
+ "@done-coding/cli-utils": "^0.3.2"
68
68
  },
69
- "gitHead": "7faf662e137d46f776c8e5abdf75ab3db541362c"
69
+ "gitHead": "7a8d554748b844c8b7694c587983b21af902d5d1"
70
70
  }
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@done-coding/cli-extract",
3
- "version": "0.1.1-alpha.0",
3
+ "version": "0.1.1",
4
4
  "description": "信息提取命令行工具",
5
5
  "cliConfig": {
6
6
  "namespaceDir": ".done-coding",