@umijs/utils 4.0.0-canary.20220317.2 → 4.0.0-canary.20220318.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.
@@ -3,6 +3,7 @@ import Generator from '../Generator/Generator';
3
3
  interface IOpts {
4
4
  path: string;
5
5
  target: string;
6
+ baseDir?: string;
6
7
  data?: any;
7
8
  questions?: prompts.PromptObject[];
8
9
  }
@@ -11,7 +12,7 @@ export default class BaseGenerator extends Generator {
11
12
  target: string;
12
13
  data: any;
13
14
  questions: prompts.PromptObject[];
14
- constructor({ path, target, data, questions }: IOpts);
15
+ constructor({ path, target, data, questions, baseDir }: IOpts);
15
16
  prompting(): prompts.PromptObject<string>[];
16
17
  writing(): Promise<void>;
17
18
  }
@@ -17,8 +17,8 @@ const path_1 = require("path");
17
17
  const fs_extra_1 = __importDefault(require("../../compiled/fs-extra"));
18
18
  const Generator_1 = __importDefault(require("../Generator/Generator"));
19
19
  class BaseGenerator extends Generator_1.default {
20
- constructor({ path, target, data, questions }) {
21
- super({ cwd: process.cwd(), args: data });
20
+ constructor({ path, target, data, questions, baseDir }) {
21
+ super({ baseDir: baseDir || target, args: data });
22
22
  this.path = path;
23
23
  this.target = target;
24
24
  this.data = data;
@@ -1,7 +1,8 @@
1
1
  import prompts from '../../compiled/prompts';
2
- declare const generateFile: ({ path, target, data, questions, }: {
2
+ declare const generateFile: ({ path, target, baseDir, data, questions, }: {
3
3
  path: string;
4
4
  target: string;
5
+ baseDir?: string | undefined;
5
6
  data?: any;
6
7
  questions?: prompts.PromptObject<string>[] | undefined;
7
8
  }) => Promise<void>;
@@ -13,10 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const BaseGenerator_1 = __importDefault(require("./BaseGenerator"));
16
- const generateFile = ({ path, target, data, questions, }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const generateFile = ({ path, target, baseDir, data, questions, }) => __awaiter(void 0, void 0, void 0, function* () {
17
17
  const generator = new BaseGenerator_1.default({
18
18
  path,
19
19
  target,
20
+ baseDir,
20
21
  data,
21
22
  questions,
22
23
  });
@@ -1,13 +1,13 @@
1
1
  import yParser from '../../compiled/yargs-parser';
2
2
  interface IOpts {
3
- cwd: string;
3
+ baseDir: string;
4
4
  args: yParser.Arguments;
5
5
  }
6
6
  declare class Generator {
7
- cwd: string;
7
+ baseDir: string;
8
8
  args: yParser.Arguments;
9
9
  prompts: any;
10
- constructor({ cwd, args }: IOpts);
10
+ constructor({ baseDir, args }: IOpts);
11
11
  run(): Promise<void>;
12
12
  prompting(): any;
13
13
  writing(): Promise<void>;
@@ -20,8 +20,8 @@ const glob_1 = __importDefault(require("../../compiled/glob"));
20
20
  const mustache_1 = __importDefault(require("../../compiled/mustache"));
21
21
  const prompts_1 = __importDefault(require("../../compiled/prompts"));
22
22
  class Generator {
23
- constructor({ cwd, args }) {
24
- this.cwd = cwd;
23
+ constructor({ baseDir, args }) {
24
+ this.baseDir = baseDir;
25
25
  this.args = args;
26
26
  this.prompts = {};
27
27
  }
@@ -42,7 +42,7 @@ class Generator {
42
42
  const tpl = (0, fs_1.readFileSync)(opts.templatePath, 'utf-8');
43
43
  const content = mustache_1.default.render(tpl, opts.context);
44
44
  fs_extra_1.default.mkdirpSync((0, path_1.dirname)(opts.target));
45
- console.log(`${chalk_1.default.green('Write:')} ${(0, path_1.relative)(this.cwd, opts.target)}`);
45
+ console.log(`${chalk_1.default.green('Write:')} ${(0, path_1.relative)(this.baseDir, opts.target)}`);
46
46
  (0, fs_1.writeFileSync)(opts.target, content, 'utf-8');
47
47
  }
48
48
  copyDirectory(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/utils",
3
- "version": "4.0.0-canary.20220317.2",
3
+ "version": "4.0.0-canary.20220318.1",
4
4
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/utils#readme",
5
5
  "bugs": "https://github.com/umijs/umi-next/issues",
6
6
  "repository": {