@dword-design/base 13.1.2 → 14.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.
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ const testOptions = [{
19
19
  }];
20
20
  try {
21
21
  await makeCli({
22
- commands: Object.values(mapValues({
22
+ commands: {
23
23
  checkUnknownFiles: {
24
24
  handler: () => base.checkUnknownFiles()
25
25
  },
@@ -61,10 +61,7 @@ try {
61
61
  ...command,
62
62
  handler: (...args) => base.run(name, ...args)
63
63
  }))
64
- }, (command, name) => ({
65
- name,
66
- ...command
67
- })))
64
+ }
68
65
  });
69
66
  } catch (error) {
70
67
  console.error(error);
@@ -0,0 +1,6 @@
1
+ import type { StdoutStderrOptionCommon } from 'execa';
2
+
3
+ export type CommandOptionsInput = {
4
+ log?: boolean;
5
+ stderr?: StdoutStderrOptionCommon<false>;
6
+ };
@@ -1 +1,2 @@
1
- export default function (options: any): Promise<import("execa").Result<any>>;
1
+ import type { CommandOptionsInput } from '@/src/commands/command-options-input';
2
+ export default function (optionsInput?: CommandOptionsInput): Promise<import("execa").Result<any>>;
@@ -1,13 +1,10 @@
1
- import pathLib from "node:path";
2
1
  import { execaCommand } from "execa";
3
- import { globby } from "globby";
4
2
  import parsePackagejsonName from "parse-packagejson-name";
5
- import ts from "typescript";
6
- export default async function (options) {
7
- options = {
3
+ export default async function (optionsInput) {
4
+ const options = {
8
5
  log: process.env.NODE_ENV !== "test",
9
6
  stderr: "inherit",
10
- ...options
7
+ ...optionsInput
11
8
  };
12
9
  const packageName = parsePackagejsonName(this.packageConfig.name).fullName;
13
10
  if (this.config.git !== void 0 && packageName !== this.config.git.project) {
@@ -21,26 +18,6 @@ export default async function (options) {
21
18
  cwd: this.cwd,
22
19
  stderr: options.stderr
23
20
  });
24
- const {
25
- config
26
- } = ts.readConfigFile(pathLib.join(this.cwd, "tsconfig.json"), ts.sys.readFile);
27
- const {
28
- fileNames
29
- } = ts.parseJsonConfigFileContent(config, ts.sys, this.cwd);
30
- const vueFiles = await globby("**/*.vue", {
31
- cwd: this.cwd,
32
- dot: true,
33
- ignore: ["**/node_modules/**"]
34
- });
35
- const allFileNames = [...fileNames, ...vueFiles];
36
- if (allFileNames.length > 0) {
37
- await execaCommand("vue-tsc --noEmit", {
38
- ...(options.log && {
39
- stdout: "inherit"
40
- }),
41
- cwd: this.cwd,
42
- stderr: options.stderr
43
- });
44
- }
21
+ await this.typecheck(options);
45
22
  return result;
46
23
  }
@@ -0,0 +1,2 @@
1
+ import type { CommandOptionsInput } from '@/src/commands/command-options-input';
2
+ export default function (optionsInput?: CommandOptionsInput): Promise<import("execa").Result<any> | undefined>;
@@ -0,0 +1,32 @@
1
+ import pathLib from "node:path";
2
+ import { execaCommand } from "execa";
3
+ import { globby } from "globby";
4
+ import ts from "typescript";
5
+ export default async function (optionsInput) {
6
+ const options = {
7
+ log: process.env.NODE_ENV !== "test",
8
+ stderr: "inherit",
9
+ ...optionsInput
10
+ };
11
+ const {
12
+ config
13
+ } = ts.readConfigFile(pathLib.join(this.cwd, "tsconfig.json"), ts.sys.readFile);
14
+ const {
15
+ fileNames
16
+ } = ts.parseJsonConfigFileContent(config, ts.sys, this.cwd);
17
+ const vueFiles = await globby("**/*.vue", {
18
+ cwd: this.cwd,
19
+ dot: true,
20
+ ignore: ["**/node_modules/**"]
21
+ });
22
+ const allFileNames = [...fileNames, ...vueFiles];
23
+ if (allFileNames.length > 0) {
24
+ return execaCommand("vue-tsc --noEmit", {
25
+ ...(options.log && {
26
+ stdout: "inherit"
27
+ }),
28
+ cwd: this.cwd,
29
+ stderr: options.stderr
30
+ });
31
+ }
32
+ }
@@ -26,7 +26,7 @@ export default function () {
26
26
  uses: gitHubAction`actions/upload-artifact@v4`,
27
27
  with: {
28
28
  "if-no-files-found": "ignore",
29
- name: "Images from tests",
29
+ name: "Data from tests",
30
30
  path: "test-results/*/**"
31
31
  }
32
32
  }];
@@ -1,7 +1,7 @@
1
- import deepmerge from "deepmerge";
1
+ import defu from "@dword-design/defu";
2
2
  import getRegexManagerString from "./get-regex-manager-string/index.js";
3
3
  export default function () {
4
- return deepmerge({
4
+ return defu(this.config.renovateConfig, {
5
5
  extends: [":semanticCommits", ":semanticPrefixFix"],
6
6
  gitIgnoredAuthors: ["actions@github.com"],
7
7
  "github-actions": {
@@ -29,5 +29,5 @@ export default function () {
29
29
  versioningTemplate: "node"
30
30
  }],
31
31
  semanticCommitScope: null
32
- }, this.config.renovateConfig || {});
32
+ });
33
33
  }
@@ -15,6 +15,6 @@ export default function () {
15
15
  skipLibCheck: true,
16
16
  target: "ESNext"
17
17
  },
18
- exclude: ["**/*.spec.ts"]
18
+ exclude: ["test-results"]
19
19
  });
20
20
  }
@@ -14,8 +14,8 @@ export default ({
14
14
  if (gitUrl === void 0) {
15
15
  return;
16
16
  }
17
- const gitInfo = hostedGitInfo.fromUrl(gitUrl) || {};
18
- if (gitInfo.type !== "github") {
17
+ const gitInfo = hostedGitInfo.fromUrl(gitUrl);
18
+ if (!gitInfo || gitInfo.type !== "github") {
19
19
  throw new Error("Only GitHub repositories are supported.");
20
20
  }
21
21
  return gitInfo;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,57 @@
1
+ import type { Options as DepcheckOptions } from 'depcheck';
1
2
  import { type ResultPromise } from 'execa';
3
+ import type GitHost from 'hosted-git-info';
4
+ import type { CommandInObjectInput, CommandObjectInObjectInput } from 'make-cli';
5
+ import type { RenovateConfig } from 'renovate/dist/config/types';
6
+ import type { PackageJson, TsConfigJson } from 'type-fest';
7
+ import type { CommandOptionsInput } from './commands/command-options-input';
8
+ type Config = {
9
+ name?: string;
10
+ global: boolean;
11
+ allowedMatches: string[];
12
+ commands: Record<string, CommandObjectInObjectInput>;
13
+ depcheckConfig: Omit<DepcheckOptions, 'package'>;
14
+ deployAssets: Array<{
15
+ label: string;
16
+ path: string;
17
+ }>;
18
+ deployEnv: Record<string, string>;
19
+ deployPlugins: string[];
20
+ editorIgnore: string[];
21
+ fetchGitHistory: boolean;
22
+ git?: GitHost;
23
+ gitignore: string[];
24
+ hasTypescriptConfigRootAlias: boolean;
25
+ lint: (optionsInput?: CommandOptionsInput) => void;
26
+ macos: boolean;
27
+ minNodeVersion: number;
28
+ nodeVersion: number;
29
+ preDeploySteps: string[];
30
+ prepare: (optionsInput?: CommandOptionsInput) => void;
31
+ readmeInstallString: string;
32
+ seeAlso: Array<{
33
+ description: string;
34
+ repository: string;
35
+ }>;
36
+ supportedNodeVersions: number[];
37
+ syncKeywords: boolean;
38
+ typescriptConfig: TsConfigJson;
39
+ windows: boolean;
40
+ testInContainer: boolean;
41
+ eslintConfig: string;
42
+ useJobMatrix: boolean;
43
+ packageConfig: PackageJson;
44
+ renovateConfig: RenovateConfig;
45
+ isLockFileFixCommitType: boolean;
46
+ };
47
+ type ConfigObjectInput = Omit<Partial<Config>, 'commands'> & {
48
+ commands?: Record<string, CommandInObjectInput>;
49
+ };
50
+ type ConfigObjectOrFunctionInput = ConfigObjectInput | ((this: Base) => ConfigObjectInput);
51
+ type ConfigInput = ConfigObjectOrFunctionInput | string | null;
2
52
  declare class Base {
3
- config: any;
4
- packageConfig: any;
53
+ config: Config;
54
+ packageConfig: PackageJson;
5
55
  cwd: string;
6
56
  generatedFiles: any;
7
57
  githubCodespacesConfig: {
@@ -9,6 +59,7 @@ declare class Base {
9
59
  };
10
60
  commit(...args: any[]): ResultPromise;
11
61
  lint(...args: any[]): ResultPromise;
62
+ typecheck(...args: any[]): ResultPromise;
12
63
  prepare(...args: any[]): void;
13
64
  test(...args: any[]): ResultPromise;
14
65
  testRaw(...args: any[]): ResultPromise;
@@ -17,20 +68,20 @@ declare class Base {
17
68
  getGeneratedFiles(...args: any[]): any;
18
69
  checkUnknownFiles(...args: any[]): void;
19
70
  depcheck(...args: any[]): void;
20
- getEditorIgnoreConfig(...args: any[]): void;
21
- getEslintConfig(...args: any[]): void;
22
- getGithubSyncMetadataConfig(...args: any[]): void;
23
- getGithubWorkflowConfig(...args: any[]): void;
24
- getGitignoreConfig(...args: any[]): void;
25
- getGitpodConfig(...args: any[]): void;
26
- getGitpodDockerfile(...args: any[]): void;
27
- getLicenseString(...args: any[]): void;
28
- getReadmeString(...args: any[]): void;
29
- getReleaseConfig(...args: any[]): void;
30
- getRenovateConfig(...args: any[]): void;
31
- getVscodeConfig(...args: any[]): void;
32
- getTypescriptConfig(...args: any[]): void;
33
- constructor(config?: null, { cwd }?: {
71
+ getEditorIgnoreConfig(...args: any[]): any;
72
+ getEslintConfig(...args: any[]): any;
73
+ getGithubSyncMetadataConfig(...args: any[]): any;
74
+ getGithubWorkflowConfig(...args: any[]): any;
75
+ getGitignoreConfig(...args: any[]): any;
76
+ getGitpodConfig(...args: any[]): any;
77
+ getGitpodDockerfile(...args: any[]): any;
78
+ getLicenseString(...args: any[]): any;
79
+ getReadmeString(...args: any[]): any;
80
+ getReleaseConfig(...args: any[]): any;
81
+ getRenovateConfig(...args: any[]): any;
82
+ getVscodeConfig(...args: any[]): any;
83
+ getTypescriptConfig(...args: any[]): any;
84
+ constructor(configInput?: ConfigInput, { cwd }?: {
34
85
  cwd?: string | undefined;
35
86
  });
36
87
  run(name: any, ...args: any[]): any;
@@ -38,3 +89,4 @@ declare class Base {
38
89
  export { default as loadConfig } from './load-config';
39
90
  export { default as loadConfigSync } from './load-config-sync';
40
91
  export { Base };
92
+ export type { Config, ConfigInput };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import pathLib from "node:path";
2
- import deepmerge from "deepmerge";
2
+ import { createDefu } from "@dword-design/defu";
3
3
  import depcheck from "depcheck";
4
4
  import depcheckDetectorBinName from "depcheck-detector-bin-name";
5
5
  import depcheckDetectorExeca from "depcheck-detector-execa";
@@ -18,6 +18,7 @@ import prepare from "./commands/prepare/index.js";
18
18
  import test from "./commands/test/index.js";
19
19
  import testDocker from "./commands/test-docker/index.js";
20
20
  import testRaw from "./commands/test-raw/index.js";
21
+ import typecheck from "./commands/typecheck/index.js";
21
22
  import getDepcheckSpecialBase from "./get-depcheck-special-base/index.js";
22
23
  import getGeneratedFiles from "./get-generated-files/index.js";
23
24
  import getEditorIgnoreConfig from "./get-generated-files/get-editor-ignore/index.js";
@@ -32,16 +33,17 @@ import getPackageConfig from "./get-generated-files/get-package-config/index.js"
32
33
  import getReadmeString from "./get-generated-files/get-readme-string/index.js";
33
34
  import getReleaseConfig from "./get-generated-files/get-release/index.js";
34
35
  import getRenovateConfig from "./get-generated-files/get-renovate/index.js";
35
- import getTypescriptConfig from "./get-generated-files/get-typescript.js";
36
+ import getTypescriptConfig from "./get-generated-files/get-typescript/index.js";
36
37
  import getVscodeConfig from "./get-generated-files/get-vscode/index.js";
37
38
  import githubCodespacesConfig from "./get-generated-files/github-codespaces.js";
38
39
  import getGitInfo from "./get-git-info/index.js";
39
- const mergeConfigs = (...configs) => {
40
- const result = deepmerge.all(configs, {
41
- customMerge: key => key === "supportedNodeVersions" ? (a, b) => b : void 0
42
- });
43
- return result;
44
- };
40
+ const mergeConfigs = createDefu((obj, key, value) => {
41
+ if (key === "supportedNodeVersions") {
42
+ obj[key] = value;
43
+ return true;
44
+ }
45
+ return false;
46
+ });
45
47
  class Base {
46
48
  config;
47
49
  packageConfig;
@@ -54,6 +56,9 @@ class Base {
54
56
  lint(...args) {
55
57
  return lint.call(this, ...args);
56
58
  }
59
+ typecheck(...args) {
60
+ return typecheck.call(this, ...args);
61
+ }
57
62
  prepare(...args) {
58
63
  return prepare.call(this, ...args);
59
64
  }
@@ -117,19 +122,25 @@ class Base {
117
122
  getTypescriptConfig(...args) {
118
123
  return getTypescriptConfig.call(this, ...args);
119
124
  }
120
- constructor(config = null, {
125
+ constructor(configInput = null, {
121
126
  cwd = "."
122
127
  } = {}) {
123
128
  this.cwd = cwd;
124
129
  const jitiInstance = createJiti(pathLib.resolve(this.cwd));
125
- if (config === null) {
126
- config = {
127
- name: packageName`@dword-design/base-config-node`
128
- };
129
- }
130
- if (typeof config === "function") {
131
- config = config.call(this);
132
- }
130
+ const config = (() => {
131
+ if (configInput === null) {
132
+ return {
133
+ name: packageName`@dword-design/base-config-node`
134
+ };
135
+ } else if (typeof configInput === "string") {
136
+ return {
137
+ name: configInput
138
+ };
139
+ } else if (typeof configInput === "function") {
140
+ return configInput.call(this);
141
+ }
142
+ return configInput;
143
+ })();
133
144
  if (config.name) {
134
145
  config.name = pluginNameToPackageName(config.name, "base-config");
135
146
  }
@@ -149,16 +160,20 @@ class Base {
149
160
  deployEnv: {},
150
161
  deployPlugins: [],
151
162
  editorIgnore: [],
163
+ eslintConfig: "",
152
164
  fetchGitHistory: false,
153
165
  git: getGitInfo({
154
166
  cwd: this.cwd
155
167
  }),
156
168
  gitignore: [],
169
+ global: false,
157
170
  hasTypescriptConfigRootAlias: true,
158
- lint: identity,
171
+ isLockFileFixCommitType: false,
172
+ lint: () => {},
159
173
  macos: true,
160
174
  minNodeVersion: null,
161
175
  nodeVersion: 20,
176
+ packageConfig: {},
162
177
  preDeploySteps: [],
163
178
  prepare: identity,
164
179
  readmeInstallString: endent`
@@ -172,26 +187,24 @@ class Base {
172
187
  $ yarn ${config.global ? "global " : ""}add ${this.packageConfig.name}
173
188
  \`\`\`
174
189
  `,
190
+ renovateConfig: {},
175
191
  seeAlso: [],
176
- supportedNodeVersions: [18, 20],
192
+ supportedNodeVersions: [20, 22],
177
193
  syncKeywords: true,
194
+ testInContainer: false,
178
195
  typescriptConfig: {},
196
+ useJobMatrix: true,
179
197
  windows: true
180
198
  };
181
- const configsToMerge = [defaultConfig];
182
- if (config.name) {
183
- const inheritedConfigPath = config.name === this.packageConfig.name ? pathLib.resolve(this.cwd, "src", "index.ts") : config.name;
184
- let inheritedConfig = inheritedConfigPath ? jitiInstance(inheritedConfigPath) : void 0;
185
- if (inheritedConfig?.default) {
186
- inheritedConfig = inheritedConfig.default;
187
- }
188
- if (typeof inheritedConfig === "function") {
189
- inheritedConfig = inheritedConfig.call(this, mergeConfigs(defaultConfig, config));
190
- }
191
- configsToMerge.push(inheritedConfig);
199
+ const inheritedConfigPath = config.name && config.name === this.packageConfig.name ? pathLib.resolve(this.cwd, "src", "index.ts") : config.name;
200
+ let inheritedConfig = inheritedConfigPath ? jitiInstance(inheritedConfigPath) : void 0;
201
+ if (inheritedConfig && "default" in inheritedConfig) {
202
+ inheritedConfig = inheritedConfig.default;
203
+ }
204
+ if (typeof inheritedConfig === "function") {
205
+ inheritedConfig = inheritedConfig.call(this, mergeConfigs(defaultConfig, config));
192
206
  }
193
- configsToMerge.push(config);
194
- this.config = mergeConfigs(...configsToMerge);
207
+ this.config = mergeConfigs(config, inheritedConfig, defaultConfig);
195
208
  this.config = {
196
209
  ...this.config,
197
210
  commands: mapValues(this.config.commands, command => typeof command === "function" ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dword-design/base",
3
- "version": "13.1.2",
3
+ "version": "14.0.0",
4
4
  "description": "Base package for projects.",
5
5
  "repository": "dword-design/base",
6
6
  "funding": "https://github.com/sponsors/dword-design",
@@ -33,27 +33,28 @@
33
33
  "dependencies": {
34
34
  "@commitlint/cli": "^18.6.1",
35
35
  "@commitlint/config-conventional": "^18.6.3",
36
- "@dword-design/base-config-node": "^3.0.16",
36
+ "@dword-design/base-config-node": "^3.0.17",
37
37
  "@dword-design/ci": "^4.0.6",
38
- "@dword-design/defu": "^1.0.0",
38
+ "@dword-design/defu": "^1.0.3",
39
39
  "@dword-design/eslint-config": "^7.0.7",
40
40
  "@dword-design/personal-data": "^2.0.3",
41
41
  "@semantic-release/changelog": "^6.0.3",
42
42
  "@semantic-release/git": "^10.0.1",
43
+ "@types/hosted-git-info": "^3.0.5",
44
+ "@types/parse-git-config": "^3.0.4",
43
45
  "ajv": "^8.17.1",
44
46
  "c8": "^9.1.0",
45
47
  "change-case": "^5.4.4",
46
48
  "commitizen": "^4.3.1",
47
49
  "cosmiconfig": "^9.0.0",
48
50
  "cz-conventional-changelog": "^3.3.0",
49
- "deepmerge": "^4.3.1",
50
51
  "depcheck": "npm:@dword-design/depcheck@^0.0.7",
51
52
  "depcheck-detector-bin-name": "^1.0.2",
52
53
  "depcheck-detector-execa": "^4.0.3",
53
54
  "depcheck-detector-package-name": "^3.0.4",
54
55
  "depcheck-package-name": "^3.0.1",
55
56
  "endent": "npm:@dword-design/endent@^1.4.1",
56
- "eslint": "^9.29.0",
57
+ "eslint": "^9.31.0",
57
58
  "execa": "^9.6.0",
58
59
  "find-up": "^7.0.0",
59
60
  "fs-extra": "^11.3.0",
@@ -65,8 +66,8 @@
65
66
  "is-ci": "^3.0.1",
66
67
  "jiti": "^2.4.2",
67
68
  "lodash-es": "^4.17.21",
68
- "make-cli": "^4.0.0",
69
- "output-files": "^2.0.32",
69
+ "make-cli": "^4.0.6",
70
+ "output-files": "^3.0.0",
70
71
  "package-name-regex": "^4.0.3",
71
72
  "parse-git-config": "npm:@dword-design/parse-git-config@^0.0.1",
72
73
  "parse-packagejson-name": "^1.0.1",
@@ -79,22 +80,23 @@
79
80
  "spdx-license-list": "^6.10.0",
80
81
  "tagged-template-noop": "^2.1.1",
81
82
  "tsx": "^4.20.3",
83
+ "type-fest": "^4.41.0",
82
84
  "typescript": "^5.8.3",
83
- "vue-tsc": "^2.2.10",
85
+ "vue-tsc": "^2.2.12",
84
86
  "yaml": "^2.8.0"
85
87
  },
86
88
  "devDependencies": {
87
89
  "@dword-design/dotenv-json-extended": "^3.0.3",
88
- "@playwright/test": "^1.53.1",
90
+ "@playwright/test": "^1.54.1",
89
91
  "p-event": "^6.0.1",
90
92
  "renovate": "^39.264.1",
91
- "sharp": "^0.34.2",
93
+ "sharp": "^0.34.3",
92
94
  "strip-ansi": "^7.1.0",
93
95
  "uuid": "^11.1.0"
94
96
  },
95
97
  "packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
96
98
  "engines": {
97
- "node": ">=18"
99
+ "node": ">=20"
98
100
  },
99
101
  "publishConfig": {
100
102
  "access": "public"