sandstone-cli 1.1.11 → 1.2.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/.github/workflows/npm-publish.yml +4 -0
- package/lib/commands/dependency.js +20 -1
- package/lib/create.d.ts +2 -0
- package/lib/create.js +18 -0
- package/lib/index.js +1 -20
- package/lib/shared.d.ts +1 -0
- package/lib/shared.js +19 -0
- package/package.json +3 -2
- package/src/commands/dependency.ts +24 -1
- package/src/create.ts +24 -0
- package/src/index.ts +1 -22
- package/src/shared.ts +20 -0
|
@@ -236,4 +236,23 @@ export async function uninstallVanillaCommand(_libraries) {
|
|
|
236
236
|
}
|
|
237
237
|
console.log(`${count} libraries removed`);
|
|
238
238
|
}
|
|
239
|
-
export async function refreshCommand() {
|
|
239
|
+
export async function refreshCommand() {
|
|
240
|
+
let lockFilePath = path.resolve('./resources/cache/lock-smithed.json');
|
|
241
|
+
let lockFile = false;
|
|
242
|
+
try {
|
|
243
|
+
lockFile = JSON.parse(await fs.readFile(lockFilePath, 'utf-8'));
|
|
244
|
+
}
|
|
245
|
+
catch (e) { }
|
|
246
|
+
if (lockFile) {
|
|
247
|
+
console.log('Refreshing libraries...');
|
|
248
|
+
await fs.remove(path.resolve('./resources/cache/smithed'));
|
|
249
|
+
await fs.writeFile(lockFilePath, '{}');
|
|
250
|
+
await buildCommand({
|
|
251
|
+
path: './src',
|
|
252
|
+
configPath: './'
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.log('No libraries to refresh');
|
|
257
|
+
}
|
|
258
|
+
}
|
package/lib/create.d.ts
ADDED
package/lib/create.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Argument, Command } from 'commander';
|
|
3
|
+
import figlet from 'figlet';
|
|
4
|
+
import { createCommand } from './commands/index.js';
|
|
5
|
+
import { BuildDeclares } from './shared.js';
|
|
6
|
+
const commander = new Command();
|
|
7
|
+
console.log(figlet.textSync('Sandstone'));
|
|
8
|
+
const createCLI = commander
|
|
9
|
+
.version('1.0.0')
|
|
10
|
+
.description('Create a new Sandstone project. ⛏')
|
|
11
|
+
.action(createCommand)
|
|
12
|
+
.addArgument(new Argument('<projectName>', 'Not the name of the output pack'));
|
|
13
|
+
createCLI.option.apply(createCLI, BuildDeclares.name)
|
|
14
|
+
.option.apply(createCLI, BuildDeclares.namespace)
|
|
15
|
+
.option.apply(createCLI, BuildDeclares.world)
|
|
16
|
+
.option.apply(createCLI, BuildDeclares.clientPath)
|
|
17
|
+
.option.apply(createCLI, BuildDeclares.serverPath);
|
|
18
|
+
createCLI.parse(process.argv);
|
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
|
-
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). ⛏');
|
|
@@ -69,7 +51,6 @@ create.option.apply(create, BuildDeclares.name)
|
|
|
69
51
|
.option.apply(create, BuildDeclares.world)
|
|
70
52
|
.option.apply(create, BuildDeclares.clientPath)
|
|
71
53
|
.option.apply(create, BuildDeclares.serverPath);
|
|
72
|
-
// TODO
|
|
73
54
|
const install = CLI
|
|
74
55
|
.command('install')
|
|
75
56
|
.alias('add')
|
package/lib/shared.d.ts
ADDED
|
@@ -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,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sandstone-cli",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "The CLI for Sandstone - the minecraft pack creation library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
7
7
|
"bin": {
|
|
8
|
-
"sand": "./lib/index.js"
|
|
8
|
+
"sand": "./lib/index.js",
|
|
9
|
+
"create-sandstone": "./lib/create.js"
|
|
9
10
|
},
|
|
10
11
|
"scripts": {
|
|
11
12
|
"test": "echo NO TESTS",
|
|
@@ -298,4 +298,27 @@ export async function uninstallVanillaCommand(_libraries: string[]) {
|
|
|
298
298
|
console.log(`${count} libraries removed`)
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
export async function refreshCommand() {
|
|
301
|
+
export async function refreshCommand() {
|
|
302
|
+
let lockFilePath = path.resolve('./resources/cache/lock-smithed.json')
|
|
303
|
+
|
|
304
|
+
let lockFile: Record<string, {}> | false = false
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
lockFile = JSON.parse(await fs.readFile(lockFilePath, 'utf-8'))
|
|
308
|
+
} catch (e) {}
|
|
309
|
+
|
|
310
|
+
if (lockFile) {
|
|
311
|
+
console.log('Refreshing libraries...')
|
|
312
|
+
|
|
313
|
+
await fs.remove(path.resolve('./resources/cache/smithed'))
|
|
314
|
+
|
|
315
|
+
await fs.writeFile(lockFilePath, '{}')
|
|
316
|
+
|
|
317
|
+
await buildCommand({
|
|
318
|
+
path: './src',
|
|
319
|
+
configPath: './'
|
|
320
|
+
})
|
|
321
|
+
} else {
|
|
322
|
+
console.log('No libraries to refresh')
|
|
323
|
+
}
|
|
324
|
+
}
|
package/src/create.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Argument, Command } from 'commander';
|
|
3
|
+
import figlet from 'figlet';
|
|
4
|
+
import { createCommand } from './commands/index.js';
|
|
5
|
+
import { BuildDeclares } from './shared.js';
|
|
6
|
+
|
|
7
|
+
const commander = new Command()
|
|
8
|
+
|
|
9
|
+
console.log(figlet.textSync('Sandstone'));
|
|
10
|
+
|
|
11
|
+
const createCLI = commander
|
|
12
|
+
.version('1.0.0')
|
|
13
|
+
.description('Create a new Sandstone project. ⛏')
|
|
14
|
+
.action(createCommand)
|
|
15
|
+
.addArgument(new Argument('<projectName>', 'Not the name of the output pack'))
|
|
16
|
+
|
|
17
|
+
createCLI.option.apply(createCLI, BuildDeclares.name)
|
|
18
|
+
.option.apply(createCLI, BuildDeclares.namespace)
|
|
19
|
+
.option.apply(createCLI, BuildDeclares.world)
|
|
20
|
+
.option.apply(createCLI, BuildDeclares.clientPath)
|
|
21
|
+
.option.apply(createCLI, BuildDeclares.serverPath)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
createCLI.parse(process.argv)
|
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
|
-
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). ⛏')
|
|
@@ -83,7 +63,6 @@ create.option.apply(create, BuildDeclares.name)
|
|
|
83
63
|
.option.apply(create, BuildDeclares.clientPath)
|
|
84
64
|
.option.apply(create, BuildDeclares.serverPath)
|
|
85
65
|
|
|
86
|
-
// TODO
|
|
87
66
|
const install = CLI
|
|
88
67
|
.command('install')
|
|
89
68
|
.alias('add')
|
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
|