@cosmwasm/ts-codegen 1.12.1 → 1.13.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.
Files changed (53) hide show
  1. package/README.md +108 -117
  2. package/builder/builder.js +26 -24
  3. package/bundler/bundler.js +27 -17
  4. package/cli.js +2 -2
  5. package/commands/create-boilerplate.js +29 -18
  6. package/commands/generate.js +26 -35
  7. package/commands/install.js +22 -18
  8. package/esm/builder/builder.js +10 -18
  9. package/esm/bundler/bundler.js +10 -10
  10. package/esm/cli.js +2 -2
  11. package/esm/commands/create-boilerplate.js +11 -10
  12. package/esm/commands/generate.js +26 -35
  13. package/esm/commands/install.js +23 -19
  14. package/esm/file.js +4 -3
  15. package/esm/plugins/client.js +1 -1
  16. package/esm/plugins/message-builder.js +4 -4
  17. package/esm/plugins/message-composer.js +1 -1
  18. package/esm/plugins/plugin-base.js +3 -2
  19. package/esm/plugins/provider-bundle.js +1 -1
  20. package/esm/plugins/provider.js +1 -1
  21. package/esm/plugins/react-query.js +8 -7
  22. package/esm/plugins/recoil.js +4 -4
  23. package/esm/plugins/types.js +3 -3
  24. package/esm/ts-codegen.js +2 -1
  25. package/esm/utils/clean.js +1 -1
  26. package/esm/utils/cleanse.js +9 -5
  27. package/esm/utils/package.js +1 -1
  28. package/esm/utils/parse.js +5 -7
  29. package/esm/utils/prompt.js +2 -2
  30. package/esm/utils/schemas.js +32 -19
  31. package/esm/utils/unused.js +3 -4
  32. package/file.js +7 -3
  33. package/package.json +13 -13
  34. package/plugins/client.js +18 -8
  35. package/plugins/message-builder.js +20 -10
  36. package/plugins/message-composer.js +18 -8
  37. package/plugins/plugin-base.js +19 -8
  38. package/plugins/provider-bundle.js +17 -7
  39. package/plugins/provider.js +17 -7
  40. package/plugins/react-query.js +24 -13
  41. package/plugins/recoil.js +20 -10
  42. package/plugins/types.js +19 -9
  43. package/ts-codegen.js +5 -1
  44. package/utils/clean.js +1 -1
  45. package/utils/cleanse.d.ts +1 -0
  46. package/utils/cleanse.js +12 -7
  47. package/utils/files.js +17 -7
  48. package/utils/package.js +2 -3
  49. package/utils/parse.js +5 -7
  50. package/utils/prompt.js +2 -2
  51. package/utils/schemas.d.ts +5 -1
  52. package/utils/schemas.js +34 -20
  53. package/utils/unused.js +20 -11
@@ -15,23 +15,33 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
37
  };
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  const dargs_1 = __importDefault(require("dargs"));
40
+ const fs_1 = require("fs");
41
+ const glob_1 = require("glob");
42
+ const path = __importStar(require("path"));
30
43
  const shell = __importStar(require("shelljs"));
31
44
  const prompt_1 = require("../utils/prompt");
32
- const glob = require('glob').sync;
33
- const fs = require('fs');
34
- const path = require('path');
35
45
  const repo = 'https://github.com/hyperweb-io/ts-codegen-module-boilerplate';
36
46
  exports.default = async (argv) => {
37
47
  if (!shell.which('git')) {
@@ -43,11 +53,11 @@ exports.default = async (argv) => {
43
53
  type: 'string',
44
54
  name: 'name',
45
55
  message: 'Enter your new module name',
46
- }
56
+ },
47
57
  ], argv);
48
58
  shell.exec(`git clone ${repo} ${name}`);
49
59
  shell.cd(name);
50
- const questions = JSON.parse(fs.readFileSync(`.questions.json`));
60
+ const questions = JSON.parse((0, fs_1.readFileSync)(`.questions.json`, 'utf-8'));
51
61
  const fullname = shell
52
62
  .exec('git config --global user.name', { silent: true })
53
63
  .trim();
@@ -85,20 +95,21 @@ exports.default = async (argv) => {
85
95
  ], []);
86
96
  }
87
97
  const files = []
88
- .concat(glob(process.cwd() + '/**/.*'))
89
- .concat(glob(process.cwd() + '/**/*'));
98
+ .concat((0, glob_1.globSync)(process.cwd() + '/**/.*'))
99
+ .concat((0, glob_1.globSync)(process.cwd() + '/**/*'))
100
+ .sort();
90
101
  for (let i = 0; i < files.length; i++) {
91
102
  const templateFile = files[i];
92
- if (fs.lstatSync(templateFile).isDirectory())
103
+ if ((0, fs_1.lstatSync)(templateFile).isDirectory())
93
104
  continue;
94
- let content = fs.readFileSync(templateFile).toString();
105
+ let content = (0, fs_1.readFileSync)(templateFile, 'utf-8');
95
106
  if (path.basename(templateFile) === 'LICENSE' &&
96
107
  license.__LICENSE__ === 'closed') {
97
108
  content = `Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> - All Rights Reserved
98
109
  Unauthorized copying via any medium is strictly prohibited
99
110
  Proprietary and confidential`;
100
111
  }
101
- Object.keys(results).forEach(key => {
112
+ Object.keys(results).forEach((key) => {
102
113
  if (/^__/.test(key)) {
103
114
  content = content.replace(new RegExp(key, 'g'), results[key]);
104
115
  }
@@ -117,7 +128,7 @@ Proprietary and confidential`;
117
128
  // if (path.basename(templateFile) === 'README.md') {
118
129
  // content = `# ${results.__MODULENAME__}`;
119
130
  // }
120
- fs.writeFileSync(templateFile, content);
131
+ (0, fs_1.writeFileSync)(templateFile, content);
121
132
  }
122
133
  shell.rm('-rf', '.git');
123
134
  shell.rm('-rf', '.questions.json');
@@ -12,38 +12,33 @@ exports.default = async (argv) => {
12
12
  type: 'path',
13
13
  name: 'schema',
14
14
  message: 'which directory contains the the Rust contracts?',
15
- default: './schema'
15
+ default: './schema',
16
16
  },
17
17
  {
18
18
  _: true,
19
19
  type: 'path',
20
20
  name: 'out',
21
21
  message: 'where is the output directory?',
22
- default: './ts'
22
+ default: './ts',
23
23
  },
24
24
  {
25
25
  _: true,
26
26
  type: 'string',
27
27
  name: 'name',
28
- message: 'contract name?'
28
+ message: 'contract name?',
29
29
  },
30
30
  {
31
31
  type: 'checkbox',
32
32
  name: 'plugin',
33
33
  message: 'which plugins?',
34
- choices: [
35
- 'client',
36
- 'recoil',
37
- 'react-query',
38
- 'message-composer'
39
- ]
34
+ choices: ['client', 'recoil', 'react-query', 'message-composer'],
40
35
  },
41
36
  {
42
37
  type: 'confirm',
43
38
  name: 'bundle',
44
39
  message: 'enable bundle?',
45
- default: true
46
- }
40
+ default: true,
41
+ },
47
42
  ];
48
43
  if (argv.typesOnly) {
49
44
  argv.plugin = 'types';
@@ -60,24 +55,23 @@ exports.default = async (argv) => {
60
55
  type: 'confirm',
61
56
  name: 'optionalClient',
62
57
  message: 'optionalClient?',
63
- default: false
58
+ default: false,
64
59
  },
65
60
  {
66
61
  type: 'list',
67
62
  name: 'version',
68
63
  message: 'which react-query version?',
69
64
  default: 'v4',
70
- choices: ['v3', 'v4']
65
+ choices: ['v3', 'v4'],
71
66
  },
72
67
  {
73
68
  type: 'confirm',
74
69
  name: 'queryKeys',
75
70
  message: 'queryKeys?',
76
- default: false
71
+ default: false,
77
72
  },
78
73
  ]);
79
74
  }
80
- ;
81
75
  const { optionalClient, version, queryKeys } = await (0, prompt_1.prompt)(questions2, argv);
82
76
  const questions3 = [];
83
77
  if (version === 'v4') {
@@ -87,11 +81,10 @@ exports.default = async (argv) => {
87
81
  type: 'confirm',
88
82
  name: 'mutations',
89
83
  message: 'Generate useMutation hooks?',
90
- default: false
91
- }
84
+ default: false,
85
+ },
92
86
  ]);
93
87
  }
94
- ;
95
88
  const { mutations } = await (0, prompt_1.prompt)(questions3, argv);
96
89
  const queryFactoryQuestions = [];
97
90
  if (queryKeys) {
@@ -101,11 +94,10 @@ exports.default = async (argv) => {
101
94
  type: 'confirm',
102
95
  name: 'queryFactory',
103
96
  message: 'queryFactory? ',
104
- default: false
105
- }
97
+ default: false,
98
+ },
106
99
  ]);
107
100
  }
108
- ;
109
101
  const { queryFactory } = await (0, prompt_1.prompt)(queryFactoryQuestions, argv);
110
102
  ///////// END REACT QUERY
111
103
  ///////// BUNDLE
@@ -116,27 +108,26 @@ exports.default = async (argv) => {
116
108
  type: 'string',
117
109
  name: 'bundleFile',
118
110
  message: 'bundleFile?',
119
- default: 'index.ts'
111
+ default: 'index.ts',
120
112
  },
121
113
  {
122
114
  type: 'string',
123
115
  name: 'bundleScope',
124
116
  message: 'bundleScope?',
125
- default: 'contracts'
126
- }
117
+ default: 'contracts',
118
+ },
127
119
  ]);
128
120
  }
129
- ;
130
121
  const { bundleFile, bundleScope } = await (0, prompt_1.prompt)(questions4, argv);
131
122
  ///////// END BUNDLE
132
123
  const options = {
133
124
  types: {
134
- enabled: true
125
+ enabled: true,
135
126
  },
136
127
  client: {
137
128
  enabled: plugin.includes('client') ||
138
129
  plugin.includes('recoil') ||
139
- plugin.includes('react-query')
130
+ plugin.includes('react-query'),
140
131
  },
141
132
  reactQuery: {
142
133
  enabled: plugin.includes('react-query'),
@@ -144,31 +135,31 @@ exports.default = async (argv) => {
144
135
  queryKeys,
145
136
  version,
146
137
  mutations,
147
- queryFactory
138
+ queryFactory,
148
139
  },
149
140
  recoil: {
150
141
  enabled: plugin.includes('recoil'),
151
142
  },
152
143
  messageComposer: {
153
- enabled: plugin.includes('message-composer')
144
+ enabled: plugin.includes('message-composer'),
154
145
  },
155
146
  messageBuilder: {
156
- enabled: plugin.includes('message-builder')
147
+ enabled: plugin.includes('message-builder'),
157
148
  },
158
149
  bundle: {
159
150
  enabled: bundle,
160
151
  scope: bundleScope,
161
- bundleFile
162
- }
152
+ bundleFile,
153
+ },
163
154
  };
164
155
  await (0, index_1.default)({
165
156
  contracts: [
166
157
  {
167
158
  name,
168
- dir: schema
169
- }
159
+ dir: schema,
160
+ },
170
161
  ],
171
162
  outPath: out,
172
- options
163
+ options,
173
164
  });
174
165
  };
@@ -13,10 +13,12 @@ const TMPDIR = (0, os_1.tmpdir)();
13
13
  const rnd = () => Math.random().toString(36).substring(2, 15) +
14
14
  Math.random().toString(36).substring(2, 15);
15
15
  const getPackages = (names) => {
16
- return names.map(pkg => {
16
+ return names
17
+ .map((pkg) => {
17
18
  const { name, version } = (0, parse_package_name_1.parse)(pkg);
18
19
  return `${name}@${version}`;
19
- }).join(' ');
20
+ })
21
+ .join(' ');
20
22
  };
21
23
  exports.default = async (argv) => {
22
24
  // don't prompt if we got this...
@@ -29,7 +31,7 @@ exports.default = async (argv) => {
29
31
  try {
30
32
  thisPackage = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(cur, 'package.json'), 'utf-8'));
31
33
  }
32
- catch (e) {
34
+ catch {
33
35
  throw new Error('make sure you are inside of a telescope package!');
34
36
  }
35
37
  // what are we installing?
@@ -48,14 +50,14 @@ exports.default = async (argv) => {
48
50
  'stargaze-vending-factory',
49
51
  'stargaze-vending-minter',
50
52
  'stargaze-whitelist',
51
- 'wasmswap'
52
- ].map(name => {
53
+ 'wasmswap',
54
+ ].map((name) => {
53
55
  return {
54
56
  name,
55
- value: `@cosmjson/${name}`
57
+ value: `@cosmjson/${name}`,
56
58
  };
57
- })
58
- }
59
+ }),
60
+ },
59
61
  ], argv);
60
62
  // install
61
63
  if (!Array.isArray(pkg))
@@ -65,26 +67,28 @@ exports.default = async (argv) => {
65
67
  process.chdir(tmp);
66
68
  (0, shelljs_1.exec)(`npm install ${getPackages(pkg)} --production --prefix ./smart-contracts`);
67
69
  // protos
68
- const pkgs = (0, glob_1.sync)('./smart-contracts/**/package.json');
70
+ const pkgs = (0, glob_1.globSync)('./smart-contracts/**/package.json').sort();
69
71
  const cmds = pkgs
70
- .filter((f) => { return f !== './smart-contracts/package.json'; })
72
+ .filter((f) => {
73
+ return f !== './smart-contracts/package.json';
74
+ })
71
75
  .map((f) => (0, path_1.resolve)((0, path_1.join)(tmp, f)))
72
76
  .map((conf) => {
73
77
  const extDir = (0, path_1.dirname)(conf);
74
78
  const dir = extDir.split('node_modules/')[1];
75
79
  const dst = (0, path_1.basename)(dir);
76
- const files = (0, glob_1.sync)(`${extDir}/**/*`, { nodir: true });
77
- files.forEach(f => {
78
- if ((0, path_1.extname)(f) === '.json'
79
- || f === 'package.json'
80
- || /license/i.test(f)
81
- || /readme/i.test(f))
80
+ const files = (0, glob_1.globSync)(`${extDir}/**/*`, { nodir: true }).sort();
81
+ files.forEach((f) => {
82
+ if ((0, path_1.extname)(f) === '.json' ||
83
+ f === 'package.json' ||
84
+ /license/i.test(f) ||
85
+ /readme/i.test(f))
82
86
  return;
83
87
  (0, rimraf_1.sync)(f);
84
88
  });
85
89
  return [extDir, (0, path_1.resolve)((0, path_1.join)(cur, 'contracts', dst)), dir];
86
90
  });
87
- // move protos
91
+ // move protos
88
92
  for (const [src, dst, pkg] of cmds) {
89
93
  (0, rimraf_1.sync)(dst);
90
94
  console.log(`installing ${pkg}...`);
@@ -97,7 +101,7 @@ exports.default = async (argv) => {
97
101
  thisPackage.devDependencies = thisPackage.devDependencies ?? {};
98
102
  thisPackage.devDependencies = {
99
103
  ...thisPackage.devDependencies,
100
- ...deps
104
+ ...deps,
101
105
  };
102
106
  thisPackage.devDependencies = Object.fromEntries(Object.entries(thisPackage.devDependencies).sort());
103
107
  (0, fs_1.writeFileSync)((0, path_1.join)(cur, 'package.json'), JSON.stringify(thisPackage, null, 2));
@@ -1,6 +1,6 @@
1
1
  import generate from '@babel/generator';
2
2
  import * as t from '@babel/types';
3
- import { BuilderContext, defaultOptions } from '@cosmwasm/ts-codegen-ast';
3
+ import { BuilderContext, defaultOptions, } from '@cosmwasm/ts-codegen-ast';
4
4
  import { pascal } from 'case';
5
5
  import deepmerge from 'deepmerge';
6
6
  import { writeFileSync } from 'fs';
@@ -24,25 +24,22 @@ const defaultOpts = {
24
24
  bundle: {
25
25
  enabled: true,
26
26
  scope: 'contracts',
27
- bundleFile: 'bundle.ts'
27
+ bundleFile: 'bundle.ts',
28
28
  },
29
- useShorthandCtor: true
29
+ useShorthandCtor: true,
30
30
  };
31
- ;
32
- ;
33
- ;
34
31
  function getContract(contractOpt) {
35
32
  if (typeof contractOpt === 'string') {
36
33
  const name = basename(contractOpt);
37
34
  const contractName = pascal(name);
38
35
  return {
39
36
  name: contractName,
40
- dir: contractOpt
37
+ dir: contractOpt,
41
38
  };
42
39
  }
43
40
  return {
44
41
  name: pascal(contractOpt.name),
45
- dir: contractOpt.dir
42
+ dir: contractOpt.dir,
46
43
  };
47
44
  }
48
45
  export class TSBuilder {
@@ -63,7 +60,7 @@ export class TSBuilder {
63
60
  if (plugins && plugins.length) {
64
61
  this.plugins.push(...plugins);
65
62
  }
66
- this.plugins.forEach(plugin => plugin.setBuilder(this));
63
+ this.plugins.forEach((plugin) => plugin.setBuilder(this));
67
64
  }
68
65
  async build() {
69
66
  await this.process();
@@ -75,7 +72,7 @@ export class TSBuilder {
75
72
  const contract = getContract(contractOpt);
76
73
  //resolve contract schema.
77
74
  const contractInfo = await readSchemas({
78
- schemaDir: contract.dir
75
+ schemaDir: contract.dir,
79
76
  });
80
77
  //lifecycle and plugins.
81
78
  await this.render('main', contract.name, contractInfo);
@@ -113,18 +110,13 @@ export class TSBuilder {
113
110
  const bundlePath = join(this.options?.bundle?.bundlePath ?? this.outPath, bundleFile);
114
111
  const bundleVariables = {};
115
112
  const importPaths = [];
116
- allFiles.forEach(file => {
113
+ allFiles.forEach((file) => {
117
114
  createFileBundle(`${this.options.bundle.scope}.${file.contract}`, file.filename, bundlePath, importPaths, bundleVariables);
118
115
  });
119
116
  const ast = recursiveModuleBundle(bundleVariables);
120
- const nodes = [
121
- ...importPaths,
122
- ...ast
123
- ];
117
+ const nodes = [...importPaths, ...ast];
124
118
  // @ts-ignore
125
- let code = generate(t.program(
126
- // @ts-ignore
127
- nodes)).code;
119
+ let code = generate(t.program(nodes)).code;
128
120
  if (this.options?.bundle?.bundlePath) {
129
121
  mkdirp(this.options?.bundle?.bundlePath);
130
122
  }
@@ -2,20 +2,22 @@ import * as t from '@babel/types';
2
2
  import nested from 'nested-obj';
3
3
  import { dirname, extname, relative } from 'path';
4
4
  export const recursiveModuleBundle = (obj) => {
5
- return Object.keys(obj).map(key => {
5
+ return Object.keys(obj).map((key) => {
6
6
  const value = obj[key];
7
7
  if (typeof value === 'object' && value && value.__export) {
8
8
  // e.g. abci
9
9
  // 1. create variable for abci
10
10
  // 2. splat ALL _0, parms into abci
11
11
  // 3. export that variable
12
- const nmspc = t.variableDeclaration('const', [t.variableDeclarator(t.identifier(key), t.objectExpression(Object.keys(obj[key])
13
- .filter(a => a !== '__export')
14
- .filter(a => a.startsWith('_'))
15
- .map(a => t.spreadElement(t.identifier(a)))))]);
12
+ const nmspc = t.variableDeclaration('const', [
13
+ t.variableDeclarator(t.identifier(key), t.objectExpression(Object.keys(obj[key])
14
+ .filter((a) => a !== '__export')
15
+ .filter((a) => a.startsWith('_'))
16
+ .map((a) => t.spreadElement(t.identifier(a))))),
17
+ ]);
16
18
  const others = Object.keys(obj[key])
17
- .filter(a => a !== '__export')
18
- .filter(a => !a.startsWith('_'));
19
+ .filter((a) => a !== '__export')
20
+ .filter((a) => !a.startsWith('_'));
19
21
  if (others.length) {
20
22
  throw new Error('namespace and package not supported, yet.');
21
23
  }
@@ -32,9 +34,7 @@ export const recursiveModuleBundle = (obj) => {
32
34
  }
33
35
  });
34
36
  };
35
- export const importNamespace = (ident, path) => t.importDeclaration([
36
- t.importNamespaceSpecifier(t.identifier(ident))
37
- ], t.stringLiteral(path.replace(extname(path), '')));
37
+ export const importNamespace = (ident, path) => t.importDeclaration([t.importNamespaceSpecifier(t.identifier(ident))], t.stringLiteral(path.replace(extname(path), '')));
38
38
  let counter = 0;
39
39
  export const createFileBundle = (pkg, filename, bundleFile, importPaths, bundleVariables) => {
40
40
  let rel = relative(dirname(bundleFile), filename);
package/esm/cli.js CHANGED
@@ -6,8 +6,8 @@ const question = [
6
6
  type: 'fuzzy',
7
7
  name: 'cmd',
8
8
  message: 'what do you want to do?',
9
- choices: Object.keys(commands)
10
- }
9
+ choices: Object.keys(commands),
10
+ },
11
11
  ];
12
12
  export const cli = async (argv) => {
13
13
  let { cmd } = await prompt(question, argv);
@@ -1,9 +1,9 @@
1
1
  import dargs from 'dargs';
2
+ import { lstatSync, readFileSync, writeFileSync } from 'fs';
3
+ import { globSync as glob } from 'glob';
4
+ import * as path from 'path';
2
5
  import * as shell from 'shelljs';
3
6
  import { prompt } from '../utils/prompt';
4
- const glob = require('glob').sync;
5
- const fs = require('fs');
6
- const path = require('path');
7
7
  const repo = 'https://github.com/hyperweb-io/ts-codegen-module-boilerplate';
8
8
  export default async (argv) => {
9
9
  if (!shell.which('git')) {
@@ -15,11 +15,11 @@ export default async (argv) => {
15
15
  type: 'string',
16
16
  name: 'name',
17
17
  message: 'Enter your new module name',
18
- }
18
+ },
19
19
  ], argv);
20
20
  shell.exec(`git clone ${repo} ${name}`);
21
21
  shell.cd(name);
22
- const questions = JSON.parse(fs.readFileSync(`.questions.json`));
22
+ const questions = JSON.parse(readFileSync(`.questions.json`, 'utf-8'));
23
23
  const fullname = shell
24
24
  .exec('git config --global user.name', { silent: true })
25
25
  .trim();
@@ -58,19 +58,20 @@ export default async (argv) => {
58
58
  }
59
59
  const files = []
60
60
  .concat(glob(process.cwd() + '/**/.*'))
61
- .concat(glob(process.cwd() + '/**/*'));
61
+ .concat(glob(process.cwd() + '/**/*'))
62
+ .sort();
62
63
  for (let i = 0; i < files.length; i++) {
63
64
  const templateFile = files[i];
64
- if (fs.lstatSync(templateFile).isDirectory())
65
+ if (lstatSync(templateFile).isDirectory())
65
66
  continue;
66
- let content = fs.readFileSync(templateFile).toString();
67
+ let content = readFileSync(templateFile, 'utf-8');
67
68
  if (path.basename(templateFile) === 'LICENSE' &&
68
69
  license.__LICENSE__ === 'closed') {
69
70
  content = `Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> - All Rights Reserved
70
71
  Unauthorized copying via any medium is strictly prohibited
71
72
  Proprietary and confidential`;
72
73
  }
73
- Object.keys(results).forEach(key => {
74
+ Object.keys(results).forEach((key) => {
74
75
  if (/^__/.test(key)) {
75
76
  content = content.replace(new RegExp(key, 'g'), results[key]);
76
77
  }
@@ -89,7 +90,7 @@ Proprietary and confidential`;
89
90
  // if (path.basename(templateFile) === 'README.md') {
90
91
  // content = `# ${results.__MODULENAME__}`;
91
92
  // }
92
- fs.writeFileSync(templateFile, content);
93
+ writeFileSync(templateFile, content);
93
94
  }
94
95
  shell.rm('-rf', '.git');
95
96
  shell.rm('-rf', '.questions.json');