sandstone-cli 1.1.11 → 1.2.0

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.
@@ -25,3 +25,7 @@ jobs:
25
25
  - run: pnpm run build && npm publish
26
26
  env:
27
27
  NPM_TOKEN: ${{secrets.npm_token}}
28
+ - run: sed -i 's/sandstone-cli/create-sandstone/g' package.json
29
+ - run: npm publish
30
+ env:
31
+ NPM_TOKEN: ${{secrets.npm_token}}
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
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 './index.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.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ export declare const BuildDeclares: Record<string, [string, string, RegExp, boolean]>;
package/lib/index.js CHANGED
@@ -7,7 +7,7 @@ console.log(figlet.textSync('Sandstone'));
7
7
  const CLI = commander
8
8
  .version('1.0.0')
9
9
  .description('The CLI for Sandstone - the minecraft pack creation library.');
10
- const BuildDeclares = {
10
+ export const BuildDeclares = {
11
11
  // Flags
12
12
  dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
13
13
  verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
@@ -69,7 +69,6 @@ create.option.apply(create, BuildDeclares.name)
69
69
  .option.apply(create, BuildDeclares.world)
70
70
  .option.apply(create, BuildDeclares.clientPath)
71
71
  .option.apply(create, BuildDeclares.serverPath);
72
- // TODO
73
72
  const install = CLI
74
73
  .command('install')
75
74
  .alias('add')
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
- "version": "1.1.11",
3
+ "version": "1.2.0",
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 './index.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
@@ -11,7 +11,7 @@ const CLI = commander
11
11
  .version('1.0.0')
12
12
  .description('The CLI for Sandstone - the minecraft pack creation library.')
13
13
 
14
- const BuildDeclares = {
14
+ export const BuildDeclares = {
15
15
  // Flags
16
16
  dry: ['-d, --dry', 'Do not save the pack. Mostly useful with `verbose`.'],
17
17
  verbose: ['-v, --verbose', 'Log all resulting resources: functions, advancements...'],
@@ -83,7 +83,6 @@ create.option.apply(create, BuildDeclares.name)
83
83
  .option.apply(create, BuildDeclares.clientPath)
84
84
  .option.apply(create, BuildDeclares.serverPath)
85
85
 
86
- // TODO
87
86
  const install = CLI
88
87
  .command('install')
89
88
  .alias('add')