dumi 2.2.8 → 2.2.10

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.
@@ -65,7 +65,7 @@ function safeExcludeInMFSU(api, excludes) {
65
65
  var derivative_default = (api) => {
66
66
  api.describe({ key: "dumi:derivative" });
67
67
  api.onCheck(() => {
68
- var _a, _b, _c, _d, _e;
68
+ var _a, _b, _c, _d, _e, _f;
69
69
  [
70
70
  "clientLoader",
71
71
  "deadCode",
@@ -115,45 +115,45 @@ var derivative_default = (api) => {
115
115
  try {
116
116
  const tsconfigPath = import_path.default.join(api.cwd, "tsconfig.json");
117
117
  const tsconfig = require(tsconfigPath);
118
- const configFileName = (_b = api.service.configManager) == null ? void 0 : _b.mainConfigFile;
119
- const expected = [];
120
- if (configFileName && /[\\/]\.[^\\/]+\.ts$/.test(configFileName)) {
121
- expected.push((0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, configFileName)));
122
- }
123
- [
124
- (_c = api.appData.globalJS) == null ? void 0 : _c[0],
125
- api.appData.globalLoading,
126
- (_d = api.appData.appJS) == null ? void 0 : _d.path
127
- ].forEach((file) => {
128
- if (file && /([\\/])\.dumi\1.*\.tsx?$/.test(file)) {
129
- expected.push((0, import_plugin_utils.winPath)(import_path.default.relative(api.cwd, file)));
130
- }
131
- });
132
- if (import_fs.default.existsSync(import_path.default.join(api.cwd, import_constants.LOCAL_THEME_DIR))) {
133
- expected.push(`${import_constants.LOCAL_THEME_DIR}/**/*`);
134
- }
135
- if ((_e = tsconfig.include) == null ? void 0 : _e.includes(".dumi/**/*")) {
136
- tsconfig.include.splice(
137
- tsconfig.include.indexOf(".dumi/**/*"),
138
- 1,
139
- ...expected.filter((f) => !tsconfig.include.includes(f))
118
+ const dotDumiWildcard = `${import_constants.LOCAL_DUMI_DIR}/**/*`;
119
+ if ((_b = tsconfig.include) == null ? void 0 : _b.includes(dotDumiWildcard)) {
120
+ tsconfig.include = tsconfig.include.filter(
121
+ (i) => i !== dotDumiWildcard
140
122
  );
141
123
  import_fs.default.writeFileSync(
142
124
  tsconfigPath,
143
125
  JSON.stringify(tsconfig, null, 2),
144
126
  "utf-8"
145
127
  );
146
- import_plugin_utils.logger.warn(
147
- "tsconfig.json `include` option has been patched automatically, please check and commit it."
128
+ import_plugin_utils.logger.info(
129
+ `tsconfig.json \`include\` option has been patched automatically, please check and commit it.
130
+ ${import_plugin_utils.chalk.grey("see also: https://github.com/umijs/dumi/pull/1902")}`
148
131
  );
149
- } else if (!expected.every((f) => {
150
- var _a2;
151
- return (_a2 = tsconfig.include) == null ? void 0 : _a2.includes(f);
152
- })) {
132
+ }
133
+ const dotDumiPath = import_path.default.join(api.cwd, import_constants.LOCAL_DUMI_DIR);
134
+ const dotDumiTsconfigPath = import_path.default.join(dotDumiPath, "tsconfig.json");
135
+ const hasDotDumiTsFiles = import_fs.default.existsSync(dotDumiPath) && import_fs.default.readdirSync(dotDumiPath).some(
136
+ (f) => import_constants.LOCAL_PAGES_DIR.endsWith(`/${f}`) || import_constants.LOCAL_THEME_DIR.endsWith(`/${f}`) || /\.tsx?$/.test(f)
137
+ );
138
+ if (hasDotDumiTsFiles && !import_fs.default.existsSync(dotDumiTsconfigPath) && !((_c = tsconfig.include) == null ? void 0 : _c.some((i) => /(\.\/)?.dumi\//.test(i)))) {
139
+ import_fs.default.writeFileSync(
140
+ dotDumiTsconfigPath,
141
+ JSON.stringify(
142
+ { extends: "../tsconfig.json", include: ["**/*"] },
143
+ null,
144
+ 2
145
+ ),
146
+ "utf-8"
147
+ );
148
+ import_plugin_utils.logger.info(
149
+ "In order to make type prompt works for theme files, .dumi/tsconfig.json has been created automatically, please check and commit it."
150
+ );
151
+ }
152
+ const configFileName = ((_d = api.service.configManager) == null ? void 0 : _d.mainConfigFile) && import_path.default.basename((_e = api.service.configManager) == null ? void 0 : _e.mainConfigFile);
153
+ if (configFileName && // only .dumirc.ts need to be included in the root tsconfig.json, because the dot files will be excluded by default
154
+ /^\..+\.ts$/.test(configFileName) && !((_f = tsconfig.include) == null ? void 0 : _f.includes(configFileName))) {
153
155
  import_plugin_utils.logger.warn(
154
- `Please append ${expected.map((e) => `\`${e}\``).join(
155
- ", "
156
- )} into \`include\` option of tsconfig.json, to make sure the type prompt works for ${expected.length > 1 ? "them" : "it"}.`
156
+ `Please append \`${configFileName}\` into \`include\` option of tsconfig.json, to make sure the type prompt works for it.`
157
157
  );
158
158
  }
159
159
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.2.8",
3
+ "version": "2.2.10",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",