@modern-js/new-action 1.1.3 → 1.1.4

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.
@@ -12,7 +12,7 @@ export const ModuleNewAction = async options => {
12
12
  debug = false,
13
13
  registry = '',
14
14
  config = '{}',
15
- pwd = process.cwd()
15
+ cwd = process.cwd()
16
16
  } = options;
17
17
  let UserConfig = {};
18
18
 
@@ -48,7 +48,7 @@ export const ModuleNewAction = async options => {
48
48
  let hasOption = false;
49
49
  const schema = forEach(ModuleNewActionSchema, schemaItem => {
50
50
  if (ModuleActionFunctions.includes(schemaItem.key)) {
51
- const enable = hasEnabledFunction(schemaItem.key, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, pwd);
51
+ const enable = hasEnabledFunction(schemaItem.key, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, cwd);
52
52
  const {
53
53
  when
54
54
  } = schemaItem;
@@ -85,7 +85,7 @@ export const ModuleNewAction = async options => {
85
85
 
86
86
  const finalConfig = _merge(UserConfig, ans, {
87
87
  locale: UserConfig.locale || locale,
88
- packageManager: getPackageManager(pwd)
88
+ packageManager: getPackageManager(cwd)
89
89
  }, {
90
90
  devDependencies: devDependency ? {
91
91
  [devDependency]: `^${await getPackageVersion(devDependency)}`
@@ -107,6 +107,6 @@ export const ModuleNewAction = async options => {
107
107
  generator: runner.name,
108
108
  config: runner.config
109
109
  })),
110
- pwd
110
+ pwd: cwd
111
111
  });
112
112
  };
@@ -12,7 +12,7 @@ export const MonorepoNewAction = async options => {
12
12
  debug = false,
13
13
  registry = '',
14
14
  config = '{}',
15
- pwd = process.cwd()
15
+ cwd = process.cwd()
16
16
  } = options;
17
17
  let UserConfig = {};
18
18
 
@@ -59,7 +59,7 @@ export const MonorepoNewAction = async options => {
59
59
 
60
60
  const finalConfig = _merge(UserConfig, ans, MonorepoNewActionConfig[solution], {
61
61
  locale: UserConfig.locale || locale,
62
- packageManager: getPackageManager(pwd)
62
+ packageManager: getPackageManager(cwd)
63
63
  });
64
64
 
65
65
  const task = [{
@@ -71,6 +71,6 @@ export const MonorepoNewAction = async options => {
71
71
  generator: runner.name,
72
72
  config: runner.config
73
73
  })),
74
- pwd
74
+ pwd: cwd
75
75
  });
76
76
  };
@@ -12,7 +12,7 @@ export const MWANewAction = async options => {
12
12
  debug = false,
13
13
  registry = '',
14
14
  config = '{}',
15
- pwd = process.cwd()
15
+ cwd = process.cwd()
16
16
  } = options;
17
17
  let UserConfig = {};
18
18
 
@@ -47,7 +47,7 @@ export const MWANewAction = async options => {
47
47
  }, mockGeneratorCore);
48
48
  const schema = forEach(MWANewActionSchema, schemaItem => {
49
49
  if (MWAActionFunctions.includes(schemaItem.key)) {
50
- const enable = hasEnabledFunction(schemaItem.key, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, {}, pwd);
50
+ const enable = hasEnabledFunction(schemaItem.key, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, {}, cwd);
51
51
  const {
52
52
  when
53
53
  } = schemaItem;
@@ -72,7 +72,7 @@ export const MWANewAction = async options => {
72
72
 
73
73
  const finalConfig = _merge(UserConfig, ans, {
74
74
  locale: UserConfig.locale || locale,
75
- packageManager: getPackageManager(pwd)
75
+ packageManager: getPackageManager(cwd)
76
76
  }, {
77
77
  devDependencies: devDependency ? {
78
78
  [devDependency]: `^${await getPackageVersion(devDependency)}`
@@ -91,6 +91,6 @@ export const MWANewAction = async options => {
91
91
  generator: runner.name,
92
92
  config: runner.config
93
93
  })),
94
- pwd
94
+ pwd: cwd
95
95
  });
96
96
  };
@@ -1,9 +1,9 @@
1
1
  import path from 'path';
2
2
  import json5 from 'json5';
3
3
  import { fs } from '@modern-js/generator-utils';
4
- export function alreadyRepo() {
4
+ export function alreadyRepo(cwd = process.cwd()) {
5
5
  try {
6
- return fs.existsSync(path.resolve(process.cwd(), 'package.json'));
6
+ return fs.existsSync(path.resolve(cwd, 'package.json'));
7
7
  } catch (e) {
8
8
  return false;
9
9
  }
@@ -27,7 +27,7 @@ const ModuleNewAction = async options => {
27
27
  debug = false,
28
28
  registry = '',
29
29
  config = '{}',
30
- pwd = process.cwd()
30
+ cwd = process.cwd()
31
31
  } = options;
32
32
  let UserConfig = {};
33
33
 
@@ -64,7 +64,7 @@ const ModuleNewAction = async options => {
64
64
  let hasOption = false;
65
65
  const schema = (0, _codesmithApiApp.forEach)(_generatorCommon.ModuleNewActionSchema, schemaItem => {
66
66
  if (_generatorCommon.ModuleActionFunctions.includes(schemaItem.key)) {
67
- const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.ModuleActionFunctionsDependencies, _generatorCommon.ModuleActionFunctionsDevDependencies, _generatorCommon.ModuleActionFunctionsPeerDependencies, pwd);
67
+ const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.ModuleActionFunctionsDependencies, _generatorCommon.ModuleActionFunctionsDevDependencies, _generatorCommon.ModuleActionFunctionsPeerDependencies, cwd);
68
68
  const {
69
69
  when
70
70
  } = schemaItem;
@@ -100,7 +100,7 @@ const ModuleNewAction = async options => {
100
100
  const peerDependency = _generatorCommon.ModuleActionFunctionsPeerDependencies[action];
101
101
  const finalConfig = (0, _merge2.default)(UserConfig, ans, {
102
102
  locale: UserConfig.locale || locale,
103
- packageManager: (0, _generatorUtils.getPackageManager)(pwd)
103
+ packageManager: (0, _generatorUtils.getPackageManager)(cwd)
104
104
  }, {
105
105
  devDependencies: devDependency ? {
106
106
  [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
@@ -121,7 +121,7 @@ const ModuleNewAction = async options => {
121
121
  generator: runner.name,
122
122
  config: runner.config
123
123
  })),
124
- pwd
124
+ pwd: cwd
125
125
  });
126
126
  };
127
127
 
@@ -27,7 +27,7 @@ const MonorepoNewAction = async options => {
27
27
  debug = false,
28
28
  registry = '',
29
29
  config = '{}',
30
- pwd = process.cwd()
30
+ cwd = process.cwd()
31
31
  } = options;
32
32
  let UserConfig = {};
33
33
 
@@ -75,7 +75,7 @@ const MonorepoNewAction = async options => {
75
75
 
76
76
  const finalConfig = (0, _merge2.default)(UserConfig, ans, _generatorCommon.MonorepoNewActionConfig[solution], {
77
77
  locale: UserConfig.locale || locale,
78
- packageManager: (0, _generatorUtils.getPackageManager)(pwd)
78
+ packageManager: (0, _generatorUtils.getPackageManager)(cwd)
79
79
  });
80
80
  const task = [{
81
81
  name: generator,
@@ -86,7 +86,7 @@ const MonorepoNewAction = async options => {
86
86
  generator: runner.name,
87
87
  config: runner.config
88
88
  })),
89
- pwd
89
+ pwd: cwd
90
90
  });
91
91
  };
92
92
 
@@ -27,7 +27,7 @@ const MWANewAction = async options => {
27
27
  debug = false,
28
28
  registry = '',
29
29
  config = '{}',
30
- pwd = process.cwd()
30
+ cwd = process.cwd()
31
31
  } = options;
32
32
  let UserConfig = {};
33
33
 
@@ -63,7 +63,7 @@ const MWANewAction = async options => {
63
63
  }, mockGeneratorCore);
64
64
  const schema = (0, _codesmithApiApp.forEach)(_generatorCommon.MWANewActionSchema, schemaItem => {
65
65
  if (_generatorCommon.MWAActionFunctions.includes(schemaItem.key)) {
66
- const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.MWAActionFunctionsDependencies, _generatorCommon.MWAActionFunctionsDevDependencies, {}, pwd);
66
+ const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.MWAActionFunctionsDependencies, _generatorCommon.MWAActionFunctionsDevDependencies, {}, cwd);
67
67
  const {
68
68
  when
69
69
  } = schemaItem;
@@ -87,7 +87,7 @@ const MWANewAction = async options => {
87
87
  const dependency = _generatorCommon.MWAActionFunctionsDependencies[action];
88
88
  const finalConfig = (0, _merge2.default)(UserConfig, ans, {
89
89
  locale: UserConfig.locale || locale,
90
- packageManager: (0, _generatorUtils.getPackageManager)(pwd)
90
+ packageManager: (0, _generatorUtils.getPackageManager)(cwd)
91
91
  }, {
92
92
  devDependencies: devDependency ? {
93
93
  [devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
@@ -105,7 +105,7 @@ const MWANewAction = async options => {
105
105
  generator: runner.name,
106
106
  config: runner.config
107
107
  })),
108
- pwd
108
+ pwd: cwd
109
109
  });
110
110
  };
111
111
 
@@ -15,9 +15,9 @@ var _generatorUtils = require("@modern-js/generator-utils");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- function alreadyRepo() {
18
+ function alreadyRepo(cwd = process.cwd()) {
19
19
  try {
20
- return _generatorUtils.fs.existsSync(_path.default.resolve(process.cwd(), 'package.json'));
20
+ return _generatorUtils.fs.existsSync(_path.default.resolve(cwd, 'package.json'));
21
21
  } catch (e) {
22
22
  return false;
23
23
  }
@@ -4,7 +4,7 @@ interface IModuleNewActionOption {
4
4
  debug?: boolean;
5
5
  registry?: string;
6
6
  config?: string;
7
- pwd?: string;
7
+ cwd?: string;
8
8
  }
9
9
  export declare const ModuleNewAction: (options: IModuleNewActionOption) => Promise<void>;
10
10
  export {};
@@ -4,7 +4,7 @@ interface IMonorepoNewActionOption {
4
4
  debug?: boolean;
5
5
  registry?: string;
6
6
  config?: string;
7
- pwd?: string;
7
+ cwd?: string;
8
8
  }
9
9
  export declare const MonorepoNewAction: (options: IMonorepoNewActionOption) => Promise<void>;
10
10
  export {};
@@ -4,7 +4,7 @@ interface IMWANewActionOption {
4
4
  debug?: boolean;
5
5
  registry?: string;
6
6
  config?: string;
7
- pwd?: string;
7
+ cwd?: string;
8
8
  }
9
9
  export declare const MWANewAction: (options: IMWANewActionOption) => Promise<void>;
10
10
  export {};
@@ -1,4 +1,4 @@
1
1
  import { ActionFunction } from '@modern-js/generator-common';
2
- export declare function alreadyRepo(): boolean;
2
+ export declare function alreadyRepo(cwd?: string): boolean;
3
3
  export declare const readJson: (jsonPath: string) => any;
4
4
  export declare function hasEnabledFunction(action: ActionFunction, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string>, cwd: string): any;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.3",
14
+ "version": "1.1.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
package/src/module.ts CHANGED
@@ -28,7 +28,7 @@ interface IModuleNewActionOption {
28
28
  debug?: boolean;
29
29
  registry?: string;
30
30
  config?: string;
31
- pwd?: string;
31
+ cwd?: string;
32
32
  }
33
33
  // eslint-disable-next-line max-statements
34
34
  export const ModuleNewAction = async (options: IModuleNewActionOption) => {
@@ -38,7 +38,7 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
38
38
  debug = false,
39
39
  registry = '',
40
40
  config = '{}',
41
- pwd = process.cwd(),
41
+ cwd = process.cwd(),
42
42
  } = options;
43
43
 
44
44
  let UserConfig: Record<string, unknown> = {};
@@ -79,7 +79,7 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
79
79
  ModuleActionFunctionsDependencies,
80
80
  ModuleActionFunctionsDevDependencies,
81
81
  ModuleActionFunctionsPeerDependencies,
82
- pwd,
82
+ cwd,
83
83
  );
84
84
  const { when } = schemaItem;
85
85
  schemaItem.when = enable ? () => false : when;
@@ -125,7 +125,7 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
125
125
  ans,
126
126
  {
127
127
  locale: (UserConfig.locale as string) || locale,
128
- packageManager: getPackageManager(pwd),
128
+ packageManager: getPackageManager(cwd),
129
129
  },
130
130
  {
131
131
  devDependencies: devDependency
@@ -154,6 +154,6 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
154
154
  generator: runner.name,
155
155
  config: runner.config,
156
156
  })),
157
- pwd,
157
+ pwd: cwd,
158
158
  });
159
159
  };
package/src/monorepo.ts CHANGED
@@ -21,7 +21,7 @@ interface IMonorepoNewActionOption {
21
21
  debug?: boolean;
22
22
  registry?: string;
23
23
  config?: string;
24
- pwd?: string;
24
+ cwd?: string;
25
25
  }
26
26
  // eslint-disable-next-line max-statements
27
27
  export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
@@ -31,7 +31,7 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
31
31
  debug = false,
32
32
  registry = '',
33
33
  config = '{}',
34
- pwd = process.cwd(),
34
+ cwd = process.cwd(),
35
35
  } = options;
36
36
 
37
37
  let UserConfig: Record<string, unknown> = {};
@@ -86,7 +86,7 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
86
86
  MonorepoNewActionConfig[solution],
87
87
  {
88
88
  locale: (UserConfig.locale as string) || locale,
89
- packageManager: getPackageManager(pwd),
89
+ packageManager: getPackageManager(cwd),
90
90
  },
91
91
  );
92
92
 
@@ -102,6 +102,6 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
102
102
  generator: runner.name,
103
103
  config: runner.config,
104
104
  })),
105
- pwd,
105
+ pwd: cwd,
106
106
  });
107
107
  };
package/src/mwa.ts CHANGED
@@ -27,7 +27,7 @@ interface IMWANewActionOption {
27
27
  debug?: boolean;
28
28
  registry?: string;
29
29
  config?: string;
30
- pwd?: string;
30
+ cwd?: string;
31
31
  }
32
32
 
33
33
  // eslint-disable-next-line max-statements
@@ -38,7 +38,7 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
38
38
  debug = false,
39
39
  registry = '',
40
40
  config = '{}',
41
- pwd = process.cwd(),
41
+ cwd = process.cwd(),
42
42
  } = options;
43
43
 
44
44
  let UserConfig: Record<string, unknown> = {};
@@ -77,7 +77,7 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
77
77
  MWAActionFunctionsDependencies,
78
78
  MWAActionFunctionsDevDependencies,
79
79
  {},
80
- pwd,
80
+ cwd,
81
81
  );
82
82
  const { when } = schemaItem;
83
83
  schemaItem.when = enable ? () => false : when;
@@ -109,7 +109,7 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
109
109
  ans,
110
110
  {
111
111
  locale: (UserConfig.locale as string) || locale,
112
- packageManager: getPackageManager(pwd),
112
+ packageManager: getPackageManager(cwd),
113
113
  },
114
114
  {
115
115
  devDependencies: devDependency
@@ -133,6 +133,6 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
133
133
  generator: runner.name,
134
134
  config: runner.config,
135
135
  })),
136
- pwd,
136
+ pwd: cwd,
137
137
  });
138
138
  };
@@ -3,9 +3,9 @@ import json5 from 'json5';
3
3
  import { ActionFunction } from '@modern-js/generator-common';
4
4
  import { fs } from '@modern-js/generator-utils';
5
5
 
6
- export function alreadyRepo() {
6
+ export function alreadyRepo(cwd = process.cwd()) {
7
7
  try {
8
- return fs.existsSync(path.resolve(process.cwd(), 'package.json'));
8
+ return fs.existsSync(path.resolve(cwd, 'package.json'));
9
9
  } catch (e) {
10
10
  return false;
11
11
  }