@jsenv/package-publish 1.7.3 → 1.8.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/package-publish",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Publish package to one or many registry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -17,32 +17,28 @@
|
|
|
17
17
|
"node": ">=16.13.0"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
|
-
"access": "public"
|
|
21
|
-
"registry": "https://registry.npmjs.org"
|
|
20
|
+
"access": "public"
|
|
22
21
|
},
|
|
23
22
|
"type": "module",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
26
|
-
"import": "./main.js"
|
|
25
|
+
"import": "./src/main.js"
|
|
27
26
|
},
|
|
28
27
|
"./*": "./*"
|
|
29
28
|
},
|
|
30
|
-
"main": "./main.js",
|
|
29
|
+
"main": "./src/main.js",
|
|
31
30
|
"files": [
|
|
32
|
-
"/src/"
|
|
33
|
-
"/main.js"
|
|
31
|
+
"/src/"
|
|
34
32
|
],
|
|
35
33
|
"scripts": {
|
|
36
|
-
"
|
|
37
|
-
"test": "node --experimental-json-modules ./script/test/test.mjs",
|
|
34
|
+
"test": "node --experimental-json-modules ./scripts/test.mjs",
|
|
38
35
|
"test-with-coverage": "npm run test -- --coverage",
|
|
39
36
|
"prettier": "prettier --write ."
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
|
-
"@jsenv/
|
|
43
|
-
"@jsenv/
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"semver": "7.3.5"
|
|
39
|
+
"@jsenv/fetch": "1.1.2",
|
|
40
|
+
"@jsenv/filesystem": "4.1.0",
|
|
41
|
+
"@jsenv/log": "2.0.1",
|
|
42
|
+
"semver": "7.3.7"
|
|
47
43
|
}
|
|
48
|
-
}
|
|
44
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// https://github.com/npm/registry-issue-archive/issues/34
|
|
3
3
|
// https://stackoverflow.com/questions/53212849/querying-information-about-specific-version-of-scoped-npm-package
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { fetchUrl } from "@jsenv/fetch"
|
|
6
6
|
|
|
7
7
|
export const fetchLatestInRegistry = async ({
|
|
8
8
|
registryUrl,
|
|
@@ -10,7 +10,7 @@ export const fetchLatestInRegistry = async ({
|
|
|
10
10
|
token,
|
|
11
11
|
}) => {
|
|
12
12
|
const requestUrl = `${registryUrl}/${packageName}`
|
|
13
|
-
const response = await
|
|
13
|
+
const response = await fetchUrl(requestUrl, {
|
|
14
14
|
method: "GET",
|
|
15
15
|
headers: {
|
|
16
16
|
// "user-agent": "jsenv",
|
package/src/internal/publish.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
1
2
|
import { exec } from "node:child_process"
|
|
2
|
-
import {
|
|
3
|
-
resolveUrl,
|
|
4
|
-
urlToFileSystemPath,
|
|
5
|
-
readFile,
|
|
6
|
-
writeFile,
|
|
7
|
-
removeEntry,
|
|
8
|
-
} from "@jsenv/filesystem"
|
|
3
|
+
import { readFile, writeFile, removeEntry } from "@jsenv/filesystem"
|
|
9
4
|
import { UNICODE } from "@jsenv/log"
|
|
10
5
|
|
|
11
6
|
import { setNpmConfig } from "./setNpmConfig.js"
|
|
@@ -26,7 +21,8 @@ export const publish = async ({
|
|
|
26
21
|
process.env.NODE_AUTH_TOKEN = previousValue
|
|
27
22
|
}
|
|
28
23
|
process.env.NODE_AUTH_TOKEN = token
|
|
29
|
-
const rootPackageFileUrl =
|
|
24
|
+
const rootPackageFileUrl = new URL("./package.json", rootDirectoryUrl)
|
|
25
|
+
.href
|
|
30
26
|
const rootPackageString = await readFile(rootPackageFileUrl)
|
|
31
27
|
const restorePackageFile = () =>
|
|
32
28
|
writeFile(rootPackageFileUrl, rootPackageString)
|
|
@@ -39,7 +35,7 @@ export const publish = async ({
|
|
|
39
35
|
JSON.stringify(packageObject, null, " "),
|
|
40
36
|
),
|
|
41
37
|
)
|
|
42
|
-
const npmConfigFileUrl =
|
|
38
|
+
const npmConfigFileUrl = new URL("./.npmrc", rootDirectoryUrl).href
|
|
43
39
|
let restoreNpmConfigFile
|
|
44
40
|
let projectNpmConfigString
|
|
45
41
|
try {
|
|
@@ -67,9 +63,9 @@ export const publish = async ({
|
|
|
67
63
|
try {
|
|
68
64
|
return await new Promise((resolve, reject) => {
|
|
69
65
|
const command = exec(
|
|
70
|
-
"npm publish",
|
|
66
|
+
"npm publish --no-workspaces",
|
|
71
67
|
{
|
|
72
|
-
cwd:
|
|
68
|
+
cwd: fileURLToPath(rootDirectoryUrl),
|
|
73
69
|
stdio: "silent",
|
|
74
70
|
},
|
|
75
71
|
(error) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
2
|
+
import { readFile } from "@jsenv/filesystem"
|
|
2
3
|
|
|
3
4
|
export const readProjectPackage = async ({ rootDirectoryUrl }) => {
|
|
4
|
-
const packageFileUrl =
|
|
5
|
+
const packageFileUrl = new URL("./package.json", rootDirectoryUrl).href
|
|
5
6
|
let packageObject
|
|
6
7
|
try {
|
|
7
8
|
const packageString = await readFile(packageFileUrl, { as: "string" })
|
|
@@ -13,7 +14,7 @@ export const readProjectPackage = async ({ rootDirectoryUrl }) => {
|
|
|
13
14
|
--- syntax error stack ---
|
|
14
15
|
${e.stack}
|
|
15
16
|
--- package.json path ---
|
|
16
|
-
${
|
|
17
|
+
${fileURLToPath(packageFileUrl)}`)
|
|
17
18
|
}
|
|
18
19
|
throw e
|
|
19
20
|
}
|
|
@@ -22,7 +23,7 @@ ${urlToFileSystemPath(packageFileUrl)}`)
|
|
|
22
23
|
throw new Error(
|
|
23
24
|
`cannot find project package.json
|
|
24
25
|
--- package.json path ---
|
|
25
|
-
${
|
|
26
|
+
${fileURLToPath(packageFileUrl)}`,
|
|
26
27
|
)
|
|
27
28
|
}
|
|
28
29
|
throw e
|
package/{main.js → src/main.js}
RENAMED
package/src/publishPackage.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
|
|
2
|
-
import { createLogger } from "@jsenv/
|
|
2
|
+
import { createLogger } from "@jsenv/log"
|
|
3
3
|
|
|
4
4
|
import { fetchLatestInRegistry } from "./internal/fetchLatestInRegistry.js"
|
|
5
5
|
import { publish } from "./internal/publish.js"
|