@cabloy/cli 1.0.8 → 1.0.10

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.
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=bean.cli.js.map
@@ -1,11 +0,0 @@
1
- import { IConsoleLogData, IConsoleLogOptions } from '../types/console.js';
2
- import { BeanCliBase } from './bean.cli.base.js';
3
- export declare class LocalConsole {
4
- cli: BeanCliBase;
5
- constructor(cli: any);
6
- get options(): import("../index.js").CmdOptions;
7
- get context(): import("../index.js").ICommandContext;
8
- log(data?: IConsoleLogData | string, options?: IConsoleLogOptions): Promise<void>;
9
- _adjustText(prefix: any, text: any): string;
10
- }
11
- //# sourceMappingURL=local.console.d.ts.map
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalConsole = void 0;
4
- class LocalConsole {
5
- constructor(cli) {
6
- this.cli = cli;
7
- }
8
- get options() {
9
- return this.cli.options;
10
- }
11
- get context() {
12
- return this.cli.options.context;
13
- }
14
- async log(data, options = {}) {
15
- if (!data)
16
- return;
17
- // data
18
- if (typeof data !== 'object') {
19
- data = { text: String(data) };
20
- }
21
- let { /* progressNo,*/ total, progress, text } = data;
22
- // logPrefix
23
- const logPrefix = options.logPrefix;
24
- if (logPrefix) {
25
- text = this._adjustText(logPrefix, text);
26
- }
27
- // fallback
28
- if (!this.cli.terminal) {
29
- if (total !== undefined && progress !== undefined) {
30
- const progressValid = progress >= 0;
31
- const progressText = `(${progressValid ? progress + 1 : '-'}/${total})`;
32
- if (progressValid) {
33
- text = this._adjustText(`${progressText}=> `, text);
34
- }
35
- }
36
- return console.log(text);
37
- }
38
- }
39
- _adjustText(prefix, text) {
40
- return String(text)
41
- .split('\n')
42
- .map(item => (item ? prefix + item : item))
43
- .join('\n');
44
- }
45
- }
46
- exports.LocalConsole = LocalConsole;
47
- //# sourceMappingURL=local.console.js.map
@@ -1,80 +0,0 @@
1
- import Chalk from 'chalk';
2
- import TableClass, { TableConstructorOptions } from 'cli-table3';
3
- import * as ModuleInfo from '@cabloy/module-info';
4
- import { BeanCliBase } from './bean.cli.base.js';
5
- export declare class LocalHelper {
6
- cli: BeanCliBase;
7
- ProcessHelper: any;
8
- constructor(cli: any);
9
- get options(): import("../index.js").CmdOptions;
10
- get context(): import("../index.js").ICommandContext;
11
- get console(): import("./local.console.js").LocalConsole;
12
- get template(): import("./local.template.js").LocalTemplate;
13
- get moduleConfig(): {
14
- sets: {
15
- core: string;
16
- api: string;
17
- front: string;
18
- };
19
- helper: {
20
- chalk: {
21
- options: {
22
- level: number;
23
- };
24
- };
25
- boxen: {
26
- options: {
27
- padding: number;
28
- margin: number;
29
- align: string;
30
- borderColor: string;
31
- borderStyle: string;
32
- };
33
- };
34
- };
35
- template: {
36
- render: {
37
- fileMapping: {
38
- gitignore: string;
39
- _gitignore: string;
40
- '_.gitignore': string;
41
- '_package.json': string;
42
- '_.eslintrc': string;
43
- '_.eslintignore': string;
44
- '_.npmignore': string;
45
- '_.eslintrc.js': string;
46
- '_jsconfig.json': string;
47
- '_tsconfig.json': string;
48
- '_tsconfig.base.json': string;
49
- '_tsconfig.build.json': string;
50
- };
51
- ignore: string[];
52
- };
53
- };
54
- };
55
- get chalk(): Chalk.Chalk;
56
- get Table(): TableClass;
57
- get cwd(): string;
58
- newChalk(options?: any): Chalk.Chalk;
59
- newTable(options: TableConstructorOptions): TableClass.Table;
60
- boxen({ text, options }: any): string;
61
- firstCharToCapitalize(name: string): string;
62
- relativeNameToCapitalize(moduleName: string): string;
63
- parseModuleInfo(moduleName: any): ModuleInfo.IModuleInfo;
64
- findModule(moduleName: any): ModuleInfo.IModule;
65
- parseSuiteInfo(suiteName: any): ModuleInfo.IModuleInfo;
66
- findSuite(suiteName: any): ModuleInfo.ISuite;
67
- ensureDir(dir: any): Promise<any>;
68
- pnpmInstall(): Promise<void>;
69
- formatFile({ fileName, logPrefix }: any): Promise<any>;
70
- spawnBin({ cmd, args, options }: any): Promise<any>;
71
- spawnCmd({ cmd, args, options }: any): Promise<any>;
72
- spawnExe({ cmd, args, options }: any): Promise<any>;
73
- spawn({ cmd, args, options }: {
74
- cmd: any;
75
- args?: never[] | undefined;
76
- options?: {} | undefined;
77
- }): Promise<any>;
78
- gitCommit({ cwd, message }: any): Promise<any>;
79
- }
80
- //# sourceMappingURL=local.helper.d.ts.map
@@ -1,147 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
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
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.LocalHelper = void 0;
30
- const chalk_1 = __importDefault(require("chalk"));
31
- const cli_table3_1 = __importDefault(require("cli-table3"));
32
- const boxen_1 = __importDefault(require("boxen"));
33
- const fs_extra_1 = __importDefault(require("fs-extra"));
34
- const ModuleInfo = __importStar(require("@cabloy/module-info"));
35
- const process_helper_1 = require("@cabloy/process-helper");
36
- const config_js_1 = require("../config.js");
37
- class LocalHelper {
38
- constructor(cli) {
39
- this.cli = cli;
40
- this.ProcessHelper = new process_helper_1.ProcessHelper(this.cwd, this.console);
41
- }
42
- get options() {
43
- return this.cli.options;
44
- }
45
- get context() {
46
- return this.cli.options.context;
47
- }
48
- get console() {
49
- return this.cli.console;
50
- }
51
- get template() {
52
- return this.cli.template;
53
- }
54
- get moduleConfig() {
55
- return config_js_1.commandsConfig;
56
- }
57
- get chalk() {
58
- return this.newChalk();
59
- }
60
- get Table() {
61
- return cli_table3_1.default;
62
- }
63
- get cwd() {
64
- return this.context.argv.projectPath;
65
- }
66
- newChalk(options) {
67
- if (!options) {
68
- options = this.moduleConfig.helper.chalk.options;
69
- }
70
- return new chalk_1.default.Instance(options);
71
- }
72
- newTable(options) {
73
- return new cli_table3_1.default(options);
74
- }
75
- boxen({ text, options }) {
76
- if (!options) {
77
- options = this.moduleConfig.helper.boxen.options;
78
- }
79
- return (0, boxen_1.default)(text, options);
80
- }
81
- firstCharToCapitalize(name) {
82
- return name.charAt(0).toUpperCase() + name.substring(1);
83
- }
84
- relativeNameToCapitalize(moduleName) {
85
- return moduleName
86
- .split('-')
87
- .map(name => {
88
- return this.firstCharToCapitalize(name);
89
- })
90
- .join('');
91
- }
92
- parseModuleInfo(moduleName) {
93
- const moduleInfo = ModuleInfo.parseInfoPro(moduleName, 'api', 'module');
94
- if (!moduleInfo)
95
- throw new Error(`module name is not valid: ${moduleName}`);
96
- return moduleInfo;
97
- }
98
- findModule(moduleName) {
99
- const moduleInfo = this.parseModuleInfo(moduleName);
100
- return this.cli.modulesMeta.modules[moduleInfo.relativeName];
101
- }
102
- parseSuiteInfo(suiteName) {
103
- const suiteInfo = ModuleInfo.parseInfoPro(suiteName, 'api', 'suite');
104
- if (!suiteInfo)
105
- throw new Error(`suite name is not valid: ${suiteName}`);
106
- return suiteInfo;
107
- }
108
- findSuite(suiteName) {
109
- const suiteInfo = this.parseSuiteInfo(suiteName);
110
- return this.cli.modulesMeta.suites[suiteInfo.relativeName];
111
- }
112
- async ensureDir(dir) {
113
- await fs_extra_1.default.ensureDir(dir);
114
- return dir;
115
- }
116
- async pnpmInstall() {
117
- // args
118
- const args = ['install', '--force'];
119
- // log
120
- await this.console.log(`===> pnpm install --force`);
121
- // spawn
122
- await this.spawnCmd({
123
- cmd: 'pnpm',
124
- args,
125
- });
126
- }
127
- async formatFile({ fileName, logPrefix }) {
128
- return await this.ProcessHelper.formatFile({ fileName, logPrefix });
129
- }
130
- async spawnBin({ cmd, args, options }) {
131
- return await this.ProcessHelper.spawnBin({ cmd, args, options });
132
- }
133
- async spawnCmd({ cmd, args, options }) {
134
- return await this.ProcessHelper.spawnCmd({ cmd, args, options });
135
- }
136
- async spawnExe({ cmd, args, options }) {
137
- return await this.ProcessHelper.spawnExe({ cmd, args, options });
138
- }
139
- async spawn({ cmd, args = [], options = {} }) {
140
- return await this.ProcessHelper.spawn({ cmd, args, options });
141
- }
142
- async gitCommit({ cwd, message }) {
143
- return await this.ProcessHelper.gitCommit({ cwd, message });
144
- }
145
- }
146
- exports.LocalHelper = LocalHelper;
147
- //# sourceMappingURL=local.helper.js.map
@@ -1,97 +0,0 @@
1
- import { BeanCliBase } from './bean.cli.base.js';
2
- export declare class LocalTemplate {
3
- cli: BeanCliBase;
4
- constructor(cli: any);
5
- get options(): import("../index.js").CmdOptions;
6
- get context(): import("../index.js").ICommandContext;
7
- get console(): import("./local.console.js").LocalConsole;
8
- get helper(): import("./local.helper.js").LocalHelper;
9
- get moduleConfig(): {
10
- sets: {
11
- core: string;
12
- api: string;
13
- front: string;
14
- };
15
- helper: {
16
- chalk: {
17
- options: {
18
- level: number;
19
- };
20
- };
21
- boxen: {
22
- options: {
23
- padding: number;
24
- margin: number;
25
- align: string;
26
- borderColor: string;
27
- borderStyle: string;
28
- };
29
- };
30
- };
31
- template: {
32
- render: {
33
- fileMapping: {
34
- gitignore: string;
35
- _gitignore: string;
36
- '_.gitignore': string;
37
- '_package.json': string;
38
- '_.eslintrc': string;
39
- '_.eslintignore': string;
40
- '_.npmignore': string;
41
- '_.eslintrc.js': string;
42
- '_jsconfig.json': string;
43
- '_tsconfig.json': string;
44
- '_tsconfig.base.json': string;
45
- '_tsconfig.build.json': string;
46
- };
47
- ignore: string[];
48
- };
49
- };
50
- };
51
- get fileMapping(): {
52
- gitignore: string;
53
- _gitignore: string;
54
- '_.gitignore': string;
55
- '_package.json': string;
56
- '_.eslintrc': string;
57
- '_.eslintignore': string;
58
- '_.npmignore': string;
59
- '_.eslintrc.js': string;
60
- '_jsconfig.json': string;
61
- '_tsconfig.json': string;
62
- '_tsconfig.base.json': string;
63
- '_tsconfig.build.json': string;
64
- };
65
- get filesIgnore(): string[];
66
- resolveTemplatePath({ setName, path: _path }: any): string;
67
- renderBoilerplateAndSnippets({ targetDir, setName, snippetsPath, boilerplatePath }: any): Promise<void>;
68
- renderDir({ targetDir, templateDir }: any): Promise<any>;
69
- replaceTemplate(content: any, scope: any): any;
70
- getProperty(obj: any, name: any, sep?: any): any;
71
- _getProperty(obj: any, name: any, sep: any, forceObject: any): any;
72
- parseFileBaseName(basename: any): any;
73
- renderFile({ targetFile, templateFile }: any): Promise<void>;
74
- renderContent({ content }: any): Promise<any>;
75
- getEjsOptions(): {
76
- async: boolean;
77
- cache: boolean;
78
- compileDebug: boolean;
79
- outputFunctionName: string;
80
- rmWhitespace: boolean;
81
- };
82
- getEjsData(): {
83
- argv: import("../index.js").ICommandArgv;
84
- };
85
- getAstData(ast: any, snippet: any): {
86
- argv: import("../index.js").ICommandArgv;
87
- cli: BeanCliBase;
88
- ast: any;
89
- snippet: any;
90
- };
91
- applySnippets({ targetDir, snippetsDir }: any): Promise<void>;
92
- applySnippet({ targetFile, snippet }: any): Promise<void>;
93
- _parseSnippetFilePrefix(fileName: any): number;
94
- requireDynamic(file: any): any;
95
- private _requireDynamic_getFileTime;
96
- }
97
- //# sourceMappingURL=local.template.d.ts.map
@@ -1,299 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LocalTemplate = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- const egg_born_utils_1 = __importDefault(require("egg-born-utils"));
11
- const istextorbinary_1 = __importDefault(require("istextorbinary"));
12
- const ejs_1 = __importDefault(require("@zhennann/ejs"));
13
- const gogocode_1 = __importDefault(require("gogocode"));
14
- const config_js_1 = require("../config.js");
15
- class LocalTemplate {
16
- constructor(cli) {
17
- this.cli = cli;
18
- }
19
- get options() {
20
- return this.cli.options;
21
- }
22
- get context() {
23
- return this.cli.options.context;
24
- }
25
- get console() {
26
- return this.cli.console;
27
- }
28
- get helper() {
29
- return this.cli.helper;
30
- }
31
- get moduleConfig() {
32
- return config_js_1.commandsConfig;
33
- }
34
- get fileMapping() {
35
- return this.moduleConfig.template.render.fileMapping;
36
- }
37
- get filesIgnore() {
38
- return this.moduleConfig.template.render.ignore;
39
- }
40
- resolveTemplatePath({ setName, path: _path }) {
41
- const sets = this.moduleConfig.sets;
42
- const modulePath = require.resolve(`${sets[setName]}/package.json`);
43
- return path_1.default.join(path_1.default.dirname(modulePath), 'cli/templates', _path);
44
- }
45
- async renderBoilerplateAndSnippets({ targetDir, setName, snippetsPath, boilerplatePath }) {
46
- // first
47
- if (snippetsPath) {
48
- const snippetsDir = this.resolveTemplatePath({
49
- setName,
50
- path: snippetsPath,
51
- });
52
- await this.applySnippets({ targetDir, snippetsDir });
53
- }
54
- // then
55
- if (boilerplatePath) {
56
- const templateDir = this.resolveTemplatePath({
57
- setName,
58
- path: boilerplatePath,
59
- });
60
- await this.renderDir({ targetDir, templateDir });
61
- }
62
- }
63
- async renderDir({ targetDir, templateDir }) {
64
- const { argv } = this.context;
65
- // files
66
- const files = egg_born_utils_1.default.tools.globbySync('**/*', {
67
- cwd: templateDir,
68
- dot: true,
69
- onlyFiles: false,
70
- followSymlinkedDirectories: false,
71
- });
72
- // loop
73
- for (const file of files) {
74
- const { dir: dirname, base: basename } = path_1.default.parse(file);
75
- if (this.filesIgnore.includes(basename))
76
- continue;
77
- const templateFile = path_1.default.join(templateDir, file);
78
- const fileName = this.parseFileBaseName(basename);
79
- const parentPath = path_1.default.join(targetDir, dirname);
80
- const targetFile = path_1.default.join(parentPath, this.replaceTemplate(fileName, argv));
81
- await this.renderFile({ targetFile, templateFile });
82
- if (fileName !== '.gitkeep') {
83
- const gitkeep = path_1.default.join(parentPath, '.gitkeep');
84
- if (fs_1.default.existsSync(gitkeep)) {
85
- fs_1.default.unlinkSync(gitkeep);
86
- }
87
- }
88
- }
89
- return files;
90
- }
91
- replaceTemplate(content, scope) {
92
- if (!content)
93
- return null;
94
- return content.toString().replace(/(\\)?{{ *([\w\.]+) *}}/g, (block, skip, key) => {
95
- if (skip) {
96
- return block.substring(skip.length);
97
- }
98
- const value = this.getProperty(scope, key);
99
- return value !== undefined ? value : '';
100
- });
101
- }
102
- getProperty(obj, name, sep) {
103
- return this._getProperty(obj, name, sep, false);
104
- }
105
- _getProperty(obj, name, sep, forceObject) {
106
- if (!obj)
107
- return undefined;
108
- const names = name.split(sep || '.');
109
- // loop
110
- for (const name of names) {
111
- if (obj[name] === undefined || obj[name] === null) {
112
- if (forceObject) {
113
- obj[name] = {};
114
- }
115
- else {
116
- obj = obj[name];
117
- break;
118
- }
119
- }
120
- obj = obj[name];
121
- }
122
- return obj;
123
- }
124
- parseFileBaseName(basename) {
125
- let fileName = this.fileMapping[basename] || basename;
126
- if (fileName.lastIndexOf('_') === fileName.length - 1) {
127
- fileName = fileName.substring(0, fileName.length - 1);
128
- }
129
- return fileName;
130
- }
131
- async renderFile({ targetFile, templateFile }) {
132
- const stats = fs_1.default.lstatSync(templateFile);
133
- if (stats.isSymbolicLink()) {
134
- const target = fs_1.default.readlinkSync(templateFile);
135
- fs_1.default.symlinkSync(target, targetFile);
136
- await this.console.log(`${targetFile} link to ${target}`);
137
- }
138
- else if (stats.isDirectory()) {
139
- await this.helper.ensureDir(targetFile);
140
- }
141
- else if (stats.isFile()) {
142
- const content = fs_1.default.readFileSync(templateFile);
143
- await this.console.log(`write to ${targetFile}`);
144
- // check if content is a text file
145
- let result;
146
- let changed;
147
- if (!istextorbinary_1.default.isTextSync(templateFile, content)) {
148
- result = content;
149
- }
150
- else {
151
- const _content = content.toString('utf8');
152
- result = await this.renderContent({ content: _content });
153
- changed = _content !== result;
154
- }
155
- // save
156
- fs_1.default.writeFileSync(targetFile, result);
157
- // format
158
- if (changed) {
159
- await this.helper.formatFile({ fileName: targetFile, logPrefix: 'format: ' });
160
- }
161
- }
162
- else {
163
- await this.console.log(`ignore ${templateFile}, only support file, dir, symlink`);
164
- }
165
- }
166
- async renderContent({ content }) {
167
- if (!content)
168
- return content;
169
- const data = this.getEjsData();
170
- const options = this.getEjsOptions();
171
- return await ejs_1.default.render(content, data, options);
172
- }
173
- getEjsOptions() {
174
- return {
175
- async: true,
176
- cache: false,
177
- compileDebug: true,
178
- outputFunctionName: 'echo',
179
- rmWhitespace: false,
180
- };
181
- }
182
- getEjsData() {
183
- return {
184
- ...this.context,
185
- };
186
- }
187
- getAstData(ast, snippet) {
188
- return {
189
- cli: this.cli,
190
- ast,
191
- snippet,
192
- ...this.context,
193
- };
194
- }
195
- async applySnippets({ targetDir, snippetsDir }) {
196
- // snippets
197
- let files = egg_born_utils_1.default.tools.globbySync('*.cjs', {
198
- cwd: snippetsDir,
199
- onlyFiles: true,
200
- });
201
- // snippets sort
202
- files = files
203
- .filter(item => item[0] !== '-')
204
- .sort((a, b) => this._parseSnippetFilePrefix(a) - this._parseSnippetFilePrefix(b));
205
- // for
206
- for (const file of files) {
207
- const snippetTemplatePath = path_1.default.join(snippetsDir, file);
208
- const snippet = this.requireDynamic(snippetTemplatePath);
209
- if (!snippet.file) {
210
- throw new Error(`should provider file path for: ${file}`);
211
- }
212
- let fileName;
213
- if (typeof snippet.file === 'function') {
214
- fileName = snippet.file(this.getEjsData());
215
- }
216
- else {
217
- fileName = await this.renderContent({ content: snippet.file });
218
- }
219
- if (!fileName) {
220
- // means ignore, so do nothing
221
- }
222
- else {
223
- const targetFile = path_1.default.join(targetDir, fileName);
224
- await this.applySnippet({ targetFile, snippet });
225
- }
226
- }
227
- }
228
- async applySnippet({ targetFile, snippet }) {
229
- await this.console.log(`apply changes to ${targetFile}`);
230
- // source code
231
- let sourceCode;
232
- if (fs_1.default.existsSync(targetFile)) {
233
- sourceCode = fs_1.default.readFileSync(targetFile);
234
- sourceCode = sourceCode.toString('utf8');
235
- }
236
- else {
237
- if (!snippet.init) {
238
- throw new Error(`should provider init content for: ${targetFile}`);
239
- }
240
- sourceCode = await this.renderContent({ content: snippet.init });
241
- }
242
- // language
243
- const language = snippet.parseOptions && snippet.parseOptions.language;
244
- // transform
245
- let outputCode;
246
- if (language === 'plain') {
247
- const ast = sourceCode;
248
- const outAst = await snippet.transform(this.getAstData(ast, snippet));
249
- outputCode = outAst;
250
- }
251
- else if (language === 'json') {
252
- const ast = JSON.parse(sourceCode);
253
- const outAst = await snippet.transform(this.getAstData(ast, snippet));
254
- outputCode = JSON.stringify(outAst, null, 2);
255
- }
256
- else {
257
- const ast = (0, gogocode_1.default)(sourceCode, { parseOptions: snippet.parseOptions });
258
- const outAst = await snippet.transform(this.getAstData(ast, snippet));
259
- outputCode = outAst.root().generate();
260
- }
261
- // save
262
- fs_1.default.writeFileSync(targetFile, outputCode);
263
- // format
264
- await this.helper.formatFile({ fileName: targetFile, logPrefix: 'format: ' });
265
- }
266
- _parseSnippetFilePrefix(fileName) {
267
- const num = fileName.split('-')[0];
268
- if (!num || isNaN(num))
269
- return 10000;
270
- return parseInt(num);
271
- }
272
- requireDynamic(file) {
273
- if (!file)
274
- throw new Error('file should not empty');
275
- let instance = require(file);
276
- const mtime = this._requireDynamic_getFileTime(file);
277
- if (instance.__requireDynamic_mtime === undefined) {
278
- instance.__requireDynamic_mtime = mtime;
279
- }
280
- else if (instance.__requireDynamic_mtime !== mtime) {
281
- delete require.cache[require.resolve(file)];
282
- instance = require(file);
283
- instance.__requireDynamic_mtime = mtime;
284
- }
285
- return instance;
286
- }
287
- _requireDynamic_getFileTime(file) {
288
- if (!path_1.default.isAbsolute(file))
289
- return null;
290
- const exists = fs_extra_1.default.pathExistsSync(file);
291
- if (!exists)
292
- return null;
293
- // stat
294
- const stat = fs_extra_1.default.statSync(file);
295
- return stat.mtime.valueOf();
296
- }
297
- }
298
- exports.LocalTemplate = LocalTemplate;
299
- //# sourceMappingURL=local.template.js.map