@xpack/xpm-lib 3.0.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/LICENSE +21 -0
- package/README.md +223 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/chmod-recursive.d.ts +7 -0
- package/dist/lib/chmod-recursive.d.ts.map +1 -0
- package/dist/lib/chmod-recursive.js +81 -0
- package/dist/lib/chmod-recursive.js.map +1 -0
- package/dist/lib/errors.d.ts +11 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +26 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/functions/chmod-recursive.d.ts +7 -0
- package/dist/lib/functions/chmod-recursive.d.ts.map +1 -0
- package/dist/lib/functions/chmod-recursive.js +81 -0
- package/dist/lib/functions/chmod-recursive.js.map +1 -0
- package/dist/lib/functions/perform-substitutions.d.ts +20 -0
- package/dist/lib/functions/perform-substitutions.d.ts.map +1 -0
- package/dist/lib/functions/perform-substitutions.js +85 -0
- package/dist/lib/functions/perform-substitutions.js.map +1 -0
- package/dist/lib/functions/utils.d.ts +30 -0
- package/dist/lib/functions/utils.d.ts.map +1 -0
- package/dist/lib/functions/utils.js +70 -0
- package/dist/lib/functions/utils.js.map +1 -0
- package/dist/lib/init-template-base.d.ts +46 -0
- package/dist/lib/init-template-base.d.ts.map +1 -0
- package/dist/lib/init-template-base.js +275 -0
- package/dist/lib/init-template-base.js.map +1 -0
- package/dist/lib/liquid-actions.d.ts +32 -0
- package/dist/lib/liquid-actions.d.ts.map +1 -0
- package/dist/lib/liquid-actions.js +113 -0
- package/dist/lib/liquid-actions.js.map +1 -0
- package/dist/lib/liquid-build-configurations.d.ts +49 -0
- package/dist/lib/liquid-build-configurations.d.ts.map +1 -0
- package/dist/lib/liquid-build-configurations.js +267 -0
- package/dist/lib/liquid-build-configurations.js.map +1 -0
- package/dist/lib/liquid-drop.d.ts +13 -0
- package/dist/lib/liquid-drop.d.ts.map +1 -0
- package/dist/lib/liquid-drop.js +56 -0
- package/dist/lib/liquid-drop.js.map +1 -0
- package/dist/lib/liquid-engine.d.ts +5 -0
- package/dist/lib/liquid-engine.d.ts.map +1 -0
- package/dist/lib/liquid-engine.js +85 -0
- package/dist/lib/liquid-engine.js.map +1 -0
- package/dist/lib/liquid-package.d.ts +17 -0
- package/dist/lib/liquid-package.d.ts.map +1 -0
- package/dist/lib/liquid-package.js +70 -0
- package/dist/lib/liquid-package.js.map +1 -0
- package/dist/lib/package.d.ts +66 -0
- package/dist/lib/package.d.ts.map +1 -0
- package/dist/lib/package.js +700 -0
- package/dist/lib/package.js.map +1 -0
- package/dist/lib/perform-substitutions.d.ts +20 -0
- package/dist/lib/perform-substitutions.d.ts.map +1 -0
- package/dist/lib/perform-substitutions.js +85 -0
- package/dist/lib/perform-substitutions.js.map +1 -0
- package/dist/lib/policies.d.ts +13 -0
- package/dist/lib/policies.d.ts.map +1 -0
- package/dist/lib/policies.js +31 -0
- package/dist/lib/policies.js.map +1 -0
- package/dist/lib/substitutions-variables.d.ts +117 -0
- package/dist/lib/substitutions-variables.d.ts.map +1 -0
- package/dist/lib/substitutions-variables.js +51 -0
- package/dist/lib/substitutions-variables.js.map +1 -0
- package/dist/lib/types.d.ts +70 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +13 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +30 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +70 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +102 -0
- package/src/README.md +10 -0
- package/src/index.ts +35 -0
- package/src/lib/errors.ts +29 -0
- package/src/lib/functions/chmod-recursive.ts +103 -0
- package/src/lib/functions/perform-substitutions.ts +116 -0
- package/src/lib/functions/utils.ts +88 -0
- package/src/lib/init-template-base.ts +401 -0
- package/src/lib/liquid-actions.ts +179 -0
- package/src/lib/liquid-build-configurations.ts +410 -0
- package/src/lib/liquid-drop.ts +99 -0
- package/src/lib/liquid-engine.ts +135 -0
- package/src/lib/liquid-package.ts +108 -0
- package/src/lib/package.ts +946 -0
- package/src/lib/policies.ts +49 -0
- package/src/lib/substitutions-variables.ts +177 -0
- package/src/lib/types.ts +109 -0
- package/src/package.json +3 -0
- package/src/tsconfig.json +10 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the xPack project (http://xpack.github.io).
|
|
3
|
+
* Copyright (c) 2017-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
6
|
+
* for any purpose is hereby granted, under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can
|
|
9
|
+
* be obtained from https://opensource.org/license/mit.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */
|
|
13
|
+
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
// import assert from 'assert'
|
|
17
|
+
|
|
18
|
+
// https://nodejs.org/docs/latest/api/
|
|
19
|
+
import { Logger } from '@xpack/logger'
|
|
20
|
+
|
|
21
|
+
// https://www.npmjs.com/package/semver
|
|
22
|
+
import semver from 'semver'
|
|
23
|
+
|
|
24
|
+
// ----------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export class XpmPolicies {
|
|
27
|
+
#log: Logger
|
|
28
|
+
minVersion: string
|
|
29
|
+
|
|
30
|
+
shareNpmDependencies = false
|
|
31
|
+
nonHierarchicalLocalXpacksFolder = false
|
|
32
|
+
onlyStringDependencies = false
|
|
33
|
+
|
|
34
|
+
constructor({ log, minVersion }: { log: Logger; minVersion: string }) {
|
|
35
|
+
this.minVersion = minVersion || '0.0.0'
|
|
36
|
+
this.#log = log
|
|
37
|
+
|
|
38
|
+
// log.trace(`minVersion: ${this.minVersion}`)
|
|
39
|
+
this.shareNpmDependencies = semver.lt(this.minVersion, '0.14.0')
|
|
40
|
+
this.nonHierarchicalLocalXpacksFolder = semver.lt(this.minVersion, '0.16.0')
|
|
41
|
+
this.onlyStringDependencies = semver.lt(this.minVersion, '0.16.0')
|
|
42
|
+
|
|
43
|
+
this.#log.trace(
|
|
44
|
+
`policies.shareNpmDependencies: ${String(this.shareNpmDependencies)}`
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the xPack project (http://xpack.github.io).
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
6
|
+
* for any purpose is hereby granted, under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can
|
|
9
|
+
* be obtained from https://opensource.org/license/mit.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */
|
|
13
|
+
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
import * as os from 'node:os'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
export type XpmLiquidSubstitutionsStrings = Record<string, string | string[]>
|
|
22
|
+
|
|
23
|
+
export interface XpmLiquidSubstitutionsVariables {
|
|
24
|
+
/**
|
|
25
|
+
* https://nodejs.org/dist/latest-v16.x/docs/api/process.html#process_process_env
|
|
26
|
+
*/
|
|
27
|
+
env: NodeJS.ProcessEnv
|
|
28
|
+
/**
|
|
29
|
+
* https://nodejs.org/dist/latest-v16.x/docs/api/os.html
|
|
30
|
+
*/
|
|
31
|
+
os: {
|
|
32
|
+
/**
|
|
33
|
+
* The operating system-specific end-of-line marker.
|
|
34
|
+
* - `\n` on POSIX
|
|
35
|
+
* - `\r\n` on Windows
|
|
36
|
+
*/
|
|
37
|
+
EOL: string
|
|
38
|
+
/**
|
|
39
|
+
* Possible values are 'arm', 'arm64', 'ia32', 'mips', 'mipsel',
|
|
40
|
+
* 'ppc', 'ppc64', 's390', 's390x', 'x32', and 'x64'.
|
|
41
|
+
*/
|
|
42
|
+
arch: string
|
|
43
|
+
/**
|
|
44
|
+
* Contains commonly used operating system-specific constants
|
|
45
|
+
* for error codes, process signals, and so on. The specific
|
|
46
|
+
* constants defined are described in
|
|
47
|
+
* [OS constants](https://nodejs.org/dist/latest-v16.x/docs/api/os.html#os_os_constants_1)
|
|
48
|
+
*/
|
|
49
|
+
constants: {
|
|
50
|
+
signals: Record<string, number>
|
|
51
|
+
errno: Record<string, number>
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* An array of objects containing information about
|
|
55
|
+
* each logical CPU core.
|
|
56
|
+
*/
|
|
57
|
+
cpus: os.CpuInfo[]
|
|
58
|
+
/**
|
|
59
|
+
* A string identifying the endianness of the CPU
|
|
60
|
+
* for which the Node.js binary was compiled.
|
|
61
|
+
*
|
|
62
|
+
* Possible values are 'BE' for big endian and 'LE' for little endian.
|
|
63
|
+
*/
|
|
64
|
+
endianness: 'BE' | 'LE'
|
|
65
|
+
/**
|
|
66
|
+
* The string path of the current user's home directory.
|
|
67
|
+
*/
|
|
68
|
+
homedir: string
|
|
69
|
+
/**
|
|
70
|
+
* The host name of the operating system as a string.
|
|
71
|
+
*/
|
|
72
|
+
hostname: string
|
|
73
|
+
/**
|
|
74
|
+
* A string identifying the operating system platform.
|
|
75
|
+
* Possible values are 'aix', 'darwin', 'freebsd', 'linux', 'openbsd',
|
|
76
|
+
* 'sunos', and 'win32'.
|
|
77
|
+
*/
|
|
78
|
+
platform: NodeJS.Platform
|
|
79
|
+
/**
|
|
80
|
+
* The operating system as a string.
|
|
81
|
+
*/
|
|
82
|
+
release: string
|
|
83
|
+
/**
|
|
84
|
+
* Returns the operating system's default directory for
|
|
85
|
+
* temporary files as a string.
|
|
86
|
+
*/
|
|
87
|
+
tmpdir: string
|
|
88
|
+
/**
|
|
89
|
+
* Returns the operating system name as returned by uname(3).
|
|
90
|
+
* For example, it returns 'Linux' on Linux, 'Darwin' on macOS,
|
|
91
|
+
* and 'Windows_NT' on Windows.
|
|
92
|
+
*/
|
|
93
|
+
type: string
|
|
94
|
+
/**
|
|
95
|
+
* Returns a string identifying the kernel version.
|
|
96
|
+
*
|
|
97
|
+
* On POSIX systems, the operating system release is determined
|
|
98
|
+
* by calling `uname(3)`. On Windows, `RtlGetVersion()` is used,
|
|
99
|
+
* and if it is not available, `GetVersionExW()` will be used.
|
|
100
|
+
*/
|
|
101
|
+
version: string
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* https://nodejs.org/dist/latest-v16.x/docs/api/path.html
|
|
105
|
+
*/
|
|
106
|
+
path: {
|
|
107
|
+
/**
|
|
108
|
+
* Provides the platform-specific path delimiter:
|
|
109
|
+
* - `;` for Windows
|
|
110
|
+
* - `:` for POSIX
|
|
111
|
+
*/
|
|
112
|
+
delimiter: string
|
|
113
|
+
/**
|
|
114
|
+
* Provides the platform-specific path segment separator:
|
|
115
|
+
* - `\` on Windows
|
|
116
|
+
* - `/` on POSIX
|
|
117
|
+
*/
|
|
118
|
+
sep: string
|
|
119
|
+
win32: {
|
|
120
|
+
delimiter: string
|
|
121
|
+
sep: string
|
|
122
|
+
}
|
|
123
|
+
posix: {
|
|
124
|
+
delimiter: string
|
|
125
|
+
sep: string
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
package?: any
|
|
130
|
+
configuration?: {
|
|
131
|
+
name: string
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
[key: string]: any
|
|
134
|
+
}
|
|
135
|
+
properties: XpmLiquidSubstitutionsStrings
|
|
136
|
+
|
|
137
|
+
matrix?: XpmLiquidSubstitutionsStrings
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// eslint-disable-next-line max-len
|
|
141
|
+
export const xpmLiquidSubstitutionsVariablesBase: XpmLiquidSubstitutionsVariables =
|
|
142
|
+
{
|
|
143
|
+
env: process.env,
|
|
144
|
+
os: {
|
|
145
|
+
EOL: os.EOL,
|
|
146
|
+
arch: os.arch(),
|
|
147
|
+
constants: {
|
|
148
|
+
signals: os.constants.signals,
|
|
149
|
+
errno: os.constants.errno,
|
|
150
|
+
},
|
|
151
|
+
cpus: os.cpus(),
|
|
152
|
+
endianness: os.endianness(),
|
|
153
|
+
homedir: os.homedir(),
|
|
154
|
+
hostname: os.hostname(),
|
|
155
|
+
platform: os.platform(),
|
|
156
|
+
release: os.release(),
|
|
157
|
+
tmpdir: os.tmpdir(),
|
|
158
|
+
type: os.type(),
|
|
159
|
+
// os.version() available since 12.x
|
|
160
|
+
version: os.version(),
|
|
161
|
+
},
|
|
162
|
+
path: {
|
|
163
|
+
delimiter: path.delimiter,
|
|
164
|
+
sep: path.sep,
|
|
165
|
+
win32: {
|
|
166
|
+
delimiter: path.win32.delimiter,
|
|
167
|
+
sep: path.win32.sep,
|
|
168
|
+
},
|
|
169
|
+
posix: {
|
|
170
|
+
delimiter: path.posix.delimiter,
|
|
171
|
+
sep: path.posix.sep,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
properties: {},
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ----------------------------------------------------------------------------
|
package/src/lib/types.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the xPack project (http://xpack.github.io).
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
6
|
+
* for any purpose is hereby granted, under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can
|
|
9
|
+
* be obtained from https://opensource.org/license/mit.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Logger } from '@xpack/logger'
|
|
13
|
+
|
|
14
|
+
/* eslint max-len: [ "error", 80, { "ignoreUrls": true } ] */
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
export type JsonActionValue = string | string[]
|
|
19
|
+
|
|
20
|
+
export type JsonPropertyValue = string
|
|
21
|
+
|
|
22
|
+
export type JsonProperties = Record<string, JsonPropertyValue>
|
|
23
|
+
|
|
24
|
+
export type JsonBuildConfigurationInherits = string[]
|
|
25
|
+
|
|
26
|
+
export type JsonActions = Record<string, JsonActionValue>
|
|
27
|
+
|
|
28
|
+
export type JsonScripts = Record<string, string>
|
|
29
|
+
|
|
30
|
+
export type JsonDependencies = Record<string, string | JsonDependencyExtended>
|
|
31
|
+
|
|
32
|
+
export type JsonDependencyExtended = Record<string, string>
|
|
33
|
+
|
|
34
|
+
export interface JsonBuildConfiguration {
|
|
35
|
+
inherits?: JsonBuildConfigurationInherits | string
|
|
36
|
+
inherit?: JsonBuildConfigurationInherits | string // Deprecated
|
|
37
|
+
hidden?: boolean
|
|
38
|
+
properties?: JsonProperties
|
|
39
|
+
actions?: JsonActions
|
|
40
|
+
dependencies?: JsonDependencies
|
|
41
|
+
devDependencies?: JsonDependencies
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type JsonBuildConfigurations = Record<string, JsonBuildConfiguration>
|
|
45
|
+
|
|
46
|
+
export interface JsonXpack {
|
|
47
|
+
minimumXpmRequired?: string
|
|
48
|
+
binaries?: JsonXpmBinaries
|
|
49
|
+
executables?: Record<string, string>
|
|
50
|
+
bin?: Record<string, string> // Deprecated
|
|
51
|
+
properties?: JsonProperties
|
|
52
|
+
actions?: JsonActions
|
|
53
|
+
dependencies?: JsonDependencies
|
|
54
|
+
devDependencies?: JsonDependencies
|
|
55
|
+
buildConfigurations?: JsonBuildConfigurations
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type JsonXpmBinariesPlatforms = Record<string, JsonXpmPlatformFile>
|
|
59
|
+
|
|
60
|
+
export interface JsonXpmBinaries {
|
|
61
|
+
destination: string
|
|
62
|
+
baseUrl: string
|
|
63
|
+
skip?: number
|
|
64
|
+
platforms: JsonXpmBinariesPlatforms
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface JsonXpmPlatformFile {
|
|
68
|
+
fileName: string
|
|
69
|
+
sha256?: string
|
|
70
|
+
sha512?: string
|
|
71
|
+
baseUrl?: string
|
|
72
|
+
skip?: number
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface JsonNpmPackage {
|
|
76
|
+
name?: string
|
|
77
|
+
version?: string
|
|
78
|
+
scripts?: JsonScripts
|
|
79
|
+
bin?: Record<string, string> | string
|
|
80
|
+
dependencies?: JsonDependencies
|
|
81
|
+
devDependencies?: JsonDependencies
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
+
[key: string]: any // Allow any additional property
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface JsonXpmPackage extends JsonNpmPackage {
|
|
87
|
+
xpack: JsonXpack
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ----------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
export type XpmLiquidActionCommands = string[] // Always array of strings.
|
|
93
|
+
|
|
94
|
+
export interface XpmConfig {
|
|
95
|
+
doForce?: boolean
|
|
96
|
+
doSkipIfInstalled?: boolean
|
|
97
|
+
isDryRun?: boolean
|
|
98
|
+
properties?: Record<string, string | boolean | number>
|
|
99
|
+
[key: string]: unknown // Allow any additional property
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface XpmContext {
|
|
103
|
+
log: Logger
|
|
104
|
+
config: XpmConfig
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
+
[key: string]: any // Allow any additional property
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ----------------------------------------------------------------------------
|
package/src/package.json
ADDED