@adbayb/stack 2.5.0 → 2.6.1

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.
@@ -76,7 +76,7 @@ export const config = [
76
76
  "unicorn/prefer-dom-node-remove": "error",
77
77
  "unicorn/prefer-dom-node-text-content": "error",
78
78
  "unicorn/prefer-event-target": "error",
79
- "unicorn/prefer-export-from": "error",
79
+ "unicorn/prefer-export-from": ["error", { ignoreUsedVariables: true }],
80
80
  "unicorn/prefer-global-this": "error",
81
81
  "unicorn/prefer-includes": "error",
82
82
  "unicorn/prefer-keyboard-event-key": "error",
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,19 @@ 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: true
153
+ });
154
+ return;
155
+ }
156
+ helpers.message(files.join("\n "), {
157
+ label: "Following files will be checked:",
158
+ lineBreak: true
159
+ });
160
+ };
148
161
  const changeset = async (command)=>{
149
162
  try {
150
163
  return await helpers.exec(command, {
@@ -167,7 +180,7 @@ const ESLINT_EXTENSIONS = [
167
180
  "mdx"
168
181
  ];
169
182
 
170
- var version = "2.5.0";
183
+ var version = "2.6.1";
171
184
 
172
185
  const createWatchCommand = (program)=>{
173
186
  program.command({
@@ -220,7 +233,6 @@ const createReleaseCommand = (program)=>{
220
233
  description: "Publish package(s) to the registry"
221
234
  }).task({
222
235
  async handler () {
223
- // TODO: label instead?
224
236
  helpers.message("New changelog entry\n");
225
237
  await changeset("changeset");
226
238
  },
@@ -250,7 +262,9 @@ const createInstallCommand = (program)=>{
250
262
  }).task({
251
263
  label: label$4("Install `git.pre-commit` hook"),
252
264
  async handler () {
253
- await installGitHook("pre-commit", `${getStackCommand("fix $(git status --porcelain | awk 'BEGIN{ ORS=\" \" } { print $2 }')", false)} && git add -A`);
265
+ const lineBreakMatcher = String.raw`\n|\r\n`;
266
+ 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(" "))'`;
267
+ await installGitHook("pre-commit", `${getStackCommand(`fix $(${modifiedFilesCommand})`, false)} && git add -A`);
254
268
  }
255
269
  }).task({
256
270
  label: label$4("Install `git.commit-msg` hook"),
@@ -303,10 +317,15 @@ const createFixCommand = (program)=>{
303
317
  program.command({
304
318
  name: "fix",
305
319
  description: "Fix auto-fixable issues"
320
+ }).task({
321
+ handler (_, argv) {
322
+ logCheckableFiles(argv.operands);
323
+ }
306
324
  }).task({
307
325
  label: label$3("Prepare the project"),
308
326
  async handler () {
309
327
  await turbo("build", {
328
+ excludeExamples: true,
310
329
  hasLiveOutput: false
311
330
  });
312
331
  }
@@ -521,6 +540,10 @@ const createCleanCommand = (program)=>{
521
540
  handler ({ files }) {
522
541
  helpers.message(files.join("\n "), {
523
542
  label: "Removed assets",
543
+ lineBreak: {
544
+ end: false,
545
+ start: true
546
+ },
524
547
  type: "information"
525
548
  });
526
549
  },
@@ -636,7 +659,7 @@ const createPackagesVersionMismatchChecker = ()=>{
636
659
  }
637
660
  const isSameMonorepoVersion = depVersion === storedVersion;
638
661
  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}\`.`, {
662
+ 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
663
  name: dependencyName,
641
664
  consumedBy: packageName
642
665
  });
@@ -649,7 +672,7 @@ const createPackagesVersionMismatchChecker = ()=>{
649
672
  };
650
673
  };
651
674
  const createPackageError = (message, context)=>{
652
- return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to \`package.json\` guidelines.\n${message}`);
675
+ return createError("stack check", !context ? message : `\`${context.name}\` consumed by \`${context.consumedBy}\` doesn't conform to package guidelines.\n${message}`);
653
676
  };
654
677
  function assertVersion(version, { name, consumedBy }) {
655
678
  assert(version, ()=>createPackageError(`\`${name}\` must have a valid version specified (current version equals to \`${String(version)}\`).`, {
@@ -687,15 +710,21 @@ const createCheckCommand = (program)=>{
687
710
  name: "only",
688
711
  description: `Run only one specified task (accepted value: ${ONLY_VALUES.join(", ")})`,
689
712
  defaultValue: undefined
713
+ }).task({
714
+ handler (_, argv) {
715
+ logCheckableFiles(argv.operands);
716
+ },
717
+ skip: ifOnlyDefinedAndNotEqualTo("linter")
690
718
  }).task({
691
719
  label: label("Prepare the project"),
692
720
  async handler () {
693
721
  await turbo("build", {
722
+ excludeExamples: true,
694
723
  hasLiveOutput: false
695
724
  });
696
725
  },
697
726
  skip ({ only }) {
698
- return only === "commit"; // No need to build if only commitlint is run
727
+ return only === "commit"; // No need to build if only commit is checked
699
728
  }
700
729
  }).task({
701
730
  label: label("Check package guidelines"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adbayb/stack",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
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.2.0",
77
+ "termost": "^1.4.0",
78
78
  "turbo": "^2.3.0",
79
79
  "typescript-eslint": "^8.14.0",
80
80
  "typescript": "^5.6.3"