libdragon 10.0.0 → 10.3.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/CHANGELOG.md CHANGED
@@ -1,18 +1,118 @@
1
1
  # Change Log
2
2
 
3
+ ## [10.3.1] - 2022-01-25
4
+
5
+ ### Fixed
6
+
7
+ - Do not try to parse arguments after exec/make. They used to get evaluated as
8
+ libdragon paramaters previously, preventing passing down -v to the container
9
+ make for example.
10
+ - Docker image update issues
11
+ - Attempt an image update whenever the image flag is provided. Previously this
12
+ was only done if a different image name is provided, preventing the update of
13
+ the latest image. Previously not providing an image name was behaving the same
14
+ so this is not a breaking change.
15
+ - Start action used to update the image if provided but this bug was already
16
+ prevented by previous fixes by not accepting the image flag for actions other
17
+ than init/update/install. Start action no longer tries to update the image
18
+ regardless.
19
+
20
+ ### Changed
21
+
22
+ - Only accept he image flag for init, install, and update actions as documented.
23
+ - Improve documentation for the `init` and `install` actions.
24
+ - Do not attempt an `install` when running `exec`, just start the container. If
25
+ there is a half-baked container, a manual `install` will potentially restore it.
26
+ - Update libdragon.
27
+
28
+ ### Added
29
+
30
+ - Extra information for skipping the image flag when doing init for an already
31
+ initialized project.
32
+
33
+ ## [10.3.0] - 2022-01-20
34
+
35
+ ### Changed
36
+
37
+ - Update dependencies.
38
+ - Detailed help output.
39
+ - Move action descriptions to `libdragon help`.
40
+ - Update libdragon to latest version for local build.
41
+
42
+ ### Added
43
+
44
+ - Shorthand flag support.
45
+
46
+ ## [10.2.1] - 2021-10-14
47
+
48
+ ### Changed
49
+
50
+ - Updated ed64.
51
+
52
+ ### Fixed
53
+
54
+ - Fix skeleton project to match latest libdragon.
55
+
56
+ ## [10.2.0] - 2021-10-10
57
+
58
+ ### Added
59
+
60
+ - Container discovery. The tool can now find a container even if `.git` is lost.
61
+ - A few additional error messages for some potentially confusing cases such as
62
+ already having a file with `libdragon` like name.
63
+
64
+ ### Changed
65
+
66
+ - Show more output for downloading the container and initial git operations.
67
+ - Remove an extra log during initialization.
68
+ - The submodule was always being initialized when a container is started. This
69
+ was making some actions inconsistent. For example `install` or `make` action
70
+ was trying to re-initialize the submodule unnecessarily. This is fixed by only
71
+ initializing it with the `init` action. If any of those need to re-init the
72
+ container, now they assume there is an intact libdragon folder to use.
73
+ - Similarly a git repository is not initialized unnecessarily anymore.
74
+ - `update` and `install` are now able to start containers if necessary.
75
+ - Always try to copy skeleton files, they won't overwrite anything already.
76
+ - Do not re-initialize if there is a `.libdragon` folder. We now only try to
77
+ start it in this case. If it is not a complete container, it can probably be
78
+ recovered by a `libdragon install` or `libdragon update`.
79
+
80
+ ### Fixed
81
+
82
+ - Fix wording for libdragon install on the container.
83
+ - Improve image name persitence such that the tool finds and updates it more
84
+ consistently.
85
+
86
+ ## [10.1.0] - 2021-10-07
87
+
88
+ ### Added
89
+
90
+ - `exec` action to execute arbitrary commands in the container with TTY support.
91
+ This also improves the color output support as docker now knows it is using TTY.
92
+ - Add more verbose logging for skeleton project copy.
93
+
94
+ ### Changed
95
+
96
+ - Removed partially not working `--byte-swap` option. It does not already work
97
+ with the new libdragon build system so there is no need keeping it in the tool.
98
+
99
+ ### Fixed
100
+
101
+ - Publish skeleton project files to NPM.
102
+
3
103
  ## [10.0.0] - 2021-10-04
4
104
 
5
105
  ### Changed
6
106
 
7
107
  - A complete re-write of the tool. Check documentation for the new usage. It is
8
- much more straightforward to use now. `libdragon make` behaves almost the same.
108
+ much more straightforward to use now. `libdragon make` behaves almost the same.
9
109
 
10
110
  ## [9.0.0] - 2021-09-06
11
111
 
12
112
  ### Changed
13
113
 
14
114
  - Updated libdragon. We will be changing the update mechanism to be based on a
15
- git pull, so listing them here will not be useful anymore, let's not bother now.
115
+ git pull, so listing them here will not be useful anymore, let's not bother now.
16
116
  - Start using the new build system.
17
117
  - Update node engine spec to be at least 14.
18
118
  - Added minimum docker version to readme.
@@ -62,7 +162,6 @@ git pull, so listing them here will not be useful anymore, let's not bother now.
62
162
  - Support for RTC status/read/write commands (https://github.com/DragonMinded/libdragon/pull/152)
63
163
  - Generic libdragon NPM script
64
164
 
65
-
66
165
  ## [7.0.0] - 2021-06-06
67
166
 
68
167
  ### Changed
package/README.md CHANGED
@@ -36,49 +36,15 @@ You can invoke libdragon as follows;
36
36
 
37
37
  libdragon [flags] <action>
38
38
 
39
- ### Available actions
40
-
41
- __`init`__
42
-
43
- Creates a libdragon project in the current directory. Every libdragon project will have its own docker container instance. If you are in a git repository or an NPM project, libdragon will be initialized at their root also marking there with a `.libdragon` folder.
44
-
45
- A git repository and a submodule at `./libdragon` will also be created. Do not remove the `.libdragon` folder and you commit its contents if you are using git, as it keeps persistent libdragon project information.
46
-
47
- 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.
48
-
49
- __`make`__
50
-
51
- Runs the libdragon build system in the current directory. It will mirror your current working directory to the container. If you change your host working directory, `make` will be executed in the corresponding folder in the container as well.
52
-
53
- This action will first try to execute `make` in the container and if the container is not accessible, it will attempt a complete `start` cycle.
54
-
55
- __`install`__
56
-
57
- Attempts to build and install everything libdragon related into the container. This includes all the tools and third parties used by libdragon except for the toolchain. If you have made changes to libdragon, you can execute this action to build everything based on your changes. If you are not working on libdragon, you can just use the `update` action instead.
58
-
59
- __`update`__
60
-
61
- This action will update the submodule from the remote branch (`trunk`) with a merge strategy and then perform a `libdragon install`. You can use the `install` action to only update all libdragon related artifacts in the container given you have an intact `./libdragon` at the root.
62
-
63
- __`start`__
64
-
65
- Start the container assigned to the current libdragon project. Will first attempt to start an existing container if exists, followed by a new container run and `install` action. Will always print out the container id on success.
66
-
67
- __`stop`__
68
-
69
- Stop the container assigned to the current libdragon project.
39
+ Run `libdragon help [action]` for more details on individual actions.
70
40
 
71
41
  ### Available flags
72
42
 
73
- __`--image <docker-image>`__
43
+ **`--image <docker-image>`**
74
44
 
75
45
  Use this flag to provide a custom image to use instead of the default. It should include the toolchain at `/n64_toolchain`. It will be effective for `init`, `install` and `update` actions and will cause a re-initialization of the container if an image different from what was written to project configuration is provided.
76
46
 
77
- __`--byte-swap`__
78
-
79
- Enable byte-swapped ROM output for the build system.
80
-
81
- __`--verbose`__
47
+ **`--verbose`**
82
48
 
83
49
  Be verbose. This will print all commands dispatched and their outputs as well.
84
50
 
@@ -88,11 +54,15 @@ After cloning this repository on a system with node.js (`>= 14`) & docker (`>= 1
88
54
 
89
55
  npm install
90
56
 
91
- This will install all necessary NPM dependencies. Then run;
57
+ 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`)
58
+
59
+ git submodule update --init
60
+
61
+ Then run;
92
62
 
93
63
  npm run libdragon -- init
94
64
 
95
- to download the pre-built toolchain image from docker hub, get the original libdragon repository as a submodule, start and initialize it. This will also install [test bench](#local-test-bench) dependencies into the container if any.
65
+ 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.
96
66
 
97
67
  Now you will be able to work on the files simultaneously with the docker container and any built binaries will be available in your workspace as it is mounted on the container.
98
68
 
package/index.js CHANGED
@@ -3,95 +3,101 @@
3
3
  const chalk = require('chalk');
4
4
  const { readProjectInfo, CommandError, globals } = require('./modules/helpers');
5
5
  const actions = require('./modules/actions');
6
+ const { printUsage } = require('./modules/usage');
6
7
 
7
8
  const STATUS_OK = 0;
8
9
  const STATUS_ERROR = 1;
9
10
  const STATUS_BAD_PARAM = 2;
10
11
 
11
- // Command line options
12
- const options = {
13
- BYTE_SWAP: false,
14
- DOCKER_IMAGE: undefined,
15
- VERBOSE: false,
16
-
17
- ACTION: undefined,
18
- PARAMS: undefined,
19
- };
20
-
21
- // Allow standard io here
22
- /* eslint-disable no-console */
12
+ let options = {},
13
+ currentAction;
23
14
 
24
15
  for (let i = 2; i < process.argv.length; i++) {
25
16
  const val = process.argv[i];
26
17
 
27
- if (val === '--byte-swap') {
28
- options.BYTE_SWAP = true;
29
- continue;
30
- }
18
+ // Allow console here
19
+ /* eslint-disable no-console */
31
20
 
32
- if (val === '--verbose') {
21
+ if (['--verbose', '-v'].includes(val)) {
33
22
  options.VERBOSE = true;
34
23
  globals.verbose = true;
35
24
  continue;
36
25
  }
37
26
 
38
- if (val === '--image') {
27
+ if (['--image', '-i'].includes(val)) {
39
28
  options.DOCKER_IMAGE = process.argv[++i];
40
29
  continue;
30
+ } else if (val.indexOf('--image=') === 0) {
31
+ options.DOCKER_IMAGE = val.split('=')[1];
32
+ continue;
41
33
  }
42
34
 
43
35
  if (val.indexOf('--') >= 0) {
44
36
  console.error(chalk.red(`Invalid flag \`${val}\``));
45
- actions.help.fn();
37
+ printUsage();
46
38
  process.exit(STATUS_BAD_PARAM);
47
39
  }
48
40
 
49
- if (options.ACTION) {
41
+ if (currentAction) {
50
42
  console.error(
51
43
  chalk.red(`Expected only a single action, found: \`${val}\``)
52
44
  );
53
- actions.help.fn();
45
+ printUsage();
54
46
  process.exit(STATUS_BAD_PARAM);
55
47
  }
56
48
 
57
- options.ACTION = actions[val];
49
+ currentAction = actions[val];
58
50
 
59
- if (!options.ACTION) {
51
+ if (!currentAction) {
60
52
  console.error(chalk.red(`Invalid action \`${val}\``));
61
- actions.help.fn();
53
+ printUsage();
62
54
  process.exit(STATUS_BAD_PARAM);
63
55
  }
64
56
 
65
- if (options.ACTION.forwardsRestParams) {
57
+ if (currentAction.forwardsRestParams) {
66
58
  options.PARAMS = process.argv.slice(i + 1);
67
59
  break;
68
60
  }
69
61
  }
70
62
 
71
- if (!options.ACTION) {
63
+ if (!currentAction) {
72
64
  console.error(chalk.red('No action provided'));
73
- actions.help.fn();
65
+ printUsage();
74
66
  process.exit(STATUS_BAD_PARAM);
75
67
  }
76
68
 
69
+ if (currentAction === actions.exec && options.PARAMS.length === 0) {
70
+ console.error(chalk.red('You should provide a command to exec'));
71
+ printUsage(undefined, [currentAction.name]);
72
+ process.exit(STATUS_BAD_PARAM);
73
+ }
74
+
75
+ if (
76
+ ![actions.init, actions.install, actions.update].includes(currentAction) &&
77
+ options.DOCKER_IMAGE
78
+ ) {
79
+ console.error(chalk.red('Invalid flag: image'));
80
+ printUsage(undefined, [currentAction.name]);
81
+ process.exit(STATUS_BAD_PARAM);
82
+ }
77
83
 
78
84
  readProjectInfo()
79
85
  .then((info) =>
80
- options.ACTION.fn(
86
+ currentAction.fn(
81
87
  {
82
88
  ...info,
83
89
  options,
84
- ...options.ACTION,
90
+ ...currentAction,
85
91
  },
86
- options.PARAMS
92
+ options.PARAMS ?? []
87
93
  )
88
94
  )
89
95
  .catch((e) => {
90
- const userTargetedError = e instanceof CommandError && e.showOutput;
96
+ const userTargetedError = e instanceof CommandError && e.userCommand;
91
97
 
92
98
  // Show additional information to user if verbose or we did a mistake
93
99
  if (globals.verbose || !userTargetedError) {
94
- console.error(chalk.red(globals.verbose? e.stack : e.message));
100
+ console.error(chalk.red(globals.verbose ? e.stack : e.message));
95
101
  }
96
102
 
97
103
  // Print the underlying error out only if not verbose and we did a mistake