libdragon 10.9.0 → 11.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/README.md CHANGED
@@ -6,7 +6,7 @@ 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) (`>= 18`) installed on your system.
9
+ You should have [docker](https://www.docker.com/products/docker-desktop) (`>= 24`) 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
 
@@ -51,9 +51,11 @@ Download the [pre-built executable](https://github.com/anacierdem/libdragon-dock
51
51
 
52
52
  ### via NPM
53
53
 
54
- Install [node.js](https://nodejs.org/en/download/) (`>= 14`) and install `libdragon` as a global NPM package;
54
+ Install [node.js](https://nodejs.org/en/download/) (`>= 18`) and install `libdragon` as a global NPM package;
55
55
 
56
+ ```bash
56
57
  npm install -g libdragon
58
+ ```
57
59
 
58
60
  To update the tool to the latest, do `npm i -g libdragon@latest`.
59
61
 
@@ -61,19 +63,25 @@ To update the tool to the latest, do `npm i -g libdragon@latest`.
61
63
 
62
64
  Navigate to the folder you want to initialize your project and invoke libdragon;
63
65
 
66
+ ```bash
64
67
  libdragon init
68
+ ```
65
69
 
66
70
  On first `init` an example project will be created, the container will be downloaded, started and latest libdragon will get installed on it with all the example ROMs built. You can find all the example ROMs in the `libdragon` folder.
67
71
 
68
72
  The container's `make` can be invoked on your current working directory via;
69
73
 
74
+ ```
70
75
  libdragon make
76
+ ```
71
77
 
72
78
  Any additonal parameters are passed down to the actual make command. You can work on the files simultaneously with the docker container and any built artifacts will be available in project directory as it is mounted on the container.
73
79
 
74
80
  To update the library and rebuild/install all the artifacts;
75
81
 
82
+ ```
76
83
  libdragon update
84
+ ```
77
85
 
78
86
  In general, you can invoke libdragon as follows;
79
87
 
@@ -87,22 +95,32 @@ Run `libdragon help [action]` for more details on individual actions.
87
95
 
88
96
  Initialize your project as usual:
89
97
 
98
+ ```bash
90
99
  libdragon init
100
+ ```
91
101
 
92
102
  Then switch the submodule to the desired branch:
93
103
 
94
- cd ./libdragon
95
- git checkout opengl
96
- cd ..
104
+ ```bash
105
+ git -C ./libdragon checkout opengl
97
106
  libdragon install
107
+ ```
108
+
109
+ If your changes are on a different remote, then you will need to manage your git remotes as usual. If you also want to update the remote tracking branch for the submodule, run:
110
+
111
+ ```bash
112
+ git submodule set-branch -b opengl libdragon
113
+ ```
98
114
 
99
- If your changes are on a different remote, then you will need to manage your git remotes as usual.
115
+ This will update the branch on `.gitmodules` and if you commit that change, subsequent initializations will use the `opengl` branch by default.
100
116
 
101
117
  ### Testing changes on libdragon
102
118
 
103
119
  As libdragon is an actively developed library, you may find yourself at a position where you want to change a few things on it and see how it works. In general, if you modify the files in `libdragon` folder of your project, you can install that version to the docker container by simply running:
104
120
 
121
+ ```bash
105
122
  libdragon install
123
+ ```
106
124
 
107
125
  This will update all the artifacts in your container and your new code will start linking against the new version when you re-build it via `libdragon make`. The build system should pick up the change in the library and re-compile the dependent files.
108
126
 
@@ -132,17 +150,23 @@ To be able to share your project with the library change, you just commit your c
132
150
 
133
151
  ## Working on this repository
134
152
 
135
- After cloning this repository on a system with node.js (`>= 14`) & docker (`>= 18`), in this repository's root do;
153
+ After cloning this repository on a system with node.js (`>= 18`) & docker (`>= 24`), in this repository's root do;
136
154
 
155
+ ```bash
137
156
  npm install
157
+ ```
138
158
 
139
159
  This will install all necessary NPM dependencies. Now it is time to get the original libdragon repository. (you can also clone this repository with `--recurse-submodules`)
140
160
 
161
+ ```bash
141
162
  git submodule update --init
163
+ ```
142
164
 
143
165
  Then run;
144
166
 
167
+ ```bash
145
168
  npm run libdragon -- init
169
+ ```
146
170
 
147
171
  to download the pre-built toolchain image, start and initialize it. This will also install [test bench](#local-test-bench) dependencies into the container if any.
148
172
 
@@ -160,17 +184,23 @@ There is a root `Makefile` making deeper makefiles easier with these recipes;
160
184
 
161
185
  For example, to re-build the original libdragon examples do;
162
186
 
187
+ ```bash
163
188
  npm run libdragon -- make examples
189
+ ```
164
190
 
165
191
  Similarly to run the `clean` recipe, run;
166
192
 
193
+ ```bash
167
194
  npm run libdragon -- make clean
195
+ ```
168
196
 
169
197
  Keep in mind that `--` is necessary for actual arguments when using npm scripts.
170
198
 
171
199
  To update the submodule and re-build everything;
172
200
 
201
+ ```bash
173
202
  npm run libdragon -- update
203
+ ```
174
204
 
175
205
  ### Local test bench
176
206
 
@@ -182,22 +212,36 @@ There are also additional vscode launch configurations to build libdragon exampl
182
212
 
183
213
  For a quick development loop it really helps linking the code in this repository as the global libdragon installation. To do this run;
184
214
 
215
+ ```bash
185
216
  npm link
217
+ ```
186
218
 
187
219
  in the root of the repository. Once you do this, running `libdragon` will use the code here rather than the actual npm installation. Then you can test your changes in the libdragon project here or elsewhere on your computer. This setup is automatically done if you use the [devcontainer](#experimental-devcontainer-support).
188
220
 
189
221
  When you are happy with your changes, you can verify you conform to the coding standards via:
190
222
 
223
+ ```bash
191
224
  npm run format-check
192
225
  npm run lint-check
226
+ ```
193
227
 
194
228
  You can auto-fix applicable errors by running `format` and `lint` scripts instead. Additionally, typescript is used as the type system. To be able to get away with transpiling the code during development, jsDoc flavor of types are used instead of inline ones. To check your types, run:
195
229
 
230
+ ```bash
196
231
  npm run tsc
232
+ ```
233
+
234
+ To run the test suite:
235
+
236
+ ```bash
237
+ npm run test
238
+ ```
197
239
 
198
240
  This repository uses [`semantic-release`](https://github.com/semantic-release/semantic-release) and manages releases from specially formatted commit messages. To simplify creating them you can use:
199
241
 
242
+ ```bash
200
243
  npx cz
244
+ ```
201
245
 
202
246
  It will create a `semantic-release` compatible commit from your current staged changes.
203
247
 
@@ -268,3 +312,4 @@ This is an experimental dependency management.
268
312
  ## Funding
269
313
 
270
314
  If this tool helped you, consider supporting its development by sponsoring it!
315
+
@@ -1,9 +1,5 @@
1
- const chalk = require('chalk').stderr;
2
-
3
1
  const { installDependencies } = require('./utils');
4
2
  const { start } = require('./start');
5
- const { syncImageAndStart } = require('./update-and-start');
6
- const { log } = require('../helpers');
7
3
 
8
4
  /**
9
5
  * Updates the image if flag is provided and install vendors onto the container.
@@ -15,22 +11,11 @@ const install = async (libdragonInfo) => {
15
11
  let updatedInfo = libdragonInfo;
16
12
 
17
13
  if (!process.env.DOCKER_CONTAINER) {
18
- const imageName = libdragonInfo.options.DOCKER_IMAGE;
19
- // If an image is provided, attempt to install
20
- if (imageName) {
21
- log(
22
- chalk.yellow(
23
- 'Using `install` action to update the docker image is deprecated. Use the `update` action instead.'
24
- )
25
- );
26
- updatedInfo = await syncImageAndStart(libdragonInfo);
27
- } else {
28
- // Make sure existing one is running
29
- updatedInfo = {
30
- ...updatedInfo,
31
- containerId: await start(libdragonInfo),
32
- };
33
- }
14
+ // Make sure existing one is running
15
+ updatedInfo = {
16
+ ...updatedInfo,
17
+ containerId: await start(libdragonInfo),
18
+ };
34
19
  }
35
20
 
36
21
  // Re-install vendors on new image
@@ -21,6 +21,4 @@ module.exports = /** @type {const} */ ({
21
21
  STATUS_ERROR: 1,
22
22
  STATUS_BAD_PARAM: 2,
23
23
  STATUS_VALIDATION_ERROR: 4,
24
-
25
- IMAGE_FILE: 'docker-image', // deprecated
26
24
  });
@@ -121,7 +121,6 @@ const parseParameters = async (argv) => {
121
121
  !(
122
122
  /** @type {typeof actions[keyof actions][]} */ ([
123
123
  actions.init,
124
- actions.install,
125
124
  actions.update,
126
125
  ]).includes(options.CURRENT_ACTION)
127
126
  ) &&
@@ -14,7 +14,6 @@ const {
14
14
  CONFIG_FILE,
15
15
  DOCKER_HUB_IMAGE,
16
16
  DEFAULT_STRATEGY,
17
- IMAGE_FILE,
18
17
  LIBDRAGON_SUBMODULE,
19
18
  CACHED_CONTAINER_FILE,
20
19
  CONTAINER_TARGET_PATH,
@@ -159,15 +158,7 @@ const readProjectInfo = async function (optionInfo) {
159
158
  return /** @type {NoProjectInfo} */ (optionInfo);
160
159
  }
161
160
 
162
- const migratedRoot = await findLibdragonRoot();
163
-
164
- // Look for old one for backwards compatibility
165
- const projectRoot =
166
- migratedRoot ??
167
- (await findLibdragonRoot(
168
- '.',
169
- path.join(LIBDRAGON_PROJECT_MANIFEST, IMAGE_FILE)
170
- ));
161
+ const projectRoot = await findLibdragonRoot();
171
162
 
172
163
  if (
173
164
  !projectRoot &&
@@ -204,7 +195,7 @@ const readProjectInfo = async function (optionInfo) {
204
195
 
205
196
  log(`Project root: ${info.root}`, true);
206
197
 
207
- if (migratedRoot) {
198
+ if (projectRoot) {
208
199
  info = {
209
200
  ...info,
210
201
  ...JSON.parse(
@@ -214,20 +205,6 @@ const readProjectInfo = async function (optionInfo) {
214
205
  )
215
206
  ),
216
207
  };
217
- } else {
218
- // Cleanup old files and migrate to the new config file
219
- const imageFile = path.join(
220
- info.root,
221
- LIBDRAGON_PROJECT_MANIFEST,
222
- IMAGE_FILE
223
- );
224
- if (await fileExists(imageFile)) {
225
- info.imageName = (
226
- await fs.readFile(imageFile, { encoding: 'utf8' })
227
- ).trim();
228
- // Immediately update the config as this is the first migration
229
- await Promise.all([writeProjectInfo(info), fs.rm(imageFile)]);
230
- }
231
208
  }
232
209
 
233
210
  if (!process.env.DOCKER_CONTAINER) {
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "libdragon",
3
- "version": "10.9.0",
3
+ "version": "11.0.0",
4
4
  "description": "This is a docker wrapper for libdragon",
5
5
  "main": "index.js",
6
6
  "engines": {
7
- "node": ">=14",
7
+ "node": ">=18",
8
8
  "npm": ">=8"
9
9
  },
10
10
  "bin": {
11
11
  "libdragon": "./index.js"
12
12
  },
13
13
  "scripts": {
14
+ "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
14
15
  "libdragon": "node index.js",
15
16
  "start": "node index.js start",
16
17
  "stop": "node index.js stop",
@@ -50,10 +51,14 @@
50
51
  "cz-conventional-changelog": "^3.3.0",
51
52
  "ed64": "^2.0.4",
52
53
  "eslint": "^7.32.0",
54
+ "ffi-napi": "^4.0.3",
55
+ "jest": "^29.5.0",
53
56
  "pkg": "^5.5.2",
54
57
  "prettier": "^2.4.0",
55
- "semantic-release": "^19.0.2",
56
- "typescript": "^4.7.4"
58
+ "ref-napi": "^3.0.3",
59
+ "semantic-release": "^21.0.9",
60
+ "typescript": "^4.7.4",
61
+ "zx": "^7.2.2"
57
62
  },
58
63
  "overrides": {
59
64
  "minimist": "1.2.6"