@lark-apaas/fullstack-cli 1.1.59-beta.0 → 1.1.60
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.
- package/package.json +1 -1
- package/templates/scripts/lint.js +22 -7
package/package.json
CHANGED
|
@@ -85,10 +85,25 @@ const STYLELINT_CONFIG_FILES = [
|
|
|
85
85
|
];
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
|
-
* 老模板(fullstack-nestjs-template 1.x
|
|
89
|
-
*
|
|
88
|
+
* 老模板(fullstack-nestjs-template 1.x 时代)的应用跑不了 stylelint,跑了就挂、把 pre-commit
|
|
89
|
+
* 卡死。两种形态都实测过:
|
|
90
|
+
*
|
|
91
|
+
* - 缺 scripts.stylelint → `npm error Missing script: "stylelint"`
|
|
92
|
+
* - 缺 .stylelintrc.* → `ConfigurationError: No configuration provided`
|
|
93
|
+
*
|
|
94
|
+
* 注意光判断 stylelint 装没装拦不住:@lark-apaas/fullstack-presets 的 dependencies 里有
|
|
95
|
+
* stylelint,只要 dep 了 presets 二进制就在。缺任一件就跳过这一步。
|
|
90
96
|
*/
|
|
91
|
-
function
|
|
97
|
+
function canRunStylelint() {
|
|
98
|
+
let pkg;
|
|
99
|
+
try {
|
|
100
|
+
pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
101
|
+
} catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!pkg.scripts || !pkg.scripts.stylelint) return false;
|
|
106
|
+
|
|
92
107
|
return STYLELINT_CONFIG_FILES.some(file => fs.existsSync(path.join(cwd, file)));
|
|
93
108
|
}
|
|
94
109
|
|
|
@@ -98,10 +113,10 @@ async function runDefaultLint() {
|
|
|
98
113
|
[getBinName('npm'), ['run', 'type:check']],
|
|
99
114
|
];
|
|
100
115
|
|
|
101
|
-
if (
|
|
116
|
+
if (canRunStylelint()) {
|
|
102
117
|
taskSpecs.push([getBinName('npm'), ['run', 'stylelint']]);
|
|
103
118
|
} else {
|
|
104
|
-
console.warn('[lint] Skip stylelint:
|
|
119
|
+
console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
|
|
105
120
|
}
|
|
106
121
|
|
|
107
122
|
process.exit(await runTasksSerially(taskSpecs));
|
|
@@ -141,8 +156,8 @@ async function runSelectiveLint(inputFiles) {
|
|
|
141
156
|
taskSpecs.push([getBinName('npx'), ['eslint', '--quiet', ...eslintFiles]]);
|
|
142
157
|
}
|
|
143
158
|
|
|
144
|
-
if (stylelintFiles.length > 0 && !
|
|
145
|
-
console.warn('[lint] Skip stylelint:
|
|
159
|
+
if (stylelintFiles.length > 0 && !canRunStylelint()) {
|
|
160
|
+
console.warn('[lint] Skip stylelint: missing scripts.stylelint or stylelint config');
|
|
146
161
|
} else if (stylelintFiles.length > 0) {
|
|
147
162
|
taskSpecs.push([getBinName('npx'), ['stylelint', '--quiet', ...stylelintFiles]]);
|
|
148
163
|
}
|