sandstone-cli 1.2.0 → 1.2.2

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.
@@ -82,9 +82,9 @@ export async function createCommand(_project, opts) {
82
82
  const { saveChoice } = await inquirer.prompt({
83
83
  name: 'saveChoice',
84
84
  type: 'list',
85
- message: 'Where do you want your pack(s) to be saved (can be changed later)?',
85
+ message: 'Where do you want your pack(s) to be exported to (can be changed later)?',
86
86
  choices: [{
87
- name: 'In the root client (.minecraft) folder',
87
+ name: 'In the root client (.minecraft/datapacks & .minecraft/resourcepacks) folder(s)',
88
88
  value: 'root',
89
89
  short: 'Client folder',
90
90
  }, {
@@ -95,27 +95,34 @@ export async function createCommand(_project, opts) {
95
95
  name: 'In a server',
96
96
  value: 'server-path',
97
97
  short: 'Server path',
98
+ }, {
99
+ name: 'N/A',
100
+ value: 'none',
101
+ short: 'None',
98
102
  }],
99
103
  });
100
- if (saveChoice === 'root') {
101
- saveOptions.root = true;
102
- }
103
- else if (saveChoice === 'world') {
104
- const { world } = await inquirer.prompt({
105
- name: 'world',
106
- message: 'What world do you want to save the packs in? >',
107
- type: 'list',
108
- choices: getWorldsList,
109
- });
110
- saveOptions.world = world;
111
- }
112
- else { // TODO: Add native folder selector
113
- const { serverPath } = await inquirer.prompt({
114
- name: 'serverPath',
115
- message: 'Where is the server to save the packs in? Relative paths are accepted. >',
116
- type: 'input',
117
- });
118
- saveOptions.serverPath = serverPath;
104
+ switch (saveChoice) {
105
+ case 'root':
106
+ saveOptions.root = true;
107
+ break;
108
+ case 'world':
109
+ const { world } = await inquirer.prompt({
110
+ name: 'world',
111
+ message: 'What world do you want to save the packs in? >',
112
+ type: 'list',
113
+ choices: getWorldsList,
114
+ });
115
+ saveOptions.world = world;
116
+ break;
117
+ case 'server-path':
118
+ const { serverPath } = await inquirer.prompt({
119
+ name: 'serverPath',
120
+ message: 'Where is the server to save the packs in? Relative paths are accepted. >',
121
+ type: 'input',
122
+ });
123
+ saveOptions.serverPath = serverPath;
124
+ break;
125
+ case 'none': break;
119
126
  }
120
127
  }
121
128
  if (opts.clientPath) {
@@ -146,7 +153,6 @@ export async function createCommand(_project, opts) {
146
153
  exec(`git checkout ${projectType}-${version[0]}`);
147
154
  exec('npx rimraf -rf .git');
148
155
  exec(`${packageManager} install`);
149
- // TODO: Make profiles for either packs or libraries
150
156
  const configPath = path.join(projectPath, `${projectType === 'library' ? 'test/' : ''}sandstone.config.ts`);
151
157
  // Merge with the config values
152
158
  let templateConfig = await fs.readFile(configPath, 'utf8');
@@ -155,7 +161,6 @@ export async function createCommand(_project, opts) {
155
161
  templateConfig = templateConfig.replace('namespace: \'default\'', `namespace: ${toJson(namespace)}`);
156
162
  // TODO: packFormat
157
163
  const optsJson = toJson(Object.fromEntries(Object.entries(saveOptions).filter(([_, value]) => value !== undefined)));
158
- console.log(saveOptions, optsJson);
159
164
  if (optsJson !== '{}') {
160
165
  templateConfig = templateConfig.replace('saveOptions: {}', `saveOptions: ${optsJson}`);
161
166
  }
package/lib/create.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Argument, Command } from 'commander';
3
3
  import figlet from 'figlet';
4
4
  import { createCommand } from './commands/index.js';
5
- import { BuildDeclares } from './index.js';
5
+ import { BuildDeclares } from './shared.js';
6
6
  const commander = new Command();
7
7
  console.log(figlet.textSync('Sandstone'));
8
8
  const createCLI = commander
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export declare const BuildDeclares: Record<string, [string, string, RegExp, boolean]>;
2
+ export {};
package/lib/index.js CHANGED
@@ -2,30 +2,12 @@
2
2
  import { Argument, Command } from 'commander';
3
3
  import figlet from 'figlet';
4
4
  import { buildCommand, createCommand, watchCommand, installNativeCommand, installVanillaCommand, uninstallVanillaCommand, refreshCommand } from './commands/index.js';
5
+ import { BuildDeclares } from './shared.js';
5
6
  const commander = new Command();
6
7
  console.log(figlet.textSync('Sandstone'));
7
8
  const CLI = commander
8
9
  .version('1.0.0')
9
10
  .description('The CLI for Sandstone - the minecraft pack creation library.');
10
- export const BuildDeclares = {
11
- // Flags
12
- dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
13
- verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
14
- root: ['-r, --root', 'Save the pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.'],
15
- fullTrace: ['-t, --full-trace', 'Show the full stack trace on errors.'],
16
- strictErrors: ['-s, --strict-errors', 'Stop pack compilation on type errors.'],
17
- production: ['-p, --production', 'Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to "production".'],
18
- // Values
19
- path: ['--path <path>', 'Path of the folder containing source files.', './src'],
20
- config: ['--config-path', 'Path of the sandstone.config.ts folder.', './'],
21
- name: ['-n, --name <name>', 'Name of the datapack. Override the value specified in the configuration file.'],
22
- namespace: ['-ns, --namespace <namespace>', 'The default namespace. Override the value specified in the configuration file.'],
23
- world: ['-w, --world <name>', 'The name of the world to save the packs in. Override the value specified in the configuration file.'],
24
- clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
25
- serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
26
- // TODO: ssh
27
- // TODO: reimplement auto reload
28
- }; // Haha TypeScript funny
29
11
  const build = CLI
30
12
  .command('build')
31
13
  .description('Build the pack(s). ⛏');
@@ -0,0 +1 @@
1
+ export declare const BuildDeclares: Record<string, [string, string, RegExp, boolean]>;
package/lib/shared.js ADDED
@@ -0,0 +1,19 @@
1
+ export const BuildDeclares = {
2
+ // Flags
3
+ dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
4
+ verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
5
+ root: ['-r, --root', 'Save the pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.'],
6
+ fullTrace: ['-t, --full-trace', 'Show the full stack trace on errors.'],
7
+ strictErrors: ['-s, --strict-errors', 'Stop pack compilation on type errors.'],
8
+ production: ['-p, --production', 'Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to "production".'],
9
+ // Values
10
+ path: ['--path <path>', 'Path of the folder containing source files.', './src'],
11
+ config: ['--config-path', 'Path of the sandstone.config.ts folder.', './'],
12
+ name: ['-n, --name <name>', 'Name of the datapack. Override the value specified in the configuration file.'],
13
+ namespace: ['-ns, --namespace <namespace>', 'The default namespace. Override the value specified in the configuration file.'],
14
+ world: ['-w, --world <name>', 'The name of the world to save the packs in. Override the value specified in the configuration file.'],
15
+ clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
16
+ serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
17
+ // TODO: ssh
18
+ // TODO: reimplement auto reload
19
+ }; // Haha TypeScript funny
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "The CLI for Sandstone - the minecraft pack creation library.",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -111,12 +111,12 @@ export async function createCommand(_project: string, opts: CreateOptions) {
111
111
  saveOptions.serverPath = opts.serverPath
112
112
  } else { // TODO: Add support for ssh
113
113
  // User didn't specify a way to save the file. Ask them.
114
- const { saveChoice }: { saveChoice: 'root' | 'world' | 'server-path' } = await inquirer.prompt({
114
+ const { saveChoice }: { saveChoice: 'root' | 'world' | 'server-path' | 'none' } = await inquirer.prompt({
115
115
  name: 'saveChoice',
116
116
  type: 'list',
117
- message: 'Where do you want your pack(s) to be saved (can be changed later)?',
117
+ message: 'Where do you want your pack(s) to be exported to (can be changed later)?',
118
118
  choices: [{
119
- name: 'In the root client (.minecraft) folder',
119
+ name: 'In the root client (.minecraft/datapacks & .minecraft/resourcepacks) folder(s)',
120
120
  value: 'root',
121
121
  short: 'Client folder',
122
122
  }, {
@@ -127,27 +127,36 @@ export async function createCommand(_project: string, opts: CreateOptions) {
127
127
  name: 'In a server',
128
128
  value: 'server-path',
129
129
  short: 'Server path',
130
+ }, {
131
+ name: 'N/A',
132
+ value: 'none',
133
+ short: 'None',
130
134
  }],
131
135
  })
132
136
 
133
- if (saveChoice === 'root') {
134
- saveOptions.root = true
135
- } else if (saveChoice === 'world') {
136
- const { world }: { world: string } = await inquirer.prompt({
137
- name: 'world',
138
- message: 'What world do you want to save the packs in? >',
139
- type: 'list',
140
- choices: getWorldsList,
141
- })
142
- saveOptions.world = world
143
- } else { // TODO: Add native folder selector
144
- const { serverPath }: { serverPath: string } = await inquirer.prompt({
145
- name: 'serverPath',
146
- message: 'Where is the server to save the packs in? Relative paths are accepted. >',
147
- type: 'input',
148
- })
149
-
150
- saveOptions.serverPath = serverPath
137
+ switch (saveChoice) {
138
+ case 'root':
139
+ saveOptions.root = true
140
+ break
141
+ case 'world':
142
+ const { world }: { world: string } = await inquirer.prompt({
143
+ name: 'world',
144
+ message: 'What world do you want to save the packs in? >',
145
+ type: 'list',
146
+ choices: getWorldsList,
147
+ })
148
+ saveOptions.world = world
149
+ break
150
+ case 'server-path':
151
+ const { serverPath }: { serverPath: string } = await inquirer.prompt({
152
+ name: 'serverPath',
153
+ message: 'Where is the server to save the packs in? Relative paths are accepted. >',
154
+ type: 'input',
155
+ })
156
+
157
+ saveOptions.serverPath = serverPath
158
+ break
159
+ case 'none': break
151
160
  }
152
161
  }
153
162
  if (opts.clientPath) {
@@ -189,8 +198,6 @@ export async function createCommand(_project: string, opts: CreateOptions) {
189
198
 
190
199
  exec(`${packageManager} install`)
191
200
 
192
- // TODO: Make profiles for either packs or libraries
193
-
194
201
  const configPath = path.join(projectPath, `${projectType === 'library' ? 'test/' : ''}sandstone.config.ts`)
195
202
 
196
203
  // Merge with the config values
@@ -206,8 +213,6 @@ export async function createCommand(_project: string, opts: CreateOptions) {
206
213
 
207
214
  const optsJson = toJson(Object.fromEntries(Object.entries(saveOptions).filter(([_, value]) => value !== undefined)))
208
215
 
209
- console.log(saveOptions, optsJson)
210
-
211
216
  if (optsJson !== '{}') {
212
217
  templateConfig = templateConfig.replace('saveOptions: {}', `saveOptions: ${optsJson}`)
213
218
  }
package/src/create.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Argument, Command } from 'commander';
3
3
  import figlet from 'figlet';
4
4
  import { createCommand } from './commands/index.js';
5
- import { BuildDeclares } from './index.js';
5
+ import { BuildDeclares } from './shared.js';
6
6
 
7
7
  const commander = new Command()
8
8
 
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import { Argument, Command } from 'commander';
3
3
  import figlet from 'figlet';
4
4
  import { buildCommand, createCommand, watchCommand, installNativeCommand, installVanillaCommand, uninstallVanillaCommand, refreshCommand } from './commands/index.js';
5
+ import { BuildDeclares } from './shared.js';
5
6
 
6
7
  const commander = new Command()
7
8
 
@@ -11,27 +12,6 @@ const CLI = commander
11
12
  .version('1.0.0')
12
13
  .description('The CLI for Sandstone - the minecraft pack creation library.')
13
14
 
14
- export const BuildDeclares = {
15
- // Flags
16
- dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
17
- verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
18
- root: ['-r, --root', 'Save the pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.'],
19
- fullTrace: ['-t, --full-trace', 'Show the full stack trace on errors.'],
20
- strictErrors: ['-s, --strict-errors', 'Stop pack compilation on type errors.'],
21
- production: ['-p, --production', 'Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to "production".'],
22
-
23
- // Values
24
- path: ['--path <path>', 'Path of the folder containing source files.', './src'],
25
- config: ['--config-path', 'Path of the sandstone.config.ts folder.', './'],
26
- name: ['-n, --name <name>', 'Name of the datapack. Override the value specified in the configuration file.'],
27
- namespace: ['-ns, --namespace <namespace>', 'The default namespace. Override the value specified in the configuration file.'],
28
- world: ['-w, --world <name>', 'The name of the world to save the packs in. Override the value specified in the configuration file.'],
29
- clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
30
- serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
31
- // TODO: ssh
32
- // TODO: reimplement auto reload
33
- } as unknown as Record<string, [string, string, RegExp, boolean]> // Haha TypeScript funny
34
-
35
15
  const build = CLI
36
16
  .command('build')
37
17
  .description('Build the pack(s). ⛏')
package/src/shared.ts ADDED
@@ -0,0 +1,20 @@
1
+ export const BuildDeclares = {
2
+ // Flags
3
+ dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
4
+ verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
5
+ root: ['-r, --root', 'Save the pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.'],
6
+ fullTrace: ['-t, --full-trace', 'Show the full stack trace on errors.'],
7
+ strictErrors: ['-s, --strict-errors', 'Stop pack compilation on type errors.'],
8
+ production: ['-p, --production', 'Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to "production".'],
9
+
10
+ // Values
11
+ path: ['--path <path>', 'Path of the folder containing source files.', './src'],
12
+ config: ['--config-path', 'Path of the sandstone.config.ts folder.', './'],
13
+ name: ['-n, --name <name>', 'Name of the datapack. Override the value specified in the configuration file.'],
14
+ namespace: ['-ns, --namespace <namespace>', 'The default namespace. Override the value specified in the configuration file.'],
15
+ world: ['-w, --world <name>', 'The name of the world to save the packs in. Override the value specified in the configuration file.'],
16
+ clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
17
+ serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
18
+ // TODO: ssh
19
+ // TODO: reimplement auto reload
20
+ } as unknown as Record<string, [string, string, RegExp, boolean]> // Haha TypeScript funny