@umijs/utils 4.0.0-rc.14 → 4.0.0-rc.17

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,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -27,31 +18,32 @@ class BaseGenerator extends Generator_1.default {
27
18
  prompting() {
28
19
  return this.questions;
29
20
  }
30
- writing() {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const context = Object.assign(Object.assign({}, this.data), this.prompts);
33
- if ((0, fs_1.statSync)(this.path).isDirectory()) {
34
- this.copyDirectory({
35
- context,
36
- path: this.path,
21
+ async writing() {
22
+ const context = {
23
+ ...this.data,
24
+ ...this.prompts,
25
+ };
26
+ if ((0, fs_1.statSync)(this.path).isDirectory()) {
27
+ this.copyDirectory({
28
+ context,
29
+ path: this.path,
30
+ target: this.target,
31
+ });
32
+ }
33
+ else {
34
+ if (this.path.endsWith('.tpl')) {
35
+ this.copyTpl({
36
+ templatePath: this.path,
37
37
  target: this.target,
38
+ context,
38
39
  });
39
40
  }
40
41
  else {
41
- if (this.path.endsWith('.tpl')) {
42
- this.copyTpl({
43
- templatePath: this.path,
44
- target: this.target,
45
- context,
46
- });
47
- }
48
- else {
49
- const absTarget = this.target;
50
- fs_extra_1.default.mkdirpSync((0, path_1.dirname)(absTarget));
51
- (0, fs_1.copyFileSync)(this.path, absTarget);
52
- }
42
+ const absTarget = this.target;
43
+ fs_extra_1.default.mkdirpSync((0, path_1.dirname)(absTarget));
44
+ (0, fs_1.copyFileSync)(this.path, absTarget);
53
45
  }
54
- });
46
+ }
55
47
  }
56
48
  }
57
49
  exports.default = BaseGenerator;
@@ -1,19 +1,10 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  const BaseGenerator_1 = __importDefault(require("./BaseGenerator"));
16
- const generateFile = ({ path, target, baseDir, data, questions, }) => __awaiter(void 0, void 0, void 0, function* () {
7
+ const generateFile = async ({ path, target, baseDir, data, questions, }) => {
17
8
  const generator = new BaseGenerator_1.default({
18
9
  path,
19
10
  target,
@@ -21,6 +12,6 @@ const generateFile = ({ path, target, baseDir, data, questions, }) => __awaiter(
21
12
  data,
22
13
  questions,
23
14
  });
24
- yield generator.run();
25
- });
15
+ await generator.run();
16
+ };
26
17
  exports.default = generateFile;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -25,19 +16,15 @@ class Generator {
25
16
  this.args = args;
26
17
  this.prompts = {};
27
18
  }
28
- run() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const questions = this.prompting();
31
- this.prompts = yield (0, prompts_1.default)(questions);
32
- yield this.writing();
33
- });
19
+ async run() {
20
+ const questions = this.prompting();
21
+ this.prompts = await (0, prompts_1.default)(questions);
22
+ await this.writing();
34
23
  }
35
24
  prompting() {
36
25
  return [];
37
26
  }
38
- writing() {
39
- return __awaiter(this, void 0, void 0, function* () { });
40
- }
27
+ async writing() { }
41
28
  copyTpl(opts) {
42
29
  const tpl = (0, fs_1.readFileSync)(opts.templatePath, 'utf-8');
43
30
  const content = mustache_1.default.render(tpl, opts.context);
@@ -43,7 +43,9 @@ function installDeps({ opts, cwd = process.cwd(), }) {
43
43
  .join(' '), {
44
44
  encoding: 'utf8',
45
45
  cwd,
46
- env: Object.assign({}, process.env),
46
+ env: {
47
+ ...process.env,
48
+ },
47
49
  stderr: 'pipe',
48
50
  stdout: 'pipe',
49
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/utils",
3
- "version": "4.0.0-rc.14",
3
+ "version": "4.0.0-rc.17",
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": {
@@ -33,7 +33,7 @@
33
33
  "@types/rimraf": "3.0.2",
34
34
  "@types/semver": "7.3.9",
35
35
  "address": "1.1.2",
36
- "axios": "0.26.1",
36
+ "axios": "0.27.2",
37
37
  "chalk": "5.0.1",
38
38
  "cheerio": "1.0.0-rc.10",
39
39
  "color": "4.2.3",