publish-flat 1.12.1 → 1.13.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.
- package/dist/PublishFlat.js +5 -5
- package/dist/copyJson.js +3 -4
- package/package.json +2 -4
package/dist/PublishFlat.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import { execFileSync } from 'node:child_process';
|
|
2
3
|
import os from 'node:os';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import Arborist from '@npmcli/arborist';
|
|
5
|
-
import fs from 'fs-extra';
|
|
6
6
|
import logdown from 'logdown';
|
|
7
7
|
import packlist from 'npm-packlist';
|
|
8
8
|
export class PublishFlat {
|
|
@@ -40,10 +40,10 @@ export class PublishFlat {
|
|
|
40
40
|
}, { filesInFlattenedDir: [], normalFiles: [] });
|
|
41
41
|
const outputDir = this.options.outputDir ? path.resolve(this.options.outputDir) : await this.createTempDir();
|
|
42
42
|
for (const file of normalFiles) {
|
|
43
|
-
await fs.
|
|
43
|
+
await fs.cp(path.join(this.packageDir, file), path.join(outputDir, file));
|
|
44
44
|
}
|
|
45
45
|
for (const { fileName, replacedFilename } of filesInFlattenedDir) {
|
|
46
|
-
await fs.
|
|
46
|
+
await fs.cp(path.join(this.packageDir, fileName), path.join(outputDir, replacedFilename));
|
|
47
47
|
}
|
|
48
48
|
this.logger.info(`Flattened ${files.length} files in "${outputDir}".`);
|
|
49
49
|
await this.cleanPackageJson(path.join(outputDir, 'package.json'), filesInFlattenedDir);
|
|
@@ -58,7 +58,7 @@ export class PublishFlat {
|
|
|
58
58
|
if (stdout) {
|
|
59
59
|
this.logger.info(stdout);
|
|
60
60
|
}
|
|
61
|
-
await fs.
|
|
61
|
+
await fs.rm(tempDir, { force: true, recursive: true });
|
|
62
62
|
}
|
|
63
63
|
cleanDirName(dirName) {
|
|
64
64
|
const separatorRegex = new RegExp('[\\/]*([^\\/]+)[\\/]*', 'g');
|
|
@@ -69,7 +69,7 @@ export class PublishFlat {
|
|
|
69
69
|
return cleanName;
|
|
70
70
|
}
|
|
71
71
|
async cleanPackageJson(filePath, filesInFlattenedDir) {
|
|
72
|
-
const packageJson = await fs.
|
|
72
|
+
const packageJson = JSON.parse(await fs.readFile(filePath, 'utf-8'));
|
|
73
73
|
if (Array.isArray(packageJson.files)) {
|
|
74
74
|
packageJson.files = packageJson.files
|
|
75
75
|
.map(fileName => fileName.replace(this.dirToFlattenRegex, ''))
|
package/dist/copyJson.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import path from 'node:path';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
3
|
async function checkFile(filePath) {
|
|
4
4
|
try {
|
|
5
5
|
await fs.access(filePath, fs.constants.F_OK | fs.constants.R_OK);
|
|
@@ -15,8 +15,7 @@ export async function copyJson(inputFile, outputFile, values) {
|
|
|
15
15
|
const inputResolved = path.resolve(inputFile);
|
|
16
16
|
const outputResolved = path.resolve(outputFile);
|
|
17
17
|
await checkFile(inputResolved);
|
|
18
|
-
await fs.
|
|
19
|
-
const originalJSON = await fs.readJSON(inputResolved);
|
|
18
|
+
const originalJSON = JSON.parse(await fs.readFile(inputResolved, 'utf-8'));
|
|
20
19
|
let newJSONRaw = await fs.readFile(outputResolved, 'utf-8');
|
|
21
20
|
let spaces = 2;
|
|
22
21
|
if (!newJSONRaw) {
|
|
@@ -35,5 +34,5 @@ export async function copyJson(inputFile, outputFile, values) {
|
|
|
35
34
|
newJSON[value] = originalJSON[value];
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
await fs.
|
|
37
|
+
await fs.writeFile(outputResolved, JSON.stringify(newJSON, null, spaces));
|
|
39
38
|
}
|
package/package.json
CHANGED
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
"@npmcli/arborist": "9.1.6",
|
|
9
9
|
"@types/npmcli__arborist": "6.3.1",
|
|
10
10
|
"commander": "14.0.2",
|
|
11
|
-
"fs-extra": "11.3.2",
|
|
12
11
|
"logdown": "3.3.1",
|
|
13
12
|
"npm-packlist": "10.0.3"
|
|
14
13
|
},
|
|
15
14
|
"description": "Publish your project without the dist directory",
|
|
16
15
|
"devDependencies": {
|
|
17
|
-
"@types/fs-extra": "11.0.4",
|
|
18
16
|
"@types/npm-packlist": "7.0.3",
|
|
19
17
|
"rimraf": "6.1.0",
|
|
20
18
|
"tsx": "4.20.6",
|
|
@@ -38,6 +36,6 @@
|
|
|
38
36
|
"start": "tsx src/cli.ts"
|
|
39
37
|
},
|
|
40
38
|
"type": "module",
|
|
41
|
-
"version": "1.
|
|
42
|
-
"gitHead": "
|
|
39
|
+
"version": "1.13.1",
|
|
40
|
+
"gitHead": "eedb2984fd69190a0b69a992d18fe451e714e04d"
|
|
43
41
|
}
|