@apdesign/code-style-react 1.0.0 → 1.0.2
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/.stylelintrc.js +3 -0
- package/package.json +1 -1
- package/scripts/buildEslint.sh +27 -5
- package/scripts/buildStylelint.sh +29 -7
- package/scripts/initConfigs.js +3 -3
- package/scripts/initHusky.js +1 -1
package/.stylelintrc.js
CHANGED
package/package.json
CHANGED
package/scripts/buildEslint.sh
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
#!/usr/bin/env sh
|
2
2
|
echo "🔍 Starting ESLint check (Git diff files only)..."
|
3
3
|
|
4
|
-
|
4
|
+
# 切换到 Git 仓库根目录
|
5
|
+
PROJECT_ROOT=$(git rev-parse --show-toplevel)
|
6
|
+
cd "$PROJECT_ROOT" || exit 1
|
7
|
+
|
8
|
+
TARGET_COMMIT=$1
|
9
|
+
LATEST_COMMIT=$(git rev-parse HEAD)
|
10
|
+
|
11
|
+
if [ -z "$TARGET_COMMIT" ]; then
|
12
|
+
echo "❗ Error: Missing target commit ID."
|
13
|
+
echo "👉 Usage: $0 <target-commit-id>"
|
14
|
+
exit 1
|
15
|
+
fi
|
16
|
+
|
17
|
+
echo "获取到上一次运行commit ID: $TARGET_COMMIT"
|
18
|
+
echo "获取到当前最新的commit ID: $LATEST_COMMIT"
|
19
|
+
|
20
|
+
DIFF_FILES=$(git diff --name-only "$TARGET_COMMIT" "$LATEST_COMMIT" -- '*.ts' '*.tsx' '*.js' '*.jsx')
|
5
21
|
|
6
22
|
if [ -z "$DIFF_FILES" ]; then
|
7
23
|
echo "✅ No matching file changes detected, skipping ESLint check"
|
@@ -11,13 +27,19 @@ fi
|
|
11
27
|
echo "📂 Changed files:"
|
12
28
|
echo "$DIFF_FILES"
|
13
29
|
|
14
|
-
|
15
|
-
|
16
|
-
|
30
|
+
FILE_COUNT=$(echo "$DIFF_FILES" | wc -w)
|
31
|
+
echo "🧾 Total changed files: $FILE_COUNT"
|
32
|
+
|
33
|
+
# 分批执行 Eslint
|
34
|
+
printf "%s\n" $DIFF_FILES | grep -E '\.(ts|tsx|js|jsx)$' | \
|
35
|
+
xargs -P 4 -n 50 npx --no-install eslint \
|
36
|
+
--config .eslintrc.cjs \
|
37
|
+
--no-error-on-unmatched-pattern \
|
38
|
+
--report-unused-disable-directives
|
17
39
|
|
18
40
|
if [ $? -ne 0 ]; then
|
19
41
|
echo "❌ ESLint check failed. Aborting build process"
|
20
42
|
exit 1
|
21
43
|
fi
|
22
44
|
|
23
|
-
echo "✅ ESLint check passed"
|
45
|
+
echo "✅ ESLint check passed"
|
@@ -1,24 +1,46 @@
|
|
1
1
|
#!/usr/bin/env sh
|
2
2
|
echo "🔍 Starting Stylelint check (Git diff files only)..."
|
3
3
|
|
4
|
-
|
4
|
+
# 切换到 Git 仓库根目录
|
5
|
+
PROJECT_ROOT=$(git rev-parse --show-toplevel)
|
6
|
+
cd "$PROJECT_ROOT" || exit 1
|
7
|
+
|
8
|
+
TARGET_COMMIT=$1
|
9
|
+
LATEST_COMMIT=$(git rev-parse HEAD)
|
10
|
+
|
11
|
+
if [ -z "$TARGET_COMMIT" ]; then
|
12
|
+
echo "❗ Error: Missing target commit ID."
|
13
|
+
echo "👉 Usage: $0 <target-commit-id>"
|
14
|
+
exit 1
|
15
|
+
fi
|
16
|
+
|
17
|
+
echo "获取到上一次运行commit ID: $TARGET_COMMIT"
|
18
|
+
echo "获取到当前最新的commit ID: $LATEST_COMMIT"
|
19
|
+
|
20
|
+
DIFF_FILES=$(git diff --name-only "$TARGET_COMMIT" "$LATEST_COMMIT" -- '*.css' '*.scss' '*.sass' '*.less')
|
5
21
|
|
6
22
|
if [ -z "$DIFF_FILES" ]; then
|
7
|
-
echo "✅ No
|
23
|
+
echo "✅ No matching file changes detected, skipping Stylelint check"
|
8
24
|
exit 0
|
9
25
|
fi
|
10
26
|
|
11
27
|
echo "📂 Changed files:"
|
12
28
|
echo "$DIFF_FILES"
|
13
29
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
30
|
+
FILE_COUNT=$(echo "$DIFF_FILES" | wc -w)
|
31
|
+
echo "🧾 Total changed files: $FILE_COUNT"
|
32
|
+
|
33
|
+
# 分批执行 Stylelint
|
34
|
+
printf "%s\n" $DIFF_FILES | grep -E '\.(css|scss|sass|less)$' | \
|
35
|
+
xargs -P 4 -n 50 npx --no-install stylelint \
|
36
|
+
--config .stylelintrc.cjs \
|
37
|
+
--allow-empty-input \
|
38
|
+
--report-needless-disables \
|
39
|
+
--report-invalid-scope-disables
|
18
40
|
|
19
41
|
if [ $? -ne 0 ]; then
|
20
42
|
echo "❌ Stylelint check failed. Aborting build process"
|
21
43
|
exit 1
|
22
44
|
fi
|
23
45
|
|
24
|
-
echo "✅ Stylelint check passed"
|
46
|
+
echo "✅ Stylelint check passed"
|
package/scripts/initConfigs.js
CHANGED
@@ -62,7 +62,7 @@ function initConfigs() {
|
|
62
62
|
|
63
63
|
try {
|
64
64
|
if (!hasAnyFileExist(eslintConfigFiles)) {
|
65
|
-
const eslintContent = `const baseConfig = require('@apdesign/
|
65
|
+
const eslintContent = `const baseConfig = require('@apdesign/code-style-react/.eslintrc.js');
|
66
66
|
module.exports = {
|
67
67
|
...baseConfig,
|
68
68
|
rules: {
|
@@ -73,7 +73,7 @@ module.exports = {
|
|
73
73
|
}
|
74
74
|
|
75
75
|
if (!hasAnyFileExist(stylelintConfigFiles)) {
|
76
|
-
const stylelintContent = `const baseConfig = require('@apdesign/
|
76
|
+
const stylelintContent = `const baseConfig = require('@apdesign/code-style-react/.stylelintrc.js');
|
77
77
|
module.exports = {
|
78
78
|
...baseConfig,
|
79
79
|
rules: {
|
@@ -84,7 +84,7 @@ module.exports = {
|
|
84
84
|
}
|
85
85
|
|
86
86
|
if (!hasAnyFileExist(prettierConfigFiles)) {
|
87
|
-
const prettierContent = `const baseConfig = require('@apdesign/
|
87
|
+
const prettierContent = `const baseConfig = require('@apdesign/code-style-react/.prettierrc.js');
|
88
88
|
module.exports = {
|
89
89
|
...baseConfig
|
90
90
|
};`;
|
package/scripts/initHusky.js
CHANGED
@@ -24,7 +24,7 @@ function initHusky() {
|
|
24
24
|
|
25
25
|
execSync('git config core.hooksPath .husky');
|
26
26
|
|
27
|
-
console.log('✅ Husky hooks installed from @apdesign/
|
27
|
+
console.log('✅ Husky hooks installed from @apdesign/code-style-react');
|
28
28
|
} catch (err) {
|
29
29
|
console.error('❌ Failed to initialize husky:', err);
|
30
30
|
}
|