Skip to content

Commit aa8e4e7

Browse files
committed
v1.0.0
1 parent 8c457a8 commit aa8e4e7

25 files changed

+373
-269
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Commander - FoundryVTT at your fingertips
22

3+
## v1.0.0 (2022-09-02)
4+
- Added welcome message, and improved `i(nfo)` and `help` commands.
5+
- Manifest migration for v10
6+
- Full suggestions with up/down arrow keys
7+
- Renamed Application class from Widget -> Commander to make the foundry rendering console log less generic-looking (No more "Foundry VTT | Rendering Widget" without any clear finger pointing at Commander)
8+
- Fixed 'Open Compendium (comp)' command to not create a new Compendium instance and use the exiting app con the compendium (This caused that the open windows would not reflect changes on the underlying compendium even when they were happening in the background).
9+
10+
311
## v0.1.0 (2022-02-19)
412
- Initial Release
513
- Complete functionality, but pending some improvements before calling it v1.0.0

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ This module provides the command-line input and the API for registering new comm
1313

1414
## Bundled Commands
1515

16-
* Command info (i)
17-
* Log commands the current use can use (cmd:allowed)
16+
* Command info (info $command)
17+
* Show commands the current user can use (help)
1818
* Open tab (go $tab)
1919
* Open compendium (comp $title)
2020
* Run macro by name (m $name)
21-
* Open character sheet by Player name (sheet:player $name)
22-
* Open character sheet by Actor name (sheet:name $name)
21+
* Open character sheet by Player name (player $name)
22+
* Open character sheet by Actor name (pc $name)
23+
* Open non-player character sheet by name (npc $name)
2324
* Apply active effect to selected tokens -just visual- (tae $effect)
2425

2526
It is not the intention of this module to provide commands specific to particular systems, but mostly the tooling and more generic commands applicable to anyone regardless of game system. If you have such a command that you want to share, [don't be afraid to open a pull request](https://github.com/ccjmk/commander/pulls)!
@@ -28,9 +29,9 @@ It is not the intention of this module to provide commands specific to particula
2829
2930
## Executing Commands
3031

31-
You can open the Commander widget by pressing the corresponding keybinding, configurable in-game, with the default been Ctrl+Backtick. *(the ` right next to the 1 in english keyboards)*
32+
You can open the Commander widget by pressing (by default) Alt+Backtick *(the \` right next to the 1 in english keyboards)*. Shortcut is configurable ingame using the default keybinding menu.
3233

33-
Then you can start typing! Command suggestions will pop up as you type, you can auto-accept the selected suggestion with `Tab`/`Enter`, or select other suggestions using `Up` or `Down`. An `Enter` when no suggestion is selected sends the Command for execution.
34+
Then you can start typing! Command suggestions will pop up as you type, you can auto-accept the selected suggestion with `Tab`/`Enter`, or select other suggestions using `Up` or `Down`. An `Enter` when no suggestion is selected sends the Command for execution, else it auto-fills that suggestion.
3435

3536
## Licensing
3637

foundryconfig.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"dataPath": "/absolute/path/to/your/FoundryVTT"
2+
"dataPath": ["/absolute/path/to/your/FoundryVTT"]
33
}

gulpfile.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,26 @@ async function clean() {
8989
/**
9090
* Get the data path of Foundry VTT based on what is configured in `foundryconfig.json`
9191
*/
92-
function getDataPath() {
92+
function getDataPaths() {
9393
const config = fs.readJSONSync('foundryconfig.json');
94-
95-
if (config?.dataPath) {
96-
if (!fs.existsSync(path.resolve(config.dataPath))) {
97-
throw new Error('User Data path invalid, no Data directory found');
98-
}
99-
100-
return path.resolve(config.dataPath);
94+
const dataPath = config?.dataPath;
95+
96+
if (dataPath) {
97+
const dataPaths = Array.isArray(dataPath) ? dataPath : [dataPath];
98+
99+
return dataPaths.map((dataPath) => {
100+
if (typeof dataPath !== 'string') {
101+
throw new Error(
102+
`Property dataPath in foundryconfig.json is expected to be a string or an array of strings, but found ${dataPath}`,
103+
);
104+
}
105+
if (!fs.existsSync(path.resolve(dataPath))) {
106+
throw new Error(`The dataPath ${dataPath} does not exist on the file system`);
107+
}
108+
return path.resolve(dataPath);
109+
});
101110
} else {
102-
throw new Error('No User Data path defined in foundryconfig.json');
111+
throw new Error('No dataPath defined in foundryconfig.json');
103112
}
104113
}
105114

@@ -111,19 +120,23 @@ async function linkUserData() {
111120
if (fs.existsSync(path.resolve(sourceDirectory, 'module.json'))) {
112121
destinationDirectory = 'modules';
113122
} else {
114-
throw new Error('Could not find module.json');
123+
throw new Error(`Could not find ${chalk.blueBright('module.json')}`);
115124
}
116125

117-
const linkDirectory = path.resolve(getDataPath(), 'Data', destinationDirectory, name);
126+
const linkDirectories = getDataPaths().map((dataPath) => path.resolve(dataPath, 'Data', destinationDirectory, name));
118127

119-
if (argv.clean || argv.c) {
120-
console.log(`Removing build in ${linkDirectory}.`);
128+
for (const linkDirectory of linkDirectories) {
129+
if (argv.clean || argv.c) {
130+
console.log(`Removing build in ${linkDirectory}.`);
121131

122-
await fs.remove(linkDirectory);
123-
} else if (!fs.existsSync(linkDirectory)) {
124-
console.log(`Linking dist to ${linkDirectory}.`);
125-
await fs.ensureDir(path.resolve(linkDirectory, '..'));
126-
await fs.symlink(path.resolve(distDirectory), linkDirectory);
132+
await fs.remove(linkDirectory);
133+
} else if (!fs.existsSync(linkDirectory)) {
134+
console.log(`Linking dist to ${linkDirectory}.`);
135+
await fs.ensureDir(path.resolve(linkDirectory, '..'));
136+
await fs.symlink(path.resolve(distDirectory), linkDirectory);
137+
} else {
138+
console.log(`SKIPPING - link to ${linkDirectory} already exists`);
139+
}
127140
}
128141
}
129142

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"contributors": [
1515
{
1616
"name": "Iñaki 'ccjmk' Guastalli"
17+
},
18+
{
19+
"name": "Miguel Galante"
1720
}
1821
],
1922
"scripts": {

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const typescript = require('@rollup/plugin-typescript');
22
const { nodeResolve } = require('@rollup/plugin-node-resolve');
33

44
module.exports = {
5-
input: { ['commander']: 'src/module/module.ts' },
5+
input: { ['commander']: 'src/module/commander.ts' },
66
output: {
77
dir: 'dist/module',
88
format: 'es',

src/module.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "commander",
2+
"id": "commander",
33
"title": "Commander",
44
"description": "Command launcher for running and registering commands executable by keyboard",
55
"version": "This is auto replaced",
@@ -13,13 +13,18 @@
1313
"url": "https://www.linkedin.com/in/miguelgalante"
1414
}
1515
],
16-
"minimumCoreVersion": "9",
17-
"compatibleCoreVersion": "9",
16+
"compatibility": {
17+
"minimum": 10,
18+
"verified": "10.284"
19+
},
1820
"scripts": [],
1921
"esmodules": ["module/commander.js"],
2022
"styles": ["styles/commander.css"],
2123
"packs": [],
22-
"dependencies": [],
24+
"relationships": {
25+
"systems": [],
26+
"requires": []
27+
},
2328
"languages": [
2429
{
2530
"lang": "en",
@@ -35,6 +40,5 @@
3540
"readme": "This is auto replaced",
3641
"bugs": "This is auto replaced",
3742
"changelog": "This is auto replaced",
38-
"system": [],
3943
"library": false
4044
}

src/module/argument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Suggestion from './suggestion';
1+
import ArgumentSuggestion from './argumentSuggestion';
22
import { ARGUMENT_TYPES } from './utils/moduleUtils';
33

44
export default interface Argument {
55
name: string;
66
type: ARGUMENT_TYPES;
7-
suggestions?: (...params: any) => Suggestion[];
7+
suggestions?: (...params: any) => ArgumentSuggestion[];
88
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default interface Suggestion {
1+
export default interface ArgumentSuggestion {
22
content: string; // what is shown on the suggestion
33
icon?: string;
44
img?: string;

src/module/commandHandler.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import rawArg from './arguments/rawArg';
55
import stringArg from './arguments/stringArg';
66
import Command from './command';
77
import Argument from './argument';
8-
import Suggestion from './suggestion';
9-
import { getSetting, SETTING } from './settings';
8+
import ArgumentSuggestion from './argumentSuggestion';
109
import { getCommandSchemaWithoutArguments } from './utils/commandUtils';
11-
import { getGame, MODULE_NAME } from './utils/moduleUtils';
10+
import { getGame, MODULE_NAME, getSetting, SETTING } from './utils/moduleUtils';
1211
import { ARGUMENT_TYPES, localize } from './utils/moduleUtils';
1312

1413
const argumentMap = new Map<ARGUMENT_TYPES, ArgumentType>();
@@ -23,8 +22,6 @@ export default class CommandHandler {
2322

2423
constructor() {
2524
this.commandMap = new Map<string, Command>();
26-
// console.log(`${MODULE_NAME} | ${localize('Handler.RetrievingCommands')}`);
27-
// retrieveCommandsFromModuleSetting().forEach(c => this._register(c, false, true));
2825
}
2926

3027
get commands(): Command[] {
@@ -47,7 +44,7 @@ export default class CommandHandler {
4744
}
4845
};
4946

50-
suggestArguments = (input: string): Suggestion[] | undefined => {
47+
suggestArguments = (input: string): ArgumentSuggestion[] | undefined => {
5148
if (startsWithOverride(input)) return; // ignore chat rolls
5249
input = sanitizeInput(input);
5350
input = removeOrphanQuotes(input);

0 commit comments

Comments
 (0)