@zwa73/dev-utils 1.0.58 → 1.0.61

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.
Files changed (39) hide show
  1. package/data/CreateElectronFrame/.eslintrc.js +41 -0
  2. package/data/CreateElectronFrame/forge.config.ts +52 -0
  3. package/data/CreateElectronFrame/package-lock.json +23687 -0
  4. package/data/CreateElectronFrame/package.json +59 -0
  5. package/data/CreateElectronFrame/src/Component/Base.tsx +8 -0
  6. package/data/CreateElectronFrame/src/Component/index.ts +1 -0
  7. package/data/CreateElectronFrame/src/Static/index.ts +14 -0
  8. package/data/CreateElectronFrame/src/app.tsx +7 -0
  9. package/data/CreateElectronFrame/src/index.html +20 -0
  10. package/data/CreateElectronFrame/src/index.ts +93 -0
  11. package/data/CreateElectronFrame/src/preload.ts +2 -0
  12. package/data/CreateElectronFrame/src/renderer.ts +2 -0
  13. package/data/CreateElectronFrame/webpack.main.config.ts +20 -0
  14. package/data/CreateElectronFrame/webpack.plugins.ts +9 -0
  15. package/data/CreateElectronFrame/webpack.renderer.config.ts +23 -0
  16. package/data/CreateElectronFrame/webpack.rules.ts +41 -0
  17. package/dist/Command/CreateElectronFrame.d.ts +3 -0
  18. package/dist/Command/CreateElectronFrame.js +63 -0
  19. package/dist/Command/GenSchema.js +1 -1
  20. package/dist/Command/Init.js +13 -2
  21. package/dist/Command/MapPath.js +19 -12
  22. package/dist/Command/Route.js +1 -2
  23. package/dist/Command/RouteInterface.js +7 -7
  24. package/dist/UtilDevTool.js +5 -6
  25. package/package.json +4 -3
  26. package/scripts/postinstall.js +7 -7
  27. package/src/Command/CreateElectronFrame.ts +40 -0
  28. package/src/Command/GenSchema.ts +1 -1
  29. package/src/Command/Init.ts +19 -2
  30. package/src/Command/MapPath.ts +18 -13
  31. package/src/UtilDevTool.ts +6 -6
  32. package/dist/b.schema.d.ts +0 -4
  33. package/dist/b.schema.js +0 -3
  34. package/src/b.schema.ts +0 -5
  35. /package/data/{index.d.ts → init/index.d.ts} +0 -0
  36. /package/data/{index.js → init/index.js} +0 -0
  37. /package/data/{scripts → init/scripts}/compile.ps1 +0 -0
  38. /package/data/{scripts → init/scripts}/watch.ps1 +0 -0
  39. /package/data/{src → init/src}/index.ts +0 -0
@@ -0,0 +1,40 @@
1
+ import { Command } from 'commander';
2
+ import * as fs from 'fs';
3
+ import path from 'pathe';
4
+
5
+ import { SLogger, UtilFT, UtilFunc } from '@zwa73/utils';
6
+
7
+ import { checkProject, DATA_PATH, MIRROR_SOURCE, PROJECT_PATH } from './RouteInterface';
8
+
9
+
10
+ const InitDataPath = path.join(DATA_PATH,'CreateElectronFrame');
11
+
12
+ /**复制基础文件 */
13
+ async function copyData() {
14
+ const filelist = await fs.promises.readdir(InitDataPath);
15
+ const plist = filelist.map(async (fileName)=>{
16
+ SLogger.info(`正在复制 ${fileName}`);
17
+ const filePath = path.join(InitDataPath,fileName);
18
+ const targetPath = path.join(PROJECT_PATH,fileName);
19
+ if(!await UtilFT.pathExists(targetPath))
20
+ await fs.promises.cp(filePath,targetPath,{recursive:true});
21
+ else
22
+ SLogger.info(`${fileName} 已存在 跳过`);
23
+ return null;
24
+ })
25
+ await Promise.all(plist);
26
+ }
27
+
28
+ /**对项目进行初始化 */
29
+ export const CmdCreateElectronFrame = (program:Command)=>program
30
+ .command('CreateElectronFrame')
31
+ .command('createelectronframe')
32
+ .description('对当前目录进行项目初始化')
33
+ .action(async (opt) => {
34
+ checkProject();
35
+ SLogger.info(`开始初始化设置当前目录 ${PROJECT_PATH}`);
36
+ await Promise.all([
37
+ copyData(),
38
+ UtilFunc.exec(`npm install --registry ${MIRROR_SOURCE}`)
39
+ ]);
40
+ });
@@ -17,7 +17,7 @@ export const CmdGenSchema = (program:Command) => program
17
17
  include : opt.include,
18
18
  exclude : opt.exclude,
19
19
  project : opt.project,
20
- outDir : opt.outDir,
20
+ outDir : opt.out,
21
21
  includeTypes: opt.includeTypes,
22
22
  excludeTypes: opt.excludeTypes
23
23
  });
@@ -6,12 +6,18 @@ import { SLogger, UtilFT, UtilFunc } from '@zwa73/utils';
6
6
 
7
7
  import { checkProject, DATA_PATH, MIRROR_SOURCE, PROJECT_PATH } from './RouteInterface';
8
8
 
9
+
10
+
11
+
12
+
13
+ const InitDataPath = path.join(DATA_PATH,'init');
14
+
9
15
  /**复制基础文件 */
10
16
  async function copyData() {
11
- const filelist = await fs.promises.readdir(DATA_PATH);
17
+ const filelist = await fs.promises.readdir(InitDataPath);
12
18
  const plist = filelist.map(async (fileName)=>{
13
19
  SLogger.info(`正在复制 ${fileName}`);
14
- const filePath = path.join(DATA_PATH,fileName);
20
+ const filePath = path.join(InitDataPath,fileName);
15
21
  const targetPath = path.join(PROJECT_PATH,fileName);
16
22
  if(!await UtilFT.pathExists(targetPath))
17
23
  await fs.promises.cp(filePath,targetPath,{recursive:true});
@@ -26,11 +32,22 @@ async function copyData() {
26
32
  async function installPackage() {
27
33
  const install = async (name:string)=>
28
34
  await UtilFunc.exec(`npm i --registry ${MIRROR_SOURCE} ${name}`);
35
+ const installdev = async (name:string)=>
36
+ await UtilFunc.exec(`npm i --registry ${MIRROR_SOURCE} --save-dev ${name}`);
29
37
  const packageList = ['@zwa73/utils'];
38
+ const devPackList = [
39
+ '@zwa73/dev-utils',
40
+ '@types/fluent-ffmpeg',
41
+ '@types/node',
42
+ ];
30
43
  for(const name of packageList){
31
44
  SLogger.info(`正在安装 ${name}`);
32
45
  await install(name);
33
46
  }
47
+ for(const name of devPackList){
48
+ SLogger.info(`正在安装 ${name}`);
49
+ await installdev(name);
50
+ }
34
51
  }
35
52
 
36
53
  /**对项目进行初始化 */
@@ -3,8 +3,9 @@ import { Command } from "commander";
3
3
  import fs from "fs";
4
4
  import path from "pathe";
5
5
 
6
- const DupMethodList = ["no-rename","overwrite","move"] as const;
6
+ const DupMethodList = ["skip","overwrite","move"] as const;
7
7
  type DupMethod = typeof DupMethodList[number];
8
+ const DupMethodWithoutMove = DupMethodList.filter(t=>t!='move') as Exclude<DupMethod,'move'>[];
8
9
 
9
10
  /**重命名文件或路径 */
10
11
  export const CmdMapPath = (program: Command) => program
@@ -14,10 +15,14 @@ export const CmdMapPath = (program: Command) => program
14
15
  .argument("<regex>", "要匹配的正则表达式, posix风格路径")
15
16
  .argument("<replacement>", "替换字符串")
16
17
  .option("-e, --exclude <regex>", "排除文件的正则表达式")
17
- .option(`-d, --duplicate-handling <${DupMethodList.join('|')}>`, "处理重名文件的方式", "no-rename")
18
- .option("-do, --duplicate-output <dir>", "移动重命名的重名文件的目录", "Duplicates")
18
+ .option(`-d, --duplicate-handling <${DupMethodWithoutMove.join('|')}|[path:string]>`,
19
+ `处理重名文件的方式:
20
+ skip 不进行处理
21
+ overwrite 覆盖重名
22
+ 其他字符串 将重名部分映射到指定目录下的对应位置, 再次重复将会覆盖`,
23
+ "skip")
19
24
  .option("-r, --recursive", "是否处理子目录", false)
20
- .option("-c, --copy", "复制而不是重命名文件", false)
25
+ .option("-m, --move", "重命名而不是复制文件", false)
21
26
  .option("-t, --test", "不对文件进行实际操作, 在控制台输出映射结果", false)
22
27
  .action(async (regexStr, replacement, options) => {
23
28
  const regex = new RegExp(regexStr);
@@ -36,10 +41,8 @@ export const CmdMapPath = (program: Command) => program
36
41
  const dir = path.parse(target).dir;
37
42
  await UtilFT.ensurePathExists(dir,{dir:true});
38
43
  if(options.test) return SLogger.info(`${source} -> ${target}`);
39
- if (options.copy)
40
- await fs.promises.copyFile(source, target);
41
- else
42
- await fs.promises.rename(source, target);
44
+ if (options.move) await fs.promises.rename(source, target);
45
+ else await fs.promises.copyFile(source, target);
43
46
  }
44
47
 
45
48
  for(const filePath of filePaths){
@@ -49,11 +52,13 @@ export const CmdMapPath = (program: Command) => program
49
52
  if (newFilePath === filePath) continue;
50
53
  //如果文件已存在
51
54
  if(await UtilFT.pathExists(newFilePath)){
52
- await matchProc(duplicateHandling,{
53
- 'move': ()=> mapPath(filePath, path.join(options.duplicateOutput, newFilePath)),
54
- 'no-rename': ()=> SLogger.info(`重名文件存在,跳过:${newFilePath}`),
55
- 'overwrite': ()=> mapPath(filePath,newFilePath),
56
- })
55
+ if(DupMethodWithoutMove.includes(options.duplicateHandling)){
56
+ const fixhd = duplicateHandling as Exclude<DupMethod,'move'>;
57
+ await matchProc(fixhd,{
58
+ 'skip': ()=> SLogger.info(`重名文件存在,跳过:${newFilePath}`),
59
+ 'overwrite': ()=> mapPath(filePath,newFilePath),
60
+ });
61
+ }else await mapPath(filePath, path.join(duplicateHandling, newFilePath));
57
62
  } else await mapPath(filePath,newFilePath);
58
63
  }
59
64
  });
@@ -69,11 +69,11 @@ export async function generateSchema(dir:string,opt?:BuildSchemaOpt){
69
69
  const it = opt?.includeTypes?.map(t=>new RegExp(t))??[/.*/];
70
70
  const et = opt?.excludeTypes?.map(t=>new RegExp(t))??[];
71
71
  const p = new Project();
72
- const types = files.map(fp=>{
73
- const sf = p.addSourceFileAtPath(fp);
74
- const ds = sf.getDescendantsOfKind(SyntaxKind.TypeAliasDeclaration);
75
- return ds.map(d=>d.getName());
76
- }).flat();
72
+ const types = files.map(fp => p
73
+ .addSourceFileAtPath(fp)
74
+ .getDescendantsOfKind(SyntaxKind.TypeAliasDeclaration)
75
+ .map(d=>d.getName())
76
+ ).flat();
77
77
  //console.log(types)
78
78
  const list = gener.getUserSymbols()
79
79
  .filter(t=>types.some(i=>i===t))
@@ -87,7 +87,7 @@ export async function generateSchema(dir:string,opt?:BuildSchemaOpt){
87
87
  //预处理
88
88
  const proced = procSchema(schema,opt?.coverDefine??{});
89
89
  await Promise.all([
90
- UtilFT.writeJSONFile(schemasPath,schema),
90
+ UtilFT.writeJSONFile(schemasPath,proced),
91
91
  //展开
92
92
  expandSchema(proced,schemasPath),
93
93
  ]);
@@ -1,4 +0,0 @@
1
- export type ASD<A, B> = {
2
- a: 123;
3
- b: 223;
4
- };
package/dist/b.schema.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- let c = null;
package/src/b.schema.ts DELETED
@@ -1,5 +0,0 @@
1
- import { PartialOption } from "@zwa73/utils";
2
-
3
- let c:PartialOption<{},{}>=null as any;
4
-
5
- export type ASD<A,B> = {a:123,b:223}
File without changes
File without changes
File without changes
File without changes
File without changes