@adbayb/stack 2.5.0 → 2.6.0
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/dist/index.js +43 -8
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -136,8 +136,8 @@ const eslint = (options)=>async (files = [])=>{
|
|
|
136
136
|
};
|
|
137
137
|
const turbo = async (command, options = {})=>{
|
|
138
138
|
try {
|
|
139
|
-
const { hasLiveOutput = true, ...restOptions } = options;
|
|
140
|
-
return await helpers.exec(`turbo run ${command}`, {
|
|
139
|
+
const { excludeExamples = false, hasLiveOutput = true, ...restOptions } = options;
|
|
140
|
+
return await helpers.exec(`turbo run ${command} ${excludeExamples ? "--filter !@examples/*" : ""}`, {
|
|
141
141
|
...restOptions,
|
|
142
142
|
hasLiveOutput
|
|
143
143
|
});
|
|
@@ -145,6 +145,25 @@ const turbo = async (command, options = {})=>{
|
|
|
145
145
|
throw createError("turbo", error);
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
|
+
const logCheckableFiles = (files)=>{
|
|
149
|
+
if (files.length === 0) {
|
|
150
|
+
helpers.message("The whole project will be checked.", {
|
|
151
|
+
label: false,
|
|
152
|
+
lineBreak: {
|
|
153
|
+
end: true,
|
|
154
|
+
start: false
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
helpers.message(files.join("\n "), {
|
|
160
|
+
label: "Following files will be checked:",
|
|
161
|
+
lineBreak: {
|
|
162
|
+
end: true,
|
|
163
|
+
start: false
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
};
|
|
148
167
|
const changeset = async (command)=>{
|
|
149
168
|
try {
|
|
150
169
|
return await helpers.exec(command, {
|
|
@@ -167,7 +186,7 @@ const ESLINT_EXTENSIONS = [
|
|
|
167
186
|
"mdx"
|
|
168
187
|
];
|
|
169
188
|
|
|
170
|
-
var version = "2.
|
|
189
|
+
var version = "2.6.0";
|
|
171
190
|
|
|
172
191
|
const createWatchCommand = (program)=>{
|
|
173
192
|
program.command({
|
|
@@ -220,7 +239,6 @@ const createReleaseCommand = (program)=>{
|
|
|
220
239
|
description: "Publish package(s) to the registry"
|
|
221
240
|
}).task({
|
|
222
241
|
async handler () {
|
|
223
|
-
// TODO: label instead?
|
|
224
242
|
helpers.message("New changelog entry\n");
|
|
225
243
|
await changeset("changeset");
|
|
226
244
|
},
|
|
@@ -250,7 +268,9 @@ const createInstallCommand = (program)=>{
|
|
|
250
268
|
}).task({
|
|
251
269
|
label: label$4("Install `git.pre-commit` hook"),
|
|
252
270
|
async handler () {
|
|
253
|
-
|
|
271
|
+
const lineBreakMatcher = String.raw`\n|\r\n`;
|
|
272
|
+
const modifiedFilesCommand = `node -e 'console.log(require("child_process").execSync("git status --porcelain", {encoding: "utf8"}).split(/${lineBreakMatcher}/).filter(Boolean).map(item => item.split(" ").at(-1)).join(" "))'`;
|
|
273
|
+
await installGitHook("pre-commit", `${getStackCommand(`fix $(${modifiedFilesCommand})`, false)} && git add -A`);
|
|
254
274
|
}
|
|
255
275
|
}).task({
|
|
256
276
|
label: label$4("Install `git.commit-msg` hook"),
|
|
@@ -303,10 +323,15 @@ const createFixCommand = (program)=>{
|
|
|
303
323
|
program.command({
|
|
304
324
|
name: "fix",
|
|
305
325
|
description: "Fix auto-fixable issues"
|
|
326
|
+
}).task({
|
|
327
|
+
handler (_, argv) {
|
|
328
|
+
logCheckableFiles(argv.operands);
|
|
329
|
+
}
|
|
306
330
|
}).task({
|
|
307
331
|
label: label$3("Prepare the project"),
|
|
308
332
|
async handler () {
|
|
309
333
|
await turbo("build", {
|
|
334
|
+
excludeExamples: true,
|
|
310
335
|
hasLiveOutput: false
|
|
311
336
|
});
|
|
312
337
|
}
|
|
@@ -521,6 +546,10 @@ const createCleanCommand = (program)=>{
|
|
|
521
546
|
handler ({ files }) {
|
|
522
547
|
helpers.message(files.join("\n "), {
|
|
523
548
|
label: "Removed assets",
|
|
549
|
+
lineBreak: {
|
|
550
|
+
end: false,
|
|
551
|
+
start: true
|
|
552
|
+
},
|
|
524
553
|
type: "information"
|
|
525
554
|
});
|
|
526
555
|
},
|
|
@@ -636,7 +665,7 @@ const createPackagesVersionMismatchChecker = ()=>{
|
|
|
636
665
|
}
|
|
637
666
|
const isSameMonorepoVersion = depVersion === storedVersion;
|
|
638
667
|
if (!isSameMonorepoVersion) {
|
|
639
|
-
throw createPackageError(`Mismatched versions: received version \`${depVersion}\` while others use \`${storedVersion}\`. To prevent issues with singleton-like code (React contexts, …), please make sure to update all packages to use the same \`${dependencyName}\` version (either \`${storedVersion}\` or \`${depVersion}
|
|
668
|
+
throw createPackageError(`Mismatched versions: received version \`${depVersion}\` while others use \`${storedVersion}\`. To prevent issues with singleton-like code (React contexts, …), please make sure to update all packages to use the same \`${dependencyName}\` version (either \`${storedVersion}\` or \`${depVersion}\`).`, {
|
|
640
669
|
name: dependencyName,
|
|
641
670
|
consumedBy: packageName
|
|
642
671
|
});
|
|
@@ -649,7 +678,7 @@ const createPackagesVersionMismatchChecker = ()=>{
|
|
|
649
678
|
};
|
|
650
679
|
};
|
|
651
680
|
const createPackageError = (message, context)=>{
|
|
652
|
-
return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to
|
|
681
|
+
return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to package guidelines.\n${message}`);
|
|
653
682
|
};
|
|
654
683
|
function assertVersion(version, { name, consumedBy }) {
|
|
655
684
|
assert(version, ()=>createPackageError(`\`${name}\` must have a valid version specified (current version equals to \`${String(version)}\`).`, {
|
|
@@ -687,15 +716,21 @@ const createCheckCommand = (program)=>{
|
|
|
687
716
|
name: "only",
|
|
688
717
|
description: `Run only one specified task (accepted value: ${ONLY_VALUES.join(", ")})`,
|
|
689
718
|
defaultValue: undefined
|
|
719
|
+
}).task({
|
|
720
|
+
handler (_, argv) {
|
|
721
|
+
logCheckableFiles(argv.operands);
|
|
722
|
+
},
|
|
723
|
+
skip: ifOnlyDefinedAndNotEqualTo("linter")
|
|
690
724
|
}).task({
|
|
691
725
|
label: label("Prepare the project"),
|
|
692
726
|
async handler () {
|
|
693
727
|
await turbo("build", {
|
|
728
|
+
excludeExamples: true,
|
|
694
729
|
hasLiveOutput: false
|
|
695
730
|
});
|
|
696
731
|
},
|
|
697
732
|
skip ({ only }) {
|
|
698
|
-
return only === "commit"; // No need to build if only
|
|
733
|
+
return only === "commit"; // No need to build if only commit is checked
|
|
699
734
|
}
|
|
700
735
|
}).task({
|
|
701
736
|
label: label("Check package guidelines"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adbayb/stack",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "My opinionated JavaScript-based toolchain",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"fdir": "^6.4.2",
|
|
75
75
|
"globals": "^15.12.0",
|
|
76
76
|
"prettier": "^3.3.3",
|
|
77
|
-
"termost": "^1.
|
|
77
|
+
"termost": "^1.4.0",
|
|
78
78
|
"turbo": "^2.3.0",
|
|
79
79
|
"typescript-eslint": "^8.14.0",
|
|
80
80
|
"typescript": "^5.6.3"
|