libdragon 11.1.2 → 11.2.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/README.md +32 -18
- package/modules/actions/init.js +62 -12
- package/modules/actions/update.js +2 -2
- package/modules/constants.js +1 -1
- package/modules/helpers.js +21 -4
- package/modules/npm-utils.js +10 -1
- package/modules/parameters.js +23 -2
- package/modules/project-info.js +18 -4
- package/modules/utils.js +6 -22
- package/package.json +10 -14
package/README.md
CHANGED
|
@@ -6,30 +6,34 @@ This is a wrapper for a docker container to make managing the libdragon toolchai
|
|
|
6
6
|
|
|
7
7
|
## Prerequisites
|
|
8
8
|
|
|
9
|
-
You should have [docker](https://www.docker.com/products/docker-desktop) (`>=
|
|
9
|
+
You should have [docker](https://www.docker.com/products/docker-desktop) (`>= 27.2.0`) installed on your system.
|
|
10
10
|
|
|
11
11
|
`git` is not strictly required to use the tool. Still, it is highly recommended to have git on your host machine as it will be used instead of the one in the container.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
|
-
This is primarily a node.js script which is also packaged as an executable. You have
|
|
15
|
+
This is primarily a node.js script which is also packaged as an executable. You have a few options:
|
|
16
16
|
|
|
17
|
-
###
|
|
17
|
+
### installer
|
|
18
18
|
|
|
19
|
-
Download the [
|
|
19
|
+
Download the [windows installer](https://github.com/anacierdem/libdragon-docker/releases/latest) and run it. This option is currently only available on Windows.
|
|
20
20
|
|
|
21
21
|
<details>
|
|
22
|
-
<summary>
|
|
22
|
+
<summary>Detailed instructions</summary>
|
|
23
23
|
|
|
24
24
|
- Download the Windows installer and run it
|
|
25
|
-
- It can show a "Windows protected your PC" warning.
|
|
25
|
+
- It can show a "Windows protected your PC" warning. Click "More info" and "Run anyway".
|
|
26
26
|
- You should now be able to use the `libdragon` on a command line or PowerShell.
|
|
27
27
|
- To update it with a new version, download a newer installer and repeat the steps above.
|
|
28
28
|
|
|
29
29
|
</details>
|
|
30
30
|
|
|
31
|
+
### pre-built executable
|
|
32
|
+
|
|
33
|
+
Download the [pre-built executable](https://github.com/anacierdem/libdragon-docker/releases/latest) for your system and put it somewhere on your PATH. It is discouraged to put it in your project folder.
|
|
34
|
+
|
|
31
35
|
<details>
|
|
32
|
-
<summary>Windows instructions
|
|
36
|
+
<summary>Windows instructions</summary>
|
|
33
37
|
|
|
34
38
|
- Download the Windows executable and copy it to `C:\bin`
|
|
35
39
|
- Press `Windows + R` key combination and then enter `rundll32 sysdm.cpl,EditEnvironmentVariables`
|
|
@@ -101,15 +105,19 @@ Run `libdragon help [action]` for more details on individual actions.
|
|
|
101
105
|
|
|
102
106
|
## Recipes
|
|
103
107
|
|
|
104
|
-
### Using a different branch
|
|
108
|
+
### Using a different libdragon branch
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
Use the `--branch` flag to set up a custom libdragon branch when initializing your project:
|
|
107
111
|
|
|
108
112
|
```bash
|
|
109
|
-
libdragon init
|
|
113
|
+
libdragon init --branch unstable
|
|
110
114
|
```
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
This will use the `unstable` toolchain and code.
|
|
117
|
+
|
|
118
|
+
### Switching to a different branch of libdragon
|
|
119
|
+
|
|
120
|
+
On an already initialized project, switch the submodule to the desired branch:
|
|
113
121
|
|
|
114
122
|
```bash
|
|
115
123
|
git -C ./libdragon checkout opengl
|
|
@@ -157,7 +165,7 @@ To be able to share your project with the library change, you just commit your c
|
|
|
157
165
|
|
|
158
166
|
## Working on this repository
|
|
159
167
|
|
|
160
|
-
After cloning this repository on a system with node.js (`>= 18`) & docker (`>=
|
|
168
|
+
After cloning this repository on a system with node.js (`>= 18`) & docker (`>= 27.2.0`), in this repository's root do;
|
|
161
169
|
|
|
162
170
|
```bash
|
|
163
171
|
npm install
|
|
@@ -200,7 +208,9 @@ Similarly to run the `clean` recipe, run;
|
|
|
200
208
|
npm run libdragon -- make clean
|
|
201
209
|
```
|
|
202
210
|
|
|
203
|
-
|
|
211
|
+
> [!IMPORTANT]
|
|
212
|
+
> Keep in mind that `--` is necessary for actual arguments when using npm scripts.
|
|
213
|
+
|
|
204
214
|
|
|
205
215
|
To update the submodule and re-build everything;
|
|
206
216
|
|
|
@@ -214,7 +224,8 @@ The root `bench` recipe is for building the code in root `src` folder. This is a
|
|
|
214
224
|
|
|
215
225
|
There are also vscode launch configurations to quickly build the examples, tests and the bench. If you have the `N64_EMU` environment variable set pointing at your favourite emulator ([ares](https://ares-emu.net/) is highly recommended), the launch configurations ending in `(emu)` will kick your emulator with the selected example/code. You can also just hit F5 to launch the selected configuration.
|
|
216
226
|
|
|
217
|
-
|
|
227
|
+
> [!NOTE]
|
|
228
|
+
> This repository also uses [ed64](https://github.com/anacierdem/ed64), so you can use the launch configurations without `(emu)` to run the code if you have an everdrive plugged in and your active configuration will just boot up.
|
|
218
229
|
|
|
219
230
|
You can clean everything with the `clean` recipe/task (open the command palette and choose `Run Task -> clean`).
|
|
220
231
|
|
|
@@ -278,7 +289,12 @@ To create your own dev container backed project, you can use the contents of the
|
|
|
278
289
|
- It will prepare the container and open it in the editor.
|
|
279
290
|
</details>
|
|
280
291
|
|
|
281
|
-
##
|
|
292
|
+
## Dependency management
|
|
293
|
+
|
|
294
|
+
> [!WARNING]
|
|
295
|
+
> This is an experimental feature.
|
|
296
|
+
|
|
297
|
+
### As an NPM dependency
|
|
282
298
|
|
|
283
299
|
You can install libdragon as an NPM dependency by `npm install libdragon --save` in order to use docker in your N64 projects. A `libdragon` command similar to global intallation is provided that can be used in your NPM scripts as follows;
|
|
284
300
|
|
|
@@ -292,7 +308,7 @@ You can install libdragon as an NPM dependency by `npm install libdragon --save`
|
|
|
292
308
|
|
|
293
309
|
See [here](https://github.com/anacierdem/ed64-example) for a full example.
|
|
294
310
|
|
|
295
|
-
|
|
311
|
+
### Developing a dependency
|
|
296
312
|
|
|
297
313
|
You can make an NPM package that a `libdragon` project can depend on. Just include a `Makefile` on the repository root with a default recipe and an `install` recipe. On the depending project, after installing libdragon and the dependency with `npm install <dep name> --save`, one can install libdragon dependencies on the current docker container using `package.json` scripts.
|
|
298
314
|
|
|
@@ -317,8 +333,6 @@ For example this `package.json` in the dependent project;
|
|
|
317
333
|
|
|
318
334
|
will init the container for this project and run `make && make install` for `ed64` upon running `npm install`. To develop a dependency [this](https://github.com/anacierdem/libdragon-dependency) is a good starting point.
|
|
319
335
|
|
|
320
|
-
This is an experimental dependency management.
|
|
321
|
-
|
|
322
336
|
## Funding
|
|
323
337
|
|
|
324
338
|
If this tool helped you, consider supporting its development by sponsoring it!
|
package/modules/actions/init.js
CHANGED
|
@@ -16,7 +16,6 @@ const {
|
|
|
16
16
|
const {
|
|
17
17
|
LIBDRAGON_PROJECT_MANIFEST,
|
|
18
18
|
LIBDRAGON_SUBMODULE,
|
|
19
|
-
LIBDRAGON_BRANCH,
|
|
20
19
|
LIBDRAGON_GIT,
|
|
21
20
|
} = require('../constants');
|
|
22
21
|
const {
|
|
@@ -27,6 +26,7 @@ const {
|
|
|
27
26
|
ValidationError,
|
|
28
27
|
toPosixPath,
|
|
29
28
|
toNativePath,
|
|
29
|
+
getImageName,
|
|
30
30
|
} = require('../helpers');
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -45,11 +45,15 @@ const autoDetect = async (info) => {
|
|
|
45
45
|
|
|
46
46
|
if (
|
|
47
47
|
vendorTargetExists &&
|
|
48
|
-
(await runGitMaybeHost(
|
|
49
|
-
|
|
50
|
-
'status',
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
(await runGitMaybeHost(
|
|
49
|
+
info,
|
|
50
|
+
['submodule', 'status', info.vendorDirectory],
|
|
51
|
+
{
|
|
52
|
+
inheritStdin: false,
|
|
53
|
+
inheritStdout: false,
|
|
54
|
+
inheritStderr: false,
|
|
55
|
+
}
|
|
56
|
+
).catch((e) => {
|
|
53
57
|
if (!(e instanceof CommandError)) {
|
|
54
58
|
throw e;
|
|
55
59
|
}
|
|
@@ -148,7 +152,7 @@ const autoVendor = async (info) => {
|
|
|
148
152
|
'--name',
|
|
149
153
|
LIBDRAGON_SUBMODULE,
|
|
150
154
|
'--branch',
|
|
151
|
-
|
|
155
|
+
info.activeBranchName,
|
|
152
156
|
LIBDRAGON_GIT,
|
|
153
157
|
info.vendorDirectory,
|
|
154
158
|
]);
|
|
@@ -156,6 +160,9 @@ const autoVendor = async (info) => {
|
|
|
156
160
|
if (!(e instanceof CommandError)) throw e;
|
|
157
161
|
// We speculate this is caused by the user, so replace it with a more useful error message.
|
|
158
162
|
e.message = `Unable to create submodule. If you have copied the executable in your project folder or you have a file named ${info.vendorDirectory}, removing it might solve this issue. Original error:\n${e.message}`;
|
|
163
|
+
if (e.out) {
|
|
164
|
+
e.message += `\n${e.out}`;
|
|
165
|
+
}
|
|
159
166
|
throw e;
|
|
160
167
|
}
|
|
161
168
|
|
|
@@ -189,7 +196,7 @@ const autoVendor = async (info) => {
|
|
|
189
196
|
'--prefix',
|
|
190
197
|
path.relative(info.root, info.vendorDirectory),
|
|
191
198
|
LIBDRAGON_GIT,
|
|
192
|
-
|
|
199
|
+
info.activeBranchName,
|
|
193
200
|
'--squash',
|
|
194
201
|
]);
|
|
195
202
|
return info;
|
|
@@ -252,11 +259,44 @@ async function init(info) {
|
|
|
252
259
|
}
|
|
253
260
|
|
|
254
261
|
if (!process.env.DOCKER_CONTAINER) {
|
|
255
|
-
|
|
256
|
-
|
|
262
|
+
let activeBranchName = info.options.BRANCH ?? info.activeBranchName;
|
|
263
|
+
let shouldOverrideBranch = !!info.options.BRANCH;
|
|
264
|
+
|
|
265
|
+
if ((await autoDetect(info)) === 'submodule') {
|
|
266
|
+
try {
|
|
267
|
+
const existingBranchName = await runGitMaybeHost(
|
|
268
|
+
info,
|
|
269
|
+
[
|
|
270
|
+
'-C',
|
|
271
|
+
path.relative(info.root, info.vendorDirectory),
|
|
272
|
+
'rev-parse',
|
|
273
|
+
'--abbrev-ref',
|
|
274
|
+
'HEAD',
|
|
275
|
+
],
|
|
276
|
+
{
|
|
277
|
+
inheritStdin: false,
|
|
278
|
+
inheritStdout: false,
|
|
279
|
+
inheritStderr: false,
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
activeBranchName = existingBranchName.trim();
|
|
283
|
+
shouldOverrideBranch = !!activeBranchName;
|
|
284
|
+
} catch {
|
|
285
|
+
// If we can't get the branch name, we will use the default
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
257
289
|
info = {
|
|
258
290
|
...info,
|
|
259
|
-
|
|
291
|
+
activeBranchName,
|
|
292
|
+
// We don't have a config yet, this is a fresh project, override with the
|
|
293
|
+
// image flag if provided. Also see https://github.com/anacierdem/libdragon-docker/issues/66
|
|
294
|
+
// Next, if `--branch` flag is provided use that or the one recovered from
|
|
295
|
+
// the submodule.
|
|
296
|
+
imageName:
|
|
297
|
+
(info.options.DOCKER_IMAGE ??
|
|
298
|
+
(shouldOverrideBranch && getImageName(activeBranchName))) ||
|
|
299
|
+
info.imageName,
|
|
260
300
|
};
|
|
261
301
|
// Download image and start it
|
|
262
302
|
await updateImage(info, info.imageName);
|
|
@@ -299,6 +339,16 @@ module.exports = /** @type {const} */ ({
|
|
|
299
339
|
If this is the first time you are creating a libdragon project at that location, this action will also create skeleton project files to kickstart things with the given image, if provided. For subsequent runs without any parameter, it will act like \`start\` thus can be used to revive an existing project without modifying it.
|
|
300
340
|
|
|
301
341
|
If you have an existing project with an already vendored submodule or subtree libdragon copy, \`init\` will automatically detect it at the provided \`--directory\`.`,
|
|
302
|
-
group: ['docker', 'vendoring'],
|
|
342
|
+
group: ['docker', 'vendoring', '_none'],
|
|
343
|
+
|
|
344
|
+
optionList: [
|
|
345
|
+
{
|
|
346
|
+
name: 'branch',
|
|
347
|
+
description:
|
|
348
|
+
'Provide a different branch to initialize libdragon. It will also change the toolchain docker image to be based on the given branch but `--image` will have precedence. Defaults to `trunk` & `latest` image.',
|
|
349
|
+
alias: 'b',
|
|
350
|
+
typeLabel: '<branch>',
|
|
351
|
+
},
|
|
352
|
+
],
|
|
303
353
|
},
|
|
304
354
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { log, assert } = require('../helpers');
|
|
2
|
-
const { LIBDRAGON_GIT
|
|
2
|
+
const { LIBDRAGON_GIT } = require('../constants');
|
|
3
3
|
const {
|
|
4
4
|
runGitMaybeHost,
|
|
5
5
|
installDependencies,
|
|
@@ -69,7 +69,7 @@ const update = async (info) => {
|
|
|
69
69
|
'--prefix',
|
|
70
70
|
info.vendorDirectory,
|
|
71
71
|
LIBDRAGON_GIT,
|
|
72
|
-
|
|
72
|
+
info.activeBranchName,
|
|
73
73
|
'--squash',
|
|
74
74
|
]);
|
|
75
75
|
}
|
package/modules/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports = /** @type {const} */ ({
|
|
2
|
-
DOCKER_HUB_IMAGE: 'ghcr.io/dragonminded/libdragon
|
|
2
|
+
DOCKER_HUB_IMAGE: 'ghcr.io/dragonminded/libdragon',
|
|
3
3
|
LIBDRAGON_GIT: 'https://github.com/DragonMinded/libdragon',
|
|
4
4
|
LIBDRAGON_BRANCH: 'trunk',
|
|
5
5
|
LIBDRAGON_SUBMODULE: 'libdragon',
|
package/modules/helpers.js
CHANGED
|
@@ -5,7 +5,11 @@ const chalk = require('chalk').stderr;
|
|
|
5
5
|
const { spawn } = require('child_process');
|
|
6
6
|
|
|
7
7
|
const { globals } = require('./globals');
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
NO_PROJECT_ACTIONS,
|
|
10
|
+
LIBDRAGON_BRANCH,
|
|
11
|
+
DOCKER_HUB_IMAGE,
|
|
12
|
+
} = require('./constants');
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* A structure to keep additional error information
|
|
@@ -392,7 +396,7 @@ async function copyDirContents(src, dst) {
|
|
|
392
396
|
await fs.writeFile(dest, content, {
|
|
393
397
|
flag: 'wx',
|
|
394
398
|
});
|
|
395
|
-
} catch
|
|
399
|
+
} catch {
|
|
396
400
|
log(`${dest} already exists, skipping.`);
|
|
397
401
|
return;
|
|
398
402
|
}
|
|
@@ -454,8 +458,8 @@ function log(text, verboseOnly = false) {
|
|
|
454
458
|
}
|
|
455
459
|
|
|
456
460
|
/**
|
|
457
|
-
* @param {import('./project-info').CLIInfo
|
|
458
|
-
* @returns {info is import('./project-info').
|
|
461
|
+
* @param {import('./project-info').CLIInfo} info
|
|
462
|
+
* @returns {info is import('./project-info').ProjectInfo}
|
|
459
463
|
*/
|
|
460
464
|
function isProjectAction(info) {
|
|
461
465
|
return !NO_PROJECT_ACTIONS.includes(
|
|
@@ -465,6 +469,18 @@ function isProjectAction(info) {
|
|
|
465
469
|
);
|
|
466
470
|
}
|
|
467
471
|
|
|
472
|
+
/**
|
|
473
|
+
* @param {string} branchName
|
|
474
|
+
* @returns {string}
|
|
475
|
+
*/
|
|
476
|
+
function getImageName(branchName) {
|
|
477
|
+
return (
|
|
478
|
+
DOCKER_HUB_IMAGE +
|
|
479
|
+
':' +
|
|
480
|
+
(branchName === LIBDRAGON_BRANCH ? 'latest' : branchName)
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
468
484
|
module.exports = {
|
|
469
485
|
spawnProcess,
|
|
470
486
|
toPosixPath,
|
|
@@ -480,4 +496,5 @@ module.exports = {
|
|
|
480
496
|
ParameterError,
|
|
481
497
|
ValidationError,
|
|
482
498
|
isProjectAction,
|
|
499
|
+
getImageName,
|
|
483
500
|
};
|
package/modules/npm-utils.js
CHANGED
|
@@ -121,7 +121,16 @@ const installNPMDependencies = async (libdragonInfo) => {
|
|
|
121
121
|
function runNPM(params) {
|
|
122
122
|
return spawnProcess(
|
|
123
123
|
/^win/.test(process.platform) ? 'npm.cmd' : 'npm',
|
|
124
|
-
params
|
|
124
|
+
params,
|
|
125
|
+
{
|
|
126
|
+
userCommand: false,
|
|
127
|
+
inheritStdin: true,
|
|
128
|
+
inheritStdout: false,
|
|
129
|
+
inheritStderr: false,
|
|
130
|
+
spawnOptions: {
|
|
131
|
+
shell: true,
|
|
132
|
+
},
|
|
133
|
+
}
|
|
125
134
|
);
|
|
126
135
|
}
|
|
127
136
|
module.exports = {
|
package/modules/parameters.js
CHANGED
|
@@ -19,6 +19,7 @@ const { globals } = require('./globals');
|
|
|
19
19
|
* VENDOR_DIR?: string;
|
|
20
20
|
* VENDOR_STRAT?: VendorStrategy;
|
|
21
21
|
* FILE?: string;
|
|
22
|
+
* BRANCH?: string;
|
|
22
23
|
* }} CommandlineOptions
|
|
23
24
|
*/
|
|
24
25
|
|
|
@@ -81,6 +82,14 @@ const parseParameters = async (argv) => {
|
|
|
81
82
|
continue;
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
if (['--branch', '-b'].includes(val)) {
|
|
86
|
+
options.BRANCH = argv[++i];
|
|
87
|
+
continue;
|
|
88
|
+
} else if (val.indexOf('--branch=') === 0) {
|
|
89
|
+
options.BRANCH = val.split('=')[1];
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
84
93
|
if (val.indexOf('-') == 0) {
|
|
85
94
|
log(chalk.red(`Invalid flag \`${val}\``));
|
|
86
95
|
process.exit(STATUS_BAD_PARAM);
|
|
@@ -126,7 +135,7 @@ const parseParameters = async (argv) => {
|
|
|
126
135
|
) &&
|
|
127
136
|
options.DOCKER_IMAGE
|
|
128
137
|
) {
|
|
129
|
-
log(chalk.red('Invalid flag: image'));
|
|
138
|
+
log(chalk.red('Invalid flag: --image'));
|
|
130
139
|
process.exit(STATUS_BAD_PARAM);
|
|
131
140
|
}
|
|
132
141
|
|
|
@@ -138,7 +147,19 @@ const parseParameters = async (argv) => {
|
|
|
138
147
|
) &&
|
|
139
148
|
options.FILE
|
|
140
149
|
) {
|
|
141
|
-
log(chalk.red('Invalid flag: file'));
|
|
150
|
+
log(chalk.red('Invalid flag: --file'));
|
|
151
|
+
process.exit(STATUS_BAD_PARAM);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (
|
|
155
|
+
!(
|
|
156
|
+
/** @type {typeof actions[keyof actions][]} */ ([actions.init]).includes(
|
|
157
|
+
options.CURRENT_ACTION
|
|
158
|
+
)
|
|
159
|
+
) &&
|
|
160
|
+
options.BRANCH
|
|
161
|
+
) {
|
|
162
|
+
log(chalk.red('Invalid flag: --branch'));
|
|
142
163
|
process.exit(STATUS_BAD_PARAM);
|
|
143
164
|
}
|
|
144
165
|
|
package/modules/project-info.js
CHANGED
|
@@ -12,11 +12,11 @@ const { findNPMRoot } = require('./npm-utils');
|
|
|
12
12
|
const {
|
|
13
13
|
LIBDRAGON_PROJECT_MANIFEST,
|
|
14
14
|
CONFIG_FILE,
|
|
15
|
-
DOCKER_HUB_IMAGE,
|
|
16
15
|
DEFAULT_STRATEGY,
|
|
17
16
|
LIBDRAGON_SUBMODULE,
|
|
18
17
|
CACHED_CONTAINER_FILE,
|
|
19
18
|
CONTAINER_TARGET_PATH,
|
|
19
|
+
LIBDRAGON_BRANCH,
|
|
20
20
|
} = require('./constants');
|
|
21
21
|
|
|
22
22
|
const {
|
|
@@ -27,6 +27,7 @@ const {
|
|
|
27
27
|
assert,
|
|
28
28
|
ParameterError,
|
|
29
29
|
isProjectAction,
|
|
30
|
+
getImageName,
|
|
30
31
|
} = require('./helpers');
|
|
31
32
|
|
|
32
33
|
/**
|
|
@@ -49,13 +50,18 @@ const {
|
|
|
49
50
|
*
|
|
50
51
|
* @typedef { {
|
|
51
52
|
* options: ActionsWithProjectOptions
|
|
53
|
+
* } } ProjectInfo
|
|
54
|
+
*
|
|
55
|
+
* @typedef { {
|
|
56
|
+
* options: ActionsWithProjectOptions
|
|
52
57
|
* root: string;
|
|
53
58
|
* userInfo: os.UserInfo<string>;
|
|
54
59
|
* haveProjectConfig: boolean;
|
|
55
60
|
* imageName: string;
|
|
56
61
|
* vendorDirectory: string;
|
|
57
62
|
* vendorStrategy: import('./parameters').VendorStrategy;
|
|
58
|
-
* containerId?: string
|
|
63
|
+
* containerId?: string;
|
|
64
|
+
* activeBranchName: string;
|
|
59
65
|
* } } LibdragonInfo
|
|
60
66
|
*/
|
|
61
67
|
|
|
@@ -189,6 +195,13 @@ const readProjectInfo = async function (optionInfo) {
|
|
|
189
195
|
|
|
190
196
|
vendorDirectory: toPosixPath(path.join('.', LIBDRAGON_SUBMODULE)),
|
|
191
197
|
vendorStrategy: DEFAULT_STRATEGY,
|
|
198
|
+
|
|
199
|
+
activeBranchName: LIBDRAGON_BRANCH,
|
|
200
|
+
|
|
201
|
+
// This is invalid at this point, but is overridden below from config file
|
|
202
|
+
// or container if it doesn't exist in the file. If a flag is provided, it
|
|
203
|
+
// will be overridden later.
|
|
204
|
+
imageName: '',
|
|
192
205
|
};
|
|
193
206
|
|
|
194
207
|
log(`Project root: ${info.root}`, true);
|
|
@@ -231,15 +244,16 @@ const readProjectInfo = async function (optionInfo) {
|
|
|
231
244
|
|
|
232
245
|
// For imageName, flag has the highest priority followed by the one read from
|
|
233
246
|
// the file and then if there is any matching container, name is read from it.
|
|
234
|
-
//
|
|
247
|
+
// Next if `--branch` flag and as last option fallback to default value.
|
|
235
248
|
// This represents the current value, so the flag should be processed later.
|
|
236
249
|
// If we were to update it here, it would be impossible to know the change
|
|
237
250
|
// with how we structure the code right now.
|
|
238
|
-
info.imageName = info.imageName
|
|
251
|
+
info.imageName = info.imageName || getImageName(info.activeBranchName);
|
|
239
252
|
|
|
240
253
|
log(`Active image name: ${info.imageName}`, true);
|
|
241
254
|
log(`Active vendor directory: ${info.vendorDirectory}`, true);
|
|
242
255
|
log(`Active vendor strategy: ${info.vendorStrategy}`, true);
|
|
256
|
+
log(`Active branch: ${info.activeBranchName}`, true);
|
|
243
257
|
|
|
244
258
|
return info;
|
|
245
259
|
};
|
package/modules/utils.js
CHANGED
|
@@ -137,29 +137,9 @@ async function runGitMaybeHost(libdragonInfo, params, options = {}) {
|
|
|
137
137
|
try {
|
|
138
138
|
const isWin = /^win/.test(process.platform);
|
|
139
139
|
|
|
140
|
-
// When using host's git the actual top level can be higher in the tree
|
|
141
|
-
// rather that at the root of the project. We need to find it to run some
|
|
142
|
-
// git operations like subtree.
|
|
143
|
-
const gitRoot = (
|
|
144
|
-
await spawnProcess(
|
|
145
|
-
'git',
|
|
146
|
-
['-C', libdragonInfo.root, 'rev-parse', '--show-toplevel'],
|
|
147
|
-
{ inheritStdin: false }
|
|
148
|
-
).catch(() => {
|
|
149
|
-
// Either this is not a git repo or the host does not have git
|
|
150
|
-
// We might also screw something up but we can live with it for now
|
|
151
|
-
return '';
|
|
152
|
-
})
|
|
153
|
-
).trim();
|
|
154
|
-
|
|
155
140
|
return await spawnProcess(
|
|
156
141
|
'git',
|
|
157
|
-
[
|
|
158
|
-
'-C',
|
|
159
|
-
libdragonInfo.root,
|
|
160
|
-
...(gitRoot ? ['--git-dir', `${gitRoot}/.git`] : []),
|
|
161
|
-
...params,
|
|
162
|
-
],
|
|
142
|
+
['-C', libdragonInfo.root, ...params],
|
|
163
143
|
// Windows git is breaking the TTY somehow - disable TTY for now
|
|
164
144
|
// We are not able to display progress for the initial clone b/c of this
|
|
165
145
|
// Enable progress otherwise.
|
|
@@ -287,7 +267,11 @@ async function initGitAndCacheContainerId(libdragonInfo) {
|
|
|
287
267
|
*/
|
|
288
268
|
async function ensureGit(info) {
|
|
289
269
|
const gitRoot = (
|
|
290
|
-
await runGitMaybeHost(info, ['rev-parse', '--show-toplevel']
|
|
270
|
+
await runGitMaybeHost(info, ['rev-parse', '--show-toplevel'], {
|
|
271
|
+
inheritStdin: false,
|
|
272
|
+
inheritStdout: false,
|
|
273
|
+
inheritStderr: false,
|
|
274
|
+
}).catch(() => {
|
|
291
275
|
// Probably host does not have git, can ignore
|
|
292
276
|
return '';
|
|
293
277
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libdragon",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "This is a docker wrapper for libdragon",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"start": "node index.js start",
|
|
18
18
|
"stop": "node index.js stop",
|
|
19
19
|
"pack": "pkg ./",
|
|
20
|
-
"format": "prettier **/*.js --write",
|
|
21
|
-
"format-check": "prettier **/*.js --check",
|
|
22
|
-
"lint": "eslint --fix
|
|
23
|
-
"lint-check": "eslint
|
|
20
|
+
"format": "prettier **/*.js **/*.mjs **/*.cjs --write",
|
|
21
|
+
"format-check": "prettier **/*.js **/*.mjs **/*.cjs --check",
|
|
22
|
+
"lint": "eslint --fix modules/**/*.js *.js *.mjs *.cjs",
|
|
23
|
+
"lint-check": "eslint modules/**/*.js *.js *.mjs *.cjs",
|
|
24
24
|
"tsc": "tsc"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chalk": "^4.1.0",
|
|
42
42
|
"command-line-usage": "^6.1.1",
|
|
43
|
-
"lodash": "^4.17.20"
|
|
43
|
+
"lodash": "^4.17.20",
|
|
44
|
+
"zx": "^8.1.8"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@semantic-release/changelog": "^6.0.1",
|
|
@@ -51,17 +52,12 @@
|
|
|
51
52
|
"commitizen": "^4.2.4",
|
|
52
53
|
"cz-conventional-changelog": "^3.3.0",
|
|
53
54
|
"ed64": "^2.0.4",
|
|
54
|
-
"eslint": "^
|
|
55
|
+
"eslint": "^9.11.0",
|
|
55
56
|
"jest": "^29.5.0",
|
|
56
57
|
"pkg": "^5.5.2",
|
|
57
58
|
"prettier": "^2.4.0",
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"typescript": "^4.7.4",
|
|
61
|
-
"zx": "^7.2.2"
|
|
62
|
-
},
|
|
63
|
-
"overrides": {
|
|
64
|
-
"minimist": "1.2.6"
|
|
59
|
+
"semantic-release": "^24.0.0",
|
|
60
|
+
"typescript": "^4.7.4"
|
|
65
61
|
},
|
|
66
62
|
"pkg": {
|
|
67
63
|
"targets": [
|