@dword-design/base 16.2.7 → 17.0.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.
Files changed (79) hide show
  1. package/LICENSE.md +9 -9
  2. package/dist/cli.js +25 -19
  3. package/dist/commands/check-unknown-files/index.d.ts +3 -1
  4. package/dist/commands/check-unknown-files/index.js +9 -9
  5. package/dist/commands/check-unknown-files/unknown-files-error.d.ts +1 -1
  6. package/dist/commands/check-unknown-files/unknown-files-error.js +1 -2
  7. package/dist/commands/command-options-input.d.ts +4 -5
  8. package/dist/commands/command-options-input.js +0 -0
  9. package/dist/commands/commit/index.d.ts +10 -1
  10. package/dist/commands/commit/index.js +6 -7
  11. package/dist/commands/depcheck/index.d.ts +3 -1
  12. package/dist/commands/depcheck/index.js +18 -18
  13. package/dist/commands/lint/index.d.ts +3 -1
  14. package/dist/commands/lint/index.js +9 -10
  15. package/dist/commands/lint/lint-packagejson.d.ts +3 -1
  16. package/dist/commands/lint/lint-packagejson.js +3 -3
  17. package/dist/commands/lint/package-json-schema.js +3 -3
  18. package/dist/commands/prepare/index.d.ts +4 -1
  19. package/dist/commands/prepare/index.js +8 -8
  20. package/dist/commands/test/index.d.ts +10 -1
  21. package/dist/commands/test/index.js +1 -3
  22. package/dist/commands/test-docker/index.d.ts +12 -1
  23. package/dist/commands/test-docker/index.js +21 -17
  24. package/dist/commands/test-raw/index.d.ts +17 -1
  25. package/dist/commands/test-raw/index.js +15 -13
  26. package/dist/commands/typecheck/index.d.ts +3 -1
  27. package/dist/commands/typecheck/index.js +8 -8
  28. package/dist/commands/verify/index.d.ts +8 -1
  29. package/dist/commands/verify/index.js +7 -8
  30. package/dist/get-depcheck-special-base/index.d.ts +1 -1
  31. package/dist/get-depcheck-special-base/index.js +1 -1
  32. package/dist/get-generated-files/editorconfig.js +1 -1
  33. package/dist/get-generated-files/get-editor-ignore/index.d.ts +3 -1
  34. package/dist/get-generated-files/get-editor-ignore/index.js +1 -3
  35. package/dist/get-generated-files/get-eslint/index.d.ts +3 -1
  36. package/dist/get-generated-files/get-eslint/index.js +13 -15
  37. package/dist/get-generated-files/get-github-sync-metadata/index.d.ts +3 -1
  38. package/dist/get-generated-files/get-github-sync-metadata/index.js +28 -30
  39. package/dist/get-generated-files/get-github-workflow/index.d.ts +28 -2
  40. package/dist/get-generated-files/get-github-workflow/index.js +8 -8
  41. package/dist/get-generated-files/get-github-workflow/steps/get-release.d.ts +12 -1
  42. package/dist/get-generated-files/get-github-workflow/steps/get-release.js +18 -20
  43. package/dist/get-generated-files/get-github-workflow/steps/get-test.d.ts +3 -1
  44. package/dist/get-generated-files/get-github-workflow/steps/get-test.js +16 -16
  45. package/dist/get-generated-files/get-github-workflow/strategies/job-matrix.d.ts +6 -4
  46. package/dist/get-generated-files/get-github-workflow/strategies/job-matrix.js +19 -19
  47. package/dist/get-generated-files/get-github-workflow/strategies/simple.d.ts +3 -1
  48. package/dist/get-generated-files/get-github-workflow/strategies/simple.js +30 -32
  49. package/dist/get-generated-files/get-gitignore/index.d.ts +3 -1
  50. package/dist/get-generated-files/get-gitignore/index.js +3 -5
  51. package/dist/get-generated-files/get-gitpod/index.d.ts +3 -1
  52. package/dist/get-generated-files/get-gitpod/index.js +3 -3
  53. package/dist/get-generated-files/get-gitpod-dockerfile.d.ts +3 -1
  54. package/dist/get-generated-files/get-gitpod-dockerfile.js +3 -5
  55. package/dist/get-generated-files/get-license-string.d.ts +3 -1
  56. package/dist/get-generated-files/get-license-string.js +4 -4
  57. package/dist/get-generated-files/get-lint-staged/index.d.ts +5 -2
  58. package/dist/get-generated-files/get-lint-staged/index.js +1 -3
  59. package/dist/get-generated-files/get-lint-staged/merge-lint-staged-configs/index.d.ts +1 -1
  60. package/dist/get-generated-files/get-lint-staged/merge-lint-staged-configs/index.js +9 -8
  61. package/dist/get-generated-files/get-package-config/index.d.ts +3 -1
  62. package/dist/get-generated-files/get-package-config/index.js +19 -20
  63. package/dist/get-generated-files/get-readme-string/index.d.ts +3 -1
  64. package/dist/get-generated-files/get-readme-string/index.js +5 -5
  65. package/dist/get-generated-files/get-readme-string/replacements.d.ts +6 -5
  66. package/dist/get-generated-files/get-readme-string/replacements.js +79 -89
  67. package/dist/get-generated-files/get-release/index.d.ts +3 -1
  68. package/dist/get-generated-files/get-release/index.js +9 -11
  69. package/dist/get-generated-files/get-renovate/index.d.ts +3 -1
  70. package/dist/get-generated-files/get-renovate/index.js +29 -31
  71. package/dist/get-generated-files/get-typescript/index.d.ts +3 -1
  72. package/dist/get-generated-files/get-typescript/index.js +17 -19
  73. package/dist/get-generated-files/get-vscode/index.d.ts +3 -1
  74. package/dist/get-generated-files/get-vscode/index.js +6 -8
  75. package/dist/get-generated-files/index.d.ts +5 -3
  76. package/dist/get-generated-files/index.js +16 -16
  77. package/dist/index.d.ts +234 -46
  78. package/dist/index.js +131 -93
  79. package/package.json +31 -29
package/LICENSE.md CHANGED
@@ -14,17 +14,17 @@ MIT License
14
14
 
15
15
  Copyright (c) <year> <copyright holders>
16
16
 
17
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
18
- associated documentation files (the "Software"), to deal in the Software without restriction, including
19
- without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
18
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
19
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
21
21
  following conditions:
22
22
 
23
- The above copyright notice and this permission notice shall be included in all copies or substantial
23
+ The above copyright notice and this permission notice shall be included in all copies or substantial
24
24
  portions of the Software.
25
25
 
26
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27
- LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
28
- EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
29
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
27
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
28
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
29
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
30
30
  USE OR OTHER DEALINGS IN THE SOFTWARE.
package/dist/cli.js CHANGED
@@ -5,19 +5,20 @@ import makeCli from "make-cli";
5
5
  import { Base } from "./index.js";
6
6
  import loadConfig from "./load-config/index.js";
7
7
  const base = new Base(await loadConfig());
8
- const testOptions = [{
9
- description: "Only run tests matching this string or regexp",
10
- name: "-g, --grep <grep>"
11
- }, {
12
- description: "Update snapshots",
13
- name: "-u, --update-snapshots"
14
- }, {
8
+ const testHostOptions = [{
15
9
  description: "Run tests in interactive UI mode",
16
10
  name: "--ui-host <host>"
17
11
  }, {
18
12
  description: "Host to serve UI on; specifying this option opens UI in a browser tab",
19
13
  name: "--ui"
20
14
  }];
15
+ const testOptions = [{
16
+ description: "Only run tests matching this string or regexp",
17
+ name: "-g, --grep <grep>"
18
+ }, {
19
+ description: "Update snapshots",
20
+ name: "-u, --update-snapshots"
21
+ }, ...(base.config.testInContainer ? [] : testHostOptions)];
21
22
  try {
22
23
  await makeCli({
23
24
  commands: {
@@ -43,15 +44,17 @@ try {
43
44
  prepare: {
44
45
  handler: () => base.prepare()
45
46
  },
47
+ test: {
48
+ arguments: "[patterns...]",
49
+ handler: (patterns, options) => base.test({
50
+ patterns,
51
+ ...options
52
+ }),
53
+ options: testOptions
54
+ },
46
55
  typecheck: {
47
56
  handler: () => base.typecheck()
48
57
  },
49
- verify: {
50
- handler: () => {
51
- dotenv.config();
52
- return base.verify();
53
- }
54
- },
55
58
  ...(base.config.testInContainer && {
56
59
  "test:raw": {
57
60
  arguments: "[patterns...]",
@@ -62,17 +65,20 @@ try {
62
65
  options: testOptions
63
66
  }
64
67
  }),
65
- test: {
68
+ verify: {
66
69
  arguments: "[patterns...]",
67
- handler: (patterns, options) => base.test({
68
- patterns,
69
- ...options
70
- }),
70
+ handler: (patterns, options) => {
71
+ dotenv.config();
72
+ return base.verify({
73
+ patterns,
74
+ ...options
75
+ });
76
+ },
71
77
  options: testOptions
72
78
  },
73
79
  ...mapValues(base.config.commands, (command, name) => ({
74
80
  ...command,
75
- handler: (...args) => base.run(name, ...args)
81
+ handler: (...arguments_) => base.run(name, ...arguments_)
76
82
  }))
77
83
  }
78
84
  });
@@ -1 +1,3 @@
1
- export default function (): Promise<void>;
1
+ import type { Base } from '@/src';
2
+ declare const _default: (base: Base) => Promise<void>;
3
+ export default _default;
@@ -1,8 +1,8 @@
1
1
  import { globby } from "globby";
2
2
  import ignore from "ignore";
3
3
  import UnknownFilesError from "./unknown-files-error.js";
4
- export default async function () {
5
- const allowedMatches = [...Object.keys(this.generatedFiles), ...Object.keys({
4
+ export default async base => {
5
+ const allowedMatches = [...Object.keys(base.generatedFiles), ...Object.keys({
6
6
  ".baserc.json": true,
7
7
  ".env.schema.json": true,
8
8
  ".git": true,
@@ -13,28 +13,28 @@ export default async function () {
13
13
  ".husky/post-merge": true,
14
14
  ".husky/pre-commit": true,
15
15
  ".husky/pre-push": true,
16
- "CHANGELOG.md": true,
17
- PRCHECKLIST: true,
18
16
  "base.config.ts": true,
17
+ "CHANGELOG.md": true,
19
18
  demo: true,
20
19
  doc: true,
21
20
  fixtures: true,
22
21
  patches: true,
23
22
  "pnpm-lock.yaml": true,
24
- "pnpm-workspace.yaml": true
23
+ "pnpm-workspace.yaml": true,
24
+ PRCHECKLIST: true
25
25
  }), ...Object.keys({
26
26
  "**/*-snapshots/**": true,
27
27
  // For some reason without the trailing ** didn't work
28
28
  "playwright.config.ts": true
29
- }), ...this.config.allowedMatches];
29
+ }), ...base.config.allowedMatches];
30
30
  let unknownFiles = await globby("**", {
31
- cwd: this.cwd,
31
+ cwd: base.cwd,
32
32
  dot: true,
33
33
  gitignore: true,
34
34
  ignore: allowedMatches
35
35
  });
36
- unknownFiles = unknownFiles.filter(ignore().add(this.getGitignoreConfig()).createFilter());
36
+ unknownFiles = unknownFiles.filter(ignore().add(base.getGitignoreConfig()).createFilter());
37
37
  if (unknownFiles.length > 0) {
38
38
  throw new UnknownFilesError(Object.fromEntries(unknownFiles.map(file => [file, true])));
39
39
  }
40
- }
40
+ };
@@ -1,3 +1,3 @@
1
1
  export default class extends Error {
2
- constructor(files: any);
2
+ constructor(files: Record<string, true>);
3
3
  }
@@ -1,13 +1,12 @@
1
1
  import endent from "endent";
2
2
  import fs from "fs-extra";
3
- import { identity, sortBy } from "lodash-es";
4
3
  const packageConfig = fs.readJsonSync(new URL("../../../package.json", import.meta.url));
5
4
  export default class extends Error {
6
5
  constructor(files) {
7
6
  super(endent`
8
7
  There are files in this repository that are not known to ${packageConfig.name}. Let's discuss about them in a PR!
9
8
 
10
- ${sortBy(Object.keys(files).map(file => `* ${file}`), identity).join("\n")}
9
+ ${Object.keys(files).map(file => `* ${file}`).toSorted((a, b) => a.localeCompare(b)).join("\n")}
11
10
  `);
12
11
  }
13
12
  }
@@ -1,7 +1,6 @@
1
- import type { StdoutStderrOptionCommon } from 'execa';
2
-
1
+ import type { StdoutStderrOption } from 'execa';
3
2
  export type PartialCommandOptions = {
4
- log?: boolean;
5
- stderr?: StdoutStderrOptionCommon<false>;
6
- env?: Record<string, string>;
3
+ env?: Record<string, string>;
4
+ log?: boolean;
5
+ stderr?: StdoutStderrOption;
7
6
  };
File without changes
@@ -1 +1,10 @@
1
- export default function (options: any): import("execa").ResultPromise<any>;
1
+ import type { Base } from '@/src';
2
+ import type { PartialCommandOptions } from '@/src/commands/command-options-input';
3
+ declare const _default: (base: Base, options?: PartialCommandOptions & {
4
+ allowEmpty?: boolean;
5
+ }) => import("execa").ResultPromise<{
6
+ cwd: any;
7
+ stderr: any;
8
+ stdout: "pipe" | "inherit";
9
+ }>;
10
+ export default _default;
@@ -1,15 +1,14 @@
1
1
  import { execaCommand } from "execa";
2
- export default function (options) {
2
+ export default (base, options = {}) => {
3
3
  options = {
4
+ allowEmpty: false,
4
5
  log: process.env.NODE_ENV !== "test",
5
6
  stderr: "inherit",
6
7
  ...options
7
8
  };
8
9
  return execaCommand(`git-cz${options.allowEmpty ? " --allow-empty" : ""}`, {
9
- cwd: this.cwd,
10
- ...(options.log && {
11
- stdout: "inherit"
12
- }),
13
- stderr: options.stderr
10
+ cwd: base.cwd,
11
+ stderr: options.stderr,
12
+ stdout: options.log ? "inherit" : "pipe"
14
13
  });
15
- }
14
+ };
@@ -1 +1,3 @@
1
- export default function (): Promise<void>;
1
+ import type { Base } from '@/src';
2
+ declare const _default: (base: Base) => Promise<void>;
3
+ export default _default;
@@ -1,37 +1,37 @@
1
1
  import depcheck from "depcheck";
2
2
  import endent from "endent";
3
3
  import { isEmpty, mapValues, omit } from "lodash-es";
4
- export default async function () {
5
- const dependenciesTypes = Object.keys(this.packageConfig.dependencies ?? {}).filter(dependency => dependency.startsWith("@types/"));
6
- const dependenciesResult = await depcheck(this.cwd, {
7
- package: omit(this.packageConfig, ["devDependencies"]),
8
- skipMissing: true,
9
- ...this.config.depcheckConfig,
10
- ignorePatterns: ["*.spec.ts", "/fixtures", "/playwright.config.ts", "package.json", "eslint.config.ts"]
4
+ export default async base => {
5
+ const dependenciesTypes = Object.keys(base.packageConfig.dependencies ?? {}).filter(dependency => dependency.startsWith("@types/"));
6
+ const dependenciesResult = await depcheck(base.cwd, {
7
+ ignorePatterns: ["*.spec.ts", "/fixtures", "/playwright.config.ts", "package.json", "eslint.config.ts"],
8
+ package: omit(base.packageConfig, ["devDependencies"]),
9
+ ...base.config.depcheckConfig,
10
+ skipMissing: true
11
11
  });
12
- const devDependenciesResult = await depcheck(this.cwd, {
13
- package: omit(this.packageConfig, ["dependencies"]),
14
- skipMissing: true,
15
- ...this.config.depcheckConfig,
16
- ignorePatterns: ["!*.spec.ts", "!/fixtures", "!/playwright.config.ts", "eslint.config.ts"]
12
+ const developmentDependenciesResult = await depcheck(base.cwd, {
13
+ ignorePatterns: ["!*.spec.ts", "!/fixtures", "!/playwright.config.ts", "eslint.config.ts"],
14
+ package: omit(base.packageConfig, ["dependencies"]),
15
+ ...base.config.depcheckConfig,
16
+ skipMissing: true
17
17
  });
18
18
  const result = {
19
19
  dependencies: dependenciesResult.dependencies,
20
- devDependencies: devDependenciesResult.devDependencies,
20
+ devDependencies: developmentDependenciesResult.devDependencies,
21
21
  invalidFiles: {
22
22
  ...dependenciesResult.invalidFiles,
23
- ...devDependenciesResult.invalidFiles
23
+ ...developmentDependenciesResult.invalidFiles
24
24
  }
25
25
  };
26
26
  const errorMessage = [...(dependenciesTypes.length > 0 ? [endent`
27
27
  Types dependencies should be in devDependencies
28
- ${dependenciesTypes.map(dep => `* ${dep}`).join("\n")}
28
+ ${dependenciesTypes.map(dependency => `* ${dependency}`).join("\n")}
29
29
  `] : []), ...(result.dependencies.length > 0 ? [endent`
30
30
  Unused dependencies
31
- ${result.dependencies.map(dep => `* ${dep}`).join("\n")}
31
+ ${result.dependencies.map(dependency => `* ${dependency}`).join("\n")}
32
32
  `] : []), ...(result.devDependencies.length > 0 ? [endent`
33
33
  Unused devDependencies
34
- ${result.devDependencies.map(dep => `* ${dep}`).join("\n")}
34
+ ${result.devDependencies.map(dependency => `* ${dependency}`).join("\n")}
35
35
  `] : []), ...(isEmpty(result.invalidFiles) ? [] : [endent`
36
36
  Invalid files
37
37
  ${Object.values(mapValues(result.invalidFiles, (error, name) => `* ${name}: ${error}`)).join("\n")}
@@ -39,4 +39,4 @@ export default async function () {
39
39
  if (errorMessage) {
40
40
  throw new Error(errorMessage);
41
41
  }
42
- }
42
+ };
@@ -1,2 +1,4 @@
1
+ import type { Base } from '@/src';
1
2
  import type { PartialCommandOptions } from '@/src/commands/command-options-input';
2
- export default function (options?: PartialCommandOptions): Promise<import("execa").Result<any>>;
3
+ declare const _default: (base: Base, options?: PartialCommandOptions) => Promise<import("execa").Result<any>>;
4
+ export default _default;
@@ -1,23 +1,22 @@
1
1
  import { execaCommand } from "execa";
2
2
  import parsePackagejsonName from "parse-packagejson-name";
3
- export default async function (options = {}) {
3
+ export default async (base, options = {}) => {
4
4
  options = {
5
5
  log: process.env.NODE_ENV !== "test",
6
6
  stderr: "inherit",
7
7
  ...options
8
8
  };
9
- this.lintPackagejson();
10
- const packageName = parsePackagejsonName(this.packageConfig.name).fullName;
11
- if (this.config.git !== void 0 && packageName !== this.config.git.project) {
12
- throw new Error(`Package name '${packageName}' has to be equal to repository name '${this.config.git.project}'`);
9
+ base.lintPackagejson();
10
+ const packageName = parsePackagejsonName(base.packageConfig.name).fullName;
11
+ if (base.config.git !== void 0 && packageName !== base.config.git.project) {
12
+ throw new Error(`Package name '${packageName}' has to be equal to repository name '${base.config.git.project}'`);
13
13
  }
14
- await this.config.lint.call(this, options);
15
- const result = await execaCommand("eslint --fix --no-error-on-unmatched-pattern .", {
14
+ await base.config.lint(base, options);
15
+ return execaCommand("eslint --fix --no-error-on-unmatched-pattern .", {
16
16
  ...(options.log && {
17
17
  stdout: "inherit"
18
18
  }),
19
- cwd: this.cwd,
19
+ cwd: base.cwd,
20
20
  stderr: options.stderr
21
21
  });
22
- return result;
23
- }
22
+ };
@@ -1 +1,3 @@
1
- export default function (): void;
1
+ import type { Base } from '@/src';
2
+ declare const _default: (base: Base) => void;
3
+ export default _default;
@@ -5,11 +5,11 @@ const ajv = new Ajv({
5
5
  allowUnionTypes: true
6
6
  });
7
7
  const validatePackageJson = ajv.compile(packageJsonSchema);
8
- export default function () {
9
- if (!validatePackageJson(this.packageConfig)) {
8
+ export default base => {
9
+ if (!validatePackageJson(base.packageConfig)) {
10
10
  throw new Error(endent`
11
11
  package.json invalid
12
12
  ${ajv.errorsText(validatePackageJson.errors)}
13
13
  `);
14
14
  }
15
- }
15
+ };
@@ -1,5 +1,5 @@
1
1
  import packageNameRegex from "package-name-regex";
2
- const distPattern = /^\.\/dist\//;
2
+ const distributionPattern = /^\.\/dist\//;
3
3
  export default {
4
4
  properties: {
5
5
  baseConfig: {
@@ -15,10 +15,10 @@ export default {
15
15
  },
16
16
  bin: {
17
17
  additionalProperties: {
18
- pattern: distPattern.source,
18
+ pattern: distributionPattern.source,
19
19
  type: "string"
20
20
  },
21
- pattern: distPattern.source,
21
+ pattern: distributionPattern.source,
22
22
  type: ["object", "string"]
23
23
  },
24
24
  dependencies: {
@@ -1 +1,4 @@
1
- export default function (options: any): Promise<void>;
1
+ import type { Base } from '@/src';
2
+ import type { PartialCommandOptions } from '@/src/commands/command-options-input';
3
+ declare const _default: (base: Base, options?: PartialCommandOptions) => Promise<void>;
4
+ export default _default;
@@ -6,35 +6,35 @@ import fs from "fs-extra";
6
6
  import outputFiles from "output-files";
7
7
  const resolver = createRequire(import.meta.url);
8
8
  const commitlintPackageConfig = resolver(packageName`@commitlint/cli/package.json`);
9
- export default async function (options) {
9
+ export default async (base, options = {}) => {
10
10
  options = {
11
11
  log: process.env.NODE_ENV !== "test",
12
12
  stderr: "inherit",
13
13
  ...options
14
14
  };
15
- await outputFiles(this.cwd, this.generatedFiles);
16
- if (await fs.exists(pathLib.join(this.cwd, ".git"))) {
15
+ await outputFiles(base.cwd, base.generatedFiles);
16
+ if (await fs.exists(pathLib.join(base.cwd, ".git"))) {
17
17
  await execaCommand("husky install", {
18
- cwd: this.cwd,
18
+ cwd: base.cwd,
19
19
  ...(options.log && {
20
20
  stdout: "inherit"
21
21
  }),
22
22
  stderr: options.stderr
23
23
  });
24
24
  await execa("husky", ["set", ".husky/commit-msg", `npx ${Object.keys(commitlintPackageConfig.bin)[0]} --edit "$1"`], {
25
- cwd: this.cwd,
25
+ cwd: base.cwd,
26
26
  ...(options.log && {
27
27
  stdout: "inherit"
28
28
  }),
29
29
  stderr: options.stderr
30
30
  });
31
31
  await execa("husky", ["set", ".husky/pre-commit", `npx ${packageName`lint-staged`}`], {
32
- cwd: this.cwd,
32
+ cwd: base.cwd,
33
33
  ...(options.log && {
34
34
  stdout: "inherit"
35
35
  }),
36
36
  stderr: options.stderr
37
37
  });
38
38
  }
39
- await this.config.prepare.call(this, options);
40
- }
39
+ await base.config.prepare(base, options);
40
+ };
@@ -1 +1,10 @@
1
- export default function (options: any): any;
1
+ import type { Base } from '@/src';
2
+ import type { PartialCommandOptions } from '@/src/commands/command-options-input';
3
+ declare const _default: (base: Base, options?: PartialCommandOptions & {
4
+ grep?: string;
5
+ patterns?: string[];
6
+ ui?: boolean;
7
+ uiHost?: string;
8
+ updateSnapshots?: boolean;
9
+ }) => any;
10
+ export default _default;
@@ -1,3 +1 @@
1
- export default function (options) {
2
- return this.config.testInContainer ? this.testDocker(options) : this.testRaw(options);
3
- }
1
+ export default (base, options = {}) => base.config.testInContainer ? base.testDocker(options) : base.testRaw(options);
@@ -1 +1,12 @@
1
- export default function (options: any): Promise<import("execa").Result<any>>;
1
+ import type { Base } from '@/src';
2
+ import type { PartialCommandOptions } from '@/src/commands/command-options-input';
3
+ declare const _default: (base: Base, optionsInput?: PartialCommandOptions & {
4
+ grep?: string;
5
+ patterns?: string[];
6
+ updateSnapshots?: boolean;
7
+ }) => Promise<import("execa").Result<{
8
+ cwd: any;
9
+ stderr: any;
10
+ stdout: "pipe" | "inherit";
11
+ }>>;
12
+ export default _default;
@@ -3,35 +3,39 @@ import { constantCase } from "change-case";
3
3
  import { execa } from "execa";
4
4
  import { findUpSync } from "find-up";
5
5
  import fs from "fs-extra";
6
- export default async function (options) {
7
- options = {
6
+ export default async (base, optionsInput = {}) => {
7
+ if (!base.packageConfig.name) {
8
+ throw new Error("package.json must have a name field to run tests in Docker.");
9
+ }
10
+ const options = {
11
+ grep: "",
8
12
  log: process.env.NODE_ENV !== "test",
9
13
  patterns: [],
10
14
  stderr: "inherit",
11
- ...options
15
+ updateSnapshots: false,
16
+ ...optionsInput
12
17
  };
13
- const volumeName = this.packageConfig.name.replace("@", "").replace("/", "-");
14
- const envSchemaPath = findUpSync(".env.schema.json", {
15
- cwd: this.cwd
18
+ const volumeName = base.packageConfig.name.replace("@", "").replace("/", "-");
19
+ const environmentSchemaPath = findUpSync(".env.schema.json", {
20
+ cwd: base.cwd
16
21
  });
17
- const envVariableNames = Object.keys({
22
+ const environmentVariableNames = Object.keys({
18
23
  CI: true,
19
- ...(envSchemaPath ? await fs.readJson(envSchemaPath) : {})
24
+ ...(environmentSchemaPath && (await fs.readJson(environmentSchemaPath)))
20
25
  }).map(name => constantCase(name));
21
26
  const userInfo = getUserInfo();
22
27
  try {
23
- return await execa("docker", ["run", "--rm", ...envVariableNames.filter(name => process.env[name] !== void 0).flatMap(name => ["--env", name]), "-v", `${this.cwd}:/app`, "-v", `${volumeName}:/app/node_modules`, "dworddesign/testing:latest", "bash", "-c", ["pnpm install --frozen-lockfile", "&&", "pnpm test:raw", ...(options.updateSnapshots ? [" --update-snapshots"] : []), ...options.patterns.map(pattern => `"${pattern}"`), ...(options.grep ? [`-g "${options.grep}"`] : [])].join(" ")], {
24
- cwd: this.cwd,
25
- ...(options.log && {
26
- stdout: "inherit"
27
- }),
28
- stderr: options.stderr
28
+ return await execa("docker", ["run", "--rm", ...environmentVariableNames.filter(name => process.env[name] !== void 0).flatMap(name => ["--env", name]), "-v", `${base.cwd}:/app`, "-v", `${volumeName}:/app/node_modules`, "dworddesign/testing:latest", "bash", "-c", ["pnpm install --frozen-lockfile", "&&", "pnpm test:raw", ...(options.updateSnapshots ? [" --update-snapshots"] : []), ...options.patterns.map(pattern => `"${pattern}"`), ...(options.grep ? [`-g "${options.grep}"`] : [])].join(" ")], {
29
+ cwd: base.cwd,
30
+ stderr: options.stderr,
31
+ // ...(options.log && { stdout: 'inherit' }),
32
+ stdout: options.log ? "inherit" : "pipe"
29
33
  });
30
34
  } finally {
31
35
  if (process.platform === "linux") {
32
- await execa("docker", ["run", "--rm", "--tty", "-v", `${this.cwd}:/app`, "-v", `${volumeName}:/app/node_modules`, "dworddesign/testing:latest", "bash", "-c", `chown -R ${userInfo.uid}:${userInfo.gid} /app`], {
33
- cwd: this.cwd
36
+ await execa("docker", ["run", "--rm", "--tty", "-v", `${base.cwd}:/app`, "-v", `${volumeName}:/app/node_modules`, "dworddesign/testing:latest", "bash", "-c", `chown -R ${userInfo.uid}:${userInfo.gid} /app`], {
37
+ cwd: base.cwd
34
38
  });
35
39
  }
36
40
  }
37
- }
41
+ };
@@ -1 +1,17 @@
1
- export default function (options: any): import("execa").ResultPromise<{}>;
1
+ import type { Base } from '@/src';
2
+ import type { PartialCommandOptions } from '@/src/commands/command-options-input';
3
+ declare const _default: (base: Base, optionsInput?: PartialCommandOptions & {
4
+ grep?: string;
5
+ patterns?: string[];
6
+ ui?: boolean;
7
+ uiHost?: string;
8
+ updateSnapshots?: boolean;
9
+ }) => import("execa").ResultPromise<{
10
+ cwd: any;
11
+ env: {
12
+ NODE_ENV: string;
13
+ };
14
+ stderr: any;
15
+ stdout: "pipe" | "inherit";
16
+ }>;
17
+ export default _default;
@@ -1,31 +1,33 @@
1
1
  import packageName from "depcheck-package-name";
2
2
  import { execa } from "execa";
3
3
  import isCI from "./is-ci.js";
4
- export default function (options) {
5
- options = {
4
+ export default (base, optionsInput = {}) => {
5
+ const options = {
6
+ grep: "",
6
7
  log: process.env.NODE_ENV !== "test",
7
8
  patterns: [],
8
9
  stderr: "inherit",
9
- ...options
10
+ ui: false,
11
+ uiHost: null,
12
+ updateSnapshots: false,
13
+ ...optionsInput
10
14
  };
11
- const runDockerTests = !isCI({
12
- cwd: this.cwd
15
+ const isRunDockerTests = !isCI({
16
+ cwd: base.cwd
13
17
  }) || !["win32", "darwin"].includes(process.platform);
14
- return execa(packageName`c8`, ["--exclude", "fixtures", "--exclude", "test-results", "--exclude", "playwright.config.ts", "playwright", "test", "--pass-with-no-tests", ...(runDockerTests ? [] : ["--grep-invert", "@usesdocker"]), ...(options.updateSnapshots ? ["--update-snapshots"] : []), ...(options.ui ? ["--ui"] : []), ...(options.uiHost ? ["--ui-host", options.uiHost] : []), ...(options.grep ? ["--grep", options.grep] : []), "--trace", "retain-on-failure", ...(isCI({
15
- cwd: this.cwd
18
+ return execa(packageName`c8`, ["--exclude", "fixtures", "--exclude", "test-results", "--exclude", "playwright.config.ts", "playwright", "test", "--pass-with-no-tests", ...(isRunDockerTests ? [] : ["--grep-invert", "@usesdocker"]), ...(options.updateSnapshots ? ["--update-snapshots"] : []), ...(options.ui ? ["--ui"] : []), ...(options.uiHost ? ["--ui-host", options.uiHost] : []), ...(options.grep ? ["--grep", options.grep] : []), "--trace", "retain-on-failure", ...(isCI({
19
+ cwd: base.cwd
16
20
  }) ? ["--forbid-only"] : []),
17
21
  /**
18
22
  * Reporter set to dot in CI environments by default.
19
23
  * See https://github.com/microsoft/playwright/blob/42ade54975f6990c41cddc7b6e11c46a36648d0d/packages/playwright/src/common/config.ts#L301.
20
24
  */
21
25
  "--reporter", "list", ...options.patterns], {
22
- cwd: this.cwd,
26
+ cwd: base.cwd,
23
27
  env: {
24
28
  NODE_ENV: "test"
25
29
  },
26
- ...(options.log && {
27
- stdout: "inherit"
28
- }),
29
- stderr: options.stderr
30
+ stderr: options.stderr,
31
+ stdout: options.log ? "inherit" : "pipe"
30
32
  });
31
- }
33
+ };
@@ -1,2 +1,4 @@
1
+ import type { Base } from '@/src';
1
2
  import type { PartialCommandOptions } from '@/src/commands/command-options-input';
2
- export default function (options?: PartialCommandOptions): Promise<import("execa").Result<any> | undefined>;
3
+ declare const _default: (base: Base, options?: PartialCommandOptions) => Promise<import("execa").Result<any> | undefined>;
4
+ export default _default;