sandstone-cli 1.2.1 → 1.2.3

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
  }
@@ -5,6 +5,7 @@ import { buildCommand } from './build.js';
5
5
  export async function watchCommand(opts) {
6
6
  let alreadyBuilding = false;
7
7
  let needRebuild = false;
8
+ // TODO: reimplement auto reload
8
9
  // let client: Client | null = null
9
10
  // TODO: add support for clients & resources that require restarts & world resets, sandstone-server should override the involved environment variables if mods are present that fix it
10
11
  /*if (flags.autoReload !== undefined) {
package/lib/index.js CHANGED
@@ -24,6 +24,7 @@ build.option.apply(build, BuildDeclares.dry)
24
24
  .option.apply(build, BuildDeclares.world)
25
25
  .option.apply(build, BuildDeclares.clientPath)
26
26
  .option.apply(build, BuildDeclares.serverPath)
27
+ .option.apply(build, BuildDeclares.enableSymlinks)
27
28
  .action(buildCommand);
28
29
  const watch = CLI
29
30
  .command('watch')
@@ -40,7 +41,8 @@ watch.option.apply(watch, BuildDeclares.dry)
40
41
  .option.apply(watch, BuildDeclares.namespace)
41
42
  .option.apply(watch, BuildDeclares.world)
42
43
  .option.apply(watch, BuildDeclares.clientPath)
43
- .option.apply(watch, BuildDeclares.serverPath);
44
+ .option.apply(watch, BuildDeclares.serverPath)
45
+ .option.apply(watch, BuildDeclares.enableSymlinks);
44
46
  const create = CLI
45
47
  .command('create')
46
48
  .description('Create a new Sandstone project. ⛏')
package/lib/shared.js CHANGED
@@ -15,5 +15,5 @@ export const BuildDeclares = {
15
15
  clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
16
16
  serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
17
17
  // TODO: ssh
18
- // TODO: reimplement auto reload
18
+ enableSymlinks: ['--enable-symlinks', 'Force enable/disable symlinks. Defaults to false. Useful if you want to enable symlinks on Windows.'],
19
19
  }; // Haha TypeScript funny
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
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
  }
@@ -28,6 +28,8 @@ export async function watchCommand(opts: WatchOptions) {
28
28
  let alreadyBuilding: boolean = false
29
29
  let needRebuild: boolean = false
30
30
 
31
+ // TODO: reimplement auto reload
32
+
31
33
  // let client: Client | null = null
32
34
 
33
35
  // TODO: add support for clients & resources that require restarts & world resets, sandstone-server should override the involved environment variables if mods are present that fix it
package/src/index.ts CHANGED
@@ -30,6 +30,8 @@ build.option.apply(build, BuildDeclares.dry)
30
30
  .option.apply(build, BuildDeclares.world)
31
31
  .option.apply(build, BuildDeclares.clientPath)
32
32
  .option.apply(build, BuildDeclares.serverPath)
33
+
34
+ .option.apply(build, BuildDeclares.enableSymlinks)
33
35
  .action(buildCommand)
34
36
 
35
37
  const watch = CLI
@@ -50,6 +52,8 @@ watch.option.apply(watch, BuildDeclares.dry)
50
52
  .option.apply(watch, BuildDeclares.world)
51
53
  .option.apply(watch, BuildDeclares.clientPath)
52
54
  .option.apply(watch, BuildDeclares.serverPath)
55
+
56
+ .option.apply(watch, BuildDeclares.enableSymlinks)
53
57
 
54
58
  const create = CLI
55
59
  .command('create')
package/src/shared.ts CHANGED
@@ -15,6 +15,8 @@ export const BuildDeclares = {
15
15
  world: ['-w, --world <name>', 'The name of the world to save the packs in. Override the value specified in the configuration file.'],
16
16
  clientPath: ['-c, --client-path <path>', 'Path of the client folder. Override the value specified in the configuration file.'],
17
17
  serverPath: ['--server-path <path>', 'Path of the server folder. Override the value specified in the configuration file.'],
18
+
18
19
  // TODO: ssh
19
- // TODO: reimplement auto reload
20
+
21
+ enableSymlinks: ['--enable-symlinks', 'Force enable/disable symlinks. Defaults to false. Useful if you want to enable symlinks on Windows.'],
20
22
  } as unknown as Record<string, [string, string, RegExp, boolean]> // Haha TypeScript funny