npm-pkgbuild 17.2.0 → 17.2.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/package.json +1 -1
- package/src/output/arch.mjs +6 -35
- package/src/output/debian.mjs +4 -4
- package/src/output/packager.mjs +14 -0
- package/src/output/rpm.mjs +11 -22
- package/src/util.mjs +9 -0
- package/types/extract-from-package.d.mts +1 -2
- package/types/output/arch.d.mts +0 -1
- package/types/output/packager.d.mts +1 -0
- package/types/output/rpm.d.mts +1 -1
- package/types/util.d.mts +1 -0
package/package.json
CHANGED
package/src/output/arch.mjs
CHANGED
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
fieldProvider,
|
|
21
21
|
quote,
|
|
22
22
|
utf8StreamOptions,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
compileFields,
|
|
24
|
+
normalizeExpression
|
|
25
25
|
} from "../util.mjs";
|
|
26
26
|
|
|
27
27
|
function* keyValueLines(key, value, options) {
|
|
@@ -117,28 +117,7 @@ export class ARCH extends Packager {
|
|
|
117
117
|
return `${p.name}-${p.version}-${p.release}-${p.arch}${this.fileNameExtension}`;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
if(Array.isArray(dependencies)) {
|
|
122
|
-
dependencies = Object.fromEntries(dependencies.map(d => {
|
|
123
|
-
const m = d.match(/^([^=<>]+)(.*)/)
|
|
124
|
-
return [m[1],m[2]];
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
return Object.entries(dependencies)
|
|
128
|
-
.filter(filterOutUnwantedDependencies())
|
|
129
|
-
.map(
|
|
130
|
-
([name, version]) =>
|
|
131
|
-
`${this.packageName(name)}${normalizeExpression(version)}`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async create(
|
|
136
|
-
sources,
|
|
137
|
-
transformer,
|
|
138
|
-
publishingDetails,
|
|
139
|
-
options,
|
|
140
|
-
expander
|
|
141
|
-
) {
|
|
120
|
+
async create(sources, transformer, publishingDetails, options, expander) {
|
|
142
121
|
const { properties, staging, destination } = await this.prepare(options);
|
|
143
122
|
|
|
144
123
|
if (properties.source) {
|
|
@@ -153,8 +132,9 @@ export class ARCH extends Packager {
|
|
|
153
132
|
yield `
|
|
154
133
|
package() {
|
|
155
134
|
depends=(${self
|
|
156
|
-
.makeDepends(properties.dependencies)
|
|
157
|
-
|
|
135
|
+
.makeDepends(properties.dependencies, (name, expression) =>
|
|
136
|
+
quote(`${self.packageName(name)}${normalizeExpression(expression)}`)
|
|
137
|
+
)
|
|
158
138
|
.join(" ")})
|
|
159
139
|
|
|
160
140
|
if [ "$(ls -A $srcdir)" ]
|
|
@@ -283,12 +263,3 @@ const fields = compileFields({
|
|
|
283
263
|
replaces: default_attribute,
|
|
284
264
|
options: default_attribute
|
|
285
265
|
});
|
|
286
|
-
|
|
287
|
-
function normalizeExpression(e) {
|
|
288
|
-
e = e.replace(/\-([\w\d]+)$/, "");
|
|
289
|
-
if (e.match(/^\d+/)) {
|
|
290
|
-
return `>=${e}`;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return e;
|
|
294
|
-
}
|
package/src/output/debian.mjs
CHANGED
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
fieldProvider,
|
|
20
20
|
extractFunctions,
|
|
21
21
|
utf8StreamOptions,
|
|
22
|
-
filterOutUnwantedDependencies,
|
|
23
22
|
compileFields
|
|
24
23
|
} from "../util.mjs";
|
|
25
24
|
|
|
@@ -115,9 +114,10 @@ export class DEBIAN extends Packager {
|
|
|
115
114
|
properties.dependencies &&
|
|
116
115
|
Object.keys(properties.dependencies).length > 0
|
|
117
116
|
) {
|
|
118
|
-
properties.Depends =
|
|
119
|
-
.
|
|
120
|
-
|
|
117
|
+
properties.Depends = this.makeDepends(
|
|
118
|
+
properties.dependencies,
|
|
119
|
+
(name, expression) => `${this.packageName(name)} (${expression})`
|
|
120
|
+
);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
const fp = fieldProvider(properties, fields);
|
package/src/output/packager.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { join } from "node:path";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { mkdtemp, mkdir } from "node:fs/promises";
|
|
4
4
|
import { publish } from "../publish.mjs";
|
|
5
|
+
import { filterOutUnwantedDependencies } from "../util.mjs";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {import('../publish.mjs').PublishingDetail} PublishingDetail
|
|
@@ -68,6 +69,19 @@ export class Packager {
|
|
|
68
69
|
return mapping[name] || name;
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
makeDepends(dependencies, exp=(name,expression)=>`${name}${expression}`) {
|
|
73
|
+
if(Array.isArray(dependencies)) {
|
|
74
|
+
dependencies = Object.fromEntries(dependencies.map(d => {
|
|
75
|
+
const m = d.match(/^([^=<>]+)(.*)/)
|
|
76
|
+
return [m[1],m[2]];
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
return dependencies && Object.entries(dependencies)
|
|
80
|
+
.filter(filterOutUnwantedDependencies())
|
|
81
|
+
.map(([name, expression]) => exp(name,expression)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
get fileNameExtension() {
|
|
72
86
|
// @ts-ignore
|
|
73
87
|
return this.constructor.fileNameExtension;
|
package/src/output/rpm.mjs
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
fieldProvider,
|
|
17
17
|
utf8StreamOptions,
|
|
18
18
|
extractFunctions,
|
|
19
|
-
filterOutUnwantedDependencies,
|
|
20
19
|
compileFields
|
|
21
20
|
} from "../util.mjs";
|
|
22
21
|
|
|
@@ -95,33 +94,23 @@ export class RPM extends Packager {
|
|
|
95
94
|
return false;
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
|
|
99
|
-
return
|
|
100
|
-
.
|
|
101
|
-
|
|
102
|
-
(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
/^\s*(<|<=|>|>=|=)\s*(\w+)/,
|
|
108
|
-
(match, p1, p2) => ` ${p1} ${p2}`
|
|
109
|
-
)}`
|
|
110
|
-
);
|
|
97
|
+
makeDepends(deps) {
|
|
98
|
+
return super.makeDepends(deps,(name, expression) =>
|
|
99
|
+
`${this.packageName(name)}${expression
|
|
100
|
+
.replace(/^\s*(\w+)/, (match, p1) => ` = ${p1}`)
|
|
101
|
+
.replace(/^\s*$/, "")
|
|
102
|
+
.replace(
|
|
103
|
+
/^\s*(<|<=|>|>=|=)\s*(\w+)/,
|
|
104
|
+
(match, p1, p2) => ` ${p1} ${p2}`
|
|
105
|
+
)}`);
|
|
111
106
|
}
|
|
112
107
|
|
|
113
|
-
async create(
|
|
114
|
-
sources,
|
|
115
|
-
transformer,
|
|
116
|
-
publishingDetails,
|
|
117
|
-
options,
|
|
118
|
-
expander
|
|
119
|
-
) {
|
|
108
|
+
async create(sources, transformer, publishingDetails, options, expander) {
|
|
120
109
|
const { properties, tmpdir, staging, destination } = await this.prepare(
|
|
121
110
|
options
|
|
122
111
|
);
|
|
123
112
|
|
|
124
|
-
properties.Requires = this.
|
|
113
|
+
properties.Requires = this.makeDepends(properties.dependencies);
|
|
125
114
|
|
|
126
115
|
if (properties.Packager?.length > 1) {
|
|
127
116
|
// TODO how to write several Packages ?
|
package/src/util.mjs
CHANGED
|
@@ -21,6 +21,15 @@ export function filterOutUnwantedDependencies() {
|
|
|
21
21
|
return ([name, version]) => version !== "-";
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export function normalizeExpression(e) {
|
|
25
|
+
e = e.replace(/\-([\w\d]+)$/, "");
|
|
26
|
+
if (e.match(/^\d+/)) {
|
|
27
|
+
return `>=${e}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return e;
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
export function mergeDependencies(a, b) {
|
|
25
34
|
if (!b) {
|
|
26
35
|
return a;
|
|
@@ -31,7 +31,7 @@ export const allInputs: (typeof NPMPackContentProvider)[];
|
|
|
31
31
|
/**
|
|
32
32
|
* All output formats
|
|
33
33
|
*/
|
|
34
|
-
export const allOutputs: (typeof ARCH | typeof
|
|
34
|
+
export const allOutputs: (typeof ARCH | typeof DOCKER)[];
|
|
35
35
|
export namespace npmArchMapping {
|
|
36
36
|
let arm64: string;
|
|
37
37
|
let arm: string;
|
|
@@ -69,6 +69,5 @@ export type PackageDefinition = {
|
|
|
69
69
|
};
|
|
70
70
|
import { NPMPackContentProvider } from "./content/npm-pack-content-provider.mjs";
|
|
71
71
|
import { ARCH } from "./output/arch.mjs";
|
|
72
|
-
import { OCI } from "./output/oci.mjs";
|
|
73
72
|
import { DOCKER } from "./output/docker.mjs";
|
|
74
73
|
import { ContentProvider } from "./content/content-provider.mjs";
|
package/types/output/arch.d.mts
CHANGED
|
@@ -9,7 +9,6 @@ export class ARCH extends Packager {
|
|
|
9
9
|
static get fields(): any;
|
|
10
10
|
static prepare(options?: {}, variant?: {}): Promise<boolean>;
|
|
11
11
|
get packageFileName(): string;
|
|
12
|
-
makeDepends(dependencies?: {}): string[];
|
|
13
12
|
create(sources: any, transformer: any, publishingDetails: any, options: any, expander: any): Promise<string>;
|
|
14
13
|
}
|
|
15
14
|
import { Packager } from "./packager.mjs";
|
|
@@ -38,6 +38,7 @@ export class Packager {
|
|
|
38
38
|
* @return {string} package name in the target eco-system
|
|
39
39
|
*/
|
|
40
40
|
packageName(name: string): string;
|
|
41
|
+
makeDepends(dependencies: any, exp?: (name: any, expression: any) => string): string[];
|
|
41
42
|
get fileNameExtension(): any;
|
|
42
43
|
get fields(): any;
|
|
43
44
|
get properties(): any;
|
package/types/output/rpm.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ export class RPM extends Packager {
|
|
|
22
22
|
arch: string;
|
|
23
23
|
}): Promise<boolean>;
|
|
24
24
|
get packageFileName(): string;
|
|
25
|
-
|
|
25
|
+
makeDepends(deps: any): string[];
|
|
26
26
|
create(sources: any, transformer: any, publishingDetails: any, options: any, expander: any): Promise<string>;
|
|
27
27
|
}
|
|
28
28
|
export type PublishingDetail = import("../publish.mjs").PublishingDetail;
|
package/types/util.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export function compileFields(fields: any): any;
|
|
2
2
|
export function filterOutUnwantedDependencies(): ([name, version]: [any, any]) => boolean;
|
|
3
|
+
export function normalizeExpression(e: any): any;
|
|
3
4
|
export function mergeDependencies(a: any, b: any): any;
|
|
4
5
|
/**
|
|
5
6
|
* Decode a password
|