rman 2.24.0 → 2.24.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.
|
@@ -226,12 +226,14 @@ async function cleanGlobs(dirname, include, exclude, dryRun) {
|
|
|
226
226
|
* **The build directory is excluded by name from the config, never as the literal `build`** - see
|
|
227
227
|
* `buildDirOf`. Its contents are the *point* of a build and are removed by `clean.include` when the
|
|
228
228
|
* repository asks, not by a rule about stray files. */
|
|
229
|
-
async function cleanTsArtifacts(pkg, dryRun) {
|
|
229
|
+
async function cleanTsArtifacts(pkg, exclude, dryRun) {
|
|
230
230
|
const dirname = pkg.dirname;
|
|
231
231
|
const buildDir = buildDirOf(pkg);
|
|
232
232
|
const files = await fg('**/*.{js,js.map,d.ts}', {
|
|
233
233
|
cwd: dirname,
|
|
234
|
-
|
|
234
|
+
/** `clean.exclude` protects a file from this sweep too - the one way to keep a file the rules
|
|
235
|
+
* below would read as output. */
|
|
236
|
+
ignore: ['**/node_modules/**', `${buildDir}/**`, `**/${buildDir}/**`, ...exclude],
|
|
235
237
|
onlyFiles: true,
|
|
236
238
|
dot: true,
|
|
237
239
|
absolute: true,
|
|
@@ -264,17 +266,24 @@ async function cleanTsArtifacts(pkg, dryRun) {
|
|
|
264
266
|
* - **A `.d.ts` always needs its `.ts`/`.tsx` beside it**, everywhere including `src` - a
|
|
265
267
|
* hand-written declaration is an ordinary thing to keep in a source tree, and this is the rule
|
|
266
268
|
* that has always been here.
|
|
267
|
-
* - **A `.js`/`.js.map` under `src`/`test` goes
|
|
268
|
-
*
|
|
269
|
-
* `ts-cleanup --all` behaviour this replaced.
|
|
269
|
+
* - **A `.js`/`.js.map` under `src`/`test` goes**, unless a `.d.ts` with no `.ts` sits beside the
|
|
270
|
+
* `.js`. Everything else there is TypeScript, so an orphan - output whose source was renamed or
|
|
271
|
+
* deleted - is still output, and sweeping it is the `ts-cleanup --all` behaviour this replaced.
|
|
270
272
|
* - **A `.js`/`.js.map` anywhere else needs its source beside it**, because out there it could just
|
|
271
273
|
* as easily be `index.js`, `*.config.js` or `scripts/*.js`, which nobody generated.
|
|
272
274
|
*/
|
|
275
|
+
/* **A `.js` declared by a hand-written `.d.ts` is kept**, because the first rule already reads that
|
|
276
|
+
* `.d.ts` as hand-written - and a declaration nobody generated describes a module nobody compiled.
|
|
277
|
+
* Measured on `panates/hl7v2`: `src/data/hl7-data.js`, a generated plain-JS data module with its
|
|
278
|
+
* `.d.ts` beside it, was deleted by the preset's `rman clean` before every build, and the next step
|
|
279
|
+
* failed with esbuild's `Could not resolve "./data/hl7-data.js"` - an error about the import, far
|
|
280
|
+
* from the cause. The cost, stated: a tsc orphan *pair* (`.js` and `.d.ts` whose `.ts` was renamed)
|
|
281
|
+
* now stays, where before only its `.d.ts` did. */
|
|
273
282
|
function isBuildOutput(dirname, file) {
|
|
274
283
|
if (file.endsWith('.d.ts'))
|
|
275
284
|
return hasTsSource(file, '.d.ts');
|
|
276
285
|
if (insideTsSourceDir(dirname, file))
|
|
277
|
-
return
|
|
286
|
+
return !(file.endsWith('.js') && isDeclaredByHand(file));
|
|
278
287
|
return hasTsSource(file, file.endsWith('.js.map') ? '.js.map' : '.js');
|
|
279
288
|
}
|
|
280
289
|
/** Directories where everything is TypeScript, so a compiled file needs no source beside it to be
|
|
@@ -293,6 +302,11 @@ function hasTsSource(file, suffix) {
|
|
|
293
302
|
const base = file.slice(0, -suffix.length);
|
|
294
303
|
return fs.existsSync(base + '.ts') || fs.existsSync(base + '.tsx');
|
|
295
304
|
}
|
|
305
|
+
/** Whether a `.js` has a `.d.ts` beside it and no `.ts`/`.tsx` - a module with a hand-written
|
|
306
|
+
* declaration, not compiled output. */
|
|
307
|
+
function isDeclaredByHand(file) {
|
|
308
|
+
return fs.existsSync(file.slice(0, -'.js'.length) + '.d.ts') && !hasTsSource(file, '.js');
|
|
309
|
+
}
|
|
296
310
|
/**
|
|
297
311
|
* Removes TypeScript's incremental-build cache files (`*.tsbuildinfo`) anywhere under `dirname` -
|
|
298
312
|
* `tsc --build`/`composite`/`incremental` output that `ts-cleanup` never touched, but which can
|
|
@@ -316,11 +330,11 @@ async function cleanPackage(pkg, item, panelEnabled, dryRun, logger) {
|
|
|
316
330
|
item.status = 'running';
|
|
317
331
|
item.startedAt = Date.now();
|
|
318
332
|
try {
|
|
333
|
+
const { include, exclude } = cleanConfig(pkg);
|
|
319
334
|
item.currentStep = 'ts';
|
|
320
|
-
const tsRemoved = await cleanTsArtifacts(pkg, dryRun);
|
|
335
|
+
const tsRemoved = await cleanTsArtifacts(pkg, exclude, dryRun);
|
|
321
336
|
const buildInfoRemoved = await cleanTsBuildInfo(pkg.dirname, dryRun);
|
|
322
337
|
item.currentStep = 'glob';
|
|
323
|
-
const { include, exclude } = cleanConfig(pkg);
|
|
324
338
|
const globRemoved = await cleanGlobs(pkg.dirname, include, exclude, dryRun);
|
|
325
339
|
const removed = [...tsRemoved, ...buildInfoRemoved, ...globRemoved];
|
|
326
340
|
const verb = dryRun ? 'would rm' : 'rm';
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.24.
|
|
1
|
+
export const version = '2.24.1';
|