sandstone-cli 0.6.1 → 0.6.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g sandstone-cli
19
19
  $ sand COMMAND
20
20
  running command...
21
21
  $ sand (-v|--version|version)
22
- sandstone-cli/0.6.1 linux-x64 node-v16.19.0
22
+ sandstone-cli/0.6.3 linux-x64 node-v16.19.1
23
23
  $ sand --help [COMMAND]
24
24
  USAGE
25
25
  $ sand COMMAND
@@ -84,7 +84,7 @@ EXAMPLES
84
84
  $ sand build --verbose --dry
85
85
  ```
86
86
 
87
- _See code: [src/commands/build.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.1/src/commands/build.ts)_
87
+ _See code: [src/commands/build.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.3/src/commands/build.ts)_
88
88
 
89
89
  ## `sand create PROJECT-NAME`
90
90
 
@@ -95,11 +95,11 @@ USAGE
95
95
  $ sand create PROJECT-NAME
96
96
 
97
97
  ARGUMENTS
98
- PROJECT-NAME Name of the project folder. This is not the name of the data pack.
98
+ PROJECT-NAME Name of the project folder. This is not the name of the output pack(s).
99
99
 
100
100
  OPTIONS
101
101
  -c, --client-path=client-path The client path to write packs at.
102
- -d, --pack-name=pack-name The name of the data pack.
102
+ -d, --pack-name=pack-name The name of the pack(s).
103
103
  -h, --help show CLI help
104
104
  -n, --namespace=namespace The default namespace that will be used.
105
105
 
@@ -108,6 +108,10 @@ OPTIONS
108
108
 
109
109
  -s, --server-path=server-path The server path to write the server-side packs at. Not compatible with --world.
110
110
 
111
+ -t, --library Whether the project will be a library for use in other Sandstone projects.
112
+
113
+ -v, --version=version What version of Sandstone you'd like to create a project for.
114
+
111
115
  -w, --world=world The world to save the packs in. Not compatible with --save-root or --server
112
116
 
113
117
  --npm Use npm.
@@ -118,7 +122,7 @@ EXAMPLE
118
122
  $ sand create my-pack
119
123
  ```
120
124
 
121
- _See code: [src/commands/create.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.1/src/commands/create.ts)_
125
+ _See code: [src/commands/create.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.3/src/commands/create.ts)_
122
126
 
123
127
  ## `sand help [COMMAND]`
124
128
 
@@ -160,7 +164,7 @@ EXAMPLES
160
164
  $ sand update --cli --sandstone --skip
161
165
  ```
162
166
 
163
- _See code: [src/commands/update.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.1/src/commands/update.ts)_
167
+ _See code: [src/commands/update.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.3/src/commands/update.ts)_
164
168
 
165
169
  ## `sand watch PATH CONFIG-PATH`
166
170
 
@@ -212,5 +216,5 @@ EXAMPLES
212
216
  $ sand watch --verbose --dry
213
217
  ```
214
218
 
215
- _See code: [src/commands/watch.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.1/src/commands/watch.ts)_
219
+ _See code: [src/commands/watch.ts](https://github.com/TheMrZZ/sandstone-cli/blob/v0.6.3/src/commands/watch.ts)_
216
220
  <!-- commandsstop -->
@@ -23,4 +23,4 @@ export declare type BuildOptions = {
23
23
  *
24
24
  * @param changedFiles The files that changed since the last build.
25
25
  */
26
- export declare function buildProject(options: BuildOptions, folders: ProjectFolders, resourceTypes: string[], changedFiles?: string[]): Promise<void>;
26
+ export declare function buildProject(options: BuildOptions, folders: ProjectFolders, changedFiles?: string[]): Promise<void>;
@@ -34,6 +34,7 @@ const madge_1 = __importDefault(require("madge"));
34
34
  const graph_1 = require("./graph");
35
35
  const chalk_1 = __importDefault(require("chalk"));
36
36
  const adm_zip_1 = __importDefault(require("adm-zip"));
37
+ const delete_empty_1 = __importDefault(require("delete-empty"));
37
38
  const pe = new pretty_error_1.default();
38
39
  // Return the hash of a string
39
40
  function hash(stringToHash) {
@@ -54,7 +55,7 @@ async function mkDir(dirPath) {
54
55
  // Directory already exists
55
56
  }
56
57
  }
57
- let cache = {};
58
+ let cache;
58
59
  const dependenciesCache = new graph_1.DependencyGraph({});
59
60
  const fileResources = new Map();
60
61
  function getNewModules(dependenciesGraph, rawFiles, projectFolder) {
@@ -79,7 +80,7 @@ function diffMap(map1, map2) {
79
80
  return new Map([...map1.entries()].filter(([key, value]) => !map2.has(key)));
80
81
  }
81
82
  function diffResources(tree1, tree2) {
82
- return tree1.diff(tree2);
83
+ return diffSet(tree1, tree2);
83
84
  }
84
85
  /**
85
86
  *
@@ -131,8 +132,8 @@ async function getClientPath() {
131
132
  *
132
133
  * @param projectFolder The folder of the project. It needs a sandstone.config.ts, and it or one of its parent needs a package.json.
133
134
  */
134
- async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandstoneConfigFolder }, resourceTypes, changedFiles) {
135
- var _a, _b, _c, _d, _e;
135
+ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandstoneConfigFolder }, changedFiles) {
136
+ var _a, _b, _c, _d, _e, _f, _g;
136
137
  const sandstoneLocation = path_1.default.join(rootFolder, 'node_modules/sandstone/');
137
138
  // First, read sandstone.config.ts to get all properties
138
139
  const sandstoneConfig = require(path_1.default.join(sandstoneConfigFolder, 'sandstone.config.ts')).default;
@@ -183,6 +184,7 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
183
184
  else {
184
185
  process.env.SANDSTONE_ENV = 'development';
185
186
  }
187
+ process.env.WORKING_DIR = absProjectFolder;
186
188
  if (sandstoneConfig.packUid) {
187
189
  process.env.PACK_UID = sandstoneConfig.packUid;
188
190
  }
@@ -191,14 +193,10 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
191
193
  if (namespace) {
192
194
  process.env.NAMESPACE = namespace;
193
195
  }
194
- const { onConflict } = sandstoneConfig;
195
- if (onConflict) {
196
- if (onConflict.default) {
197
- process.env[`GENERAL_CONFLICT_STRATEGY`] = onConflict.default;
198
- }
199
- for (const resource of resourceTypes) {
200
- if (onConflict[resource]) {
201
- process.env[`${resource.toUpperCase()}_CONFLICT_STRATEGY`] = onConflict[resource];
196
+ for (const [k, pack] of Object.entries(sandstoneConfig.packs)) {
197
+ if (pack.onConflict) {
198
+ for (const resource of Object.entries(pack.onConflict)) {
199
+ process.env[`${resource[0].toUpperCase()}_CONFLICT_STRATEGY`] = resource[1];
202
200
  }
203
201
  }
204
202
  }
@@ -296,40 +294,123 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
296
294
  // Setup the cache if it doesn't exist.
297
295
  // This cache is here to avoid writing files on disk when they did not change.
298
296
  const newCache = {};
297
+ const cacheFile = path_1.default.join(rootFolder, '.sandstone', 'cache.json');
299
298
  if (cache === undefined) {
300
- cache = {};
299
+ let oldCache;
300
+ try {
301
+ const fileRead = await fs_extra_1.default.readFile(cacheFile, 'utf8');
302
+ if (fileRead) {
303
+ oldCache = JSON.parse(fileRead);
304
+ }
305
+ }
306
+ catch { }
307
+ if (oldCache) {
308
+ cache = oldCache;
309
+ }
310
+ else {
311
+ cache = {};
312
+ }
301
313
  }
302
314
  // Save the pack
303
315
  // Run the beforeSave script (TODO: This is where sandstone-server will remove restart env vars)
304
316
  await ((_c = scripts === null || scripts === void 0 ? void 0 : scripts.beforeSave) === null || _c === void 0 ? void 0 : _c.call(scripts));
317
+ const excludeOption = (_d = saveOptions.resources) === null || _d === void 0 ? void 0 : _d.exclude;
318
+ const fileExclusions = excludeOption ? {
319
+ generated: (excludeOption.generated || excludeOption),
320
+ existing: (excludeOption.existing || excludeOption)
321
+ } : false;
322
+ const fileHandlers = ((_e = saveOptions.resources) === null || _e === void 0 ? void 0 : _e.handle) || false;
305
323
  const packTypes = await sandstonePack.save({
306
324
  // Additional parameters
307
- dryRun: cliOptions.dry,
325
+ dry: cliOptions.dry,
308
326
  verbose: cliOptions.verbose,
309
- fileHandler: (_d = saveOptions.customFileHandler) !== null && _d !== void 0 ? _d : (async ({ relativePath, content, contentSummary }) => {
310
- // We hash the relative path alongside the content to ensure unique hash.
311
- const hashValue = hash(contentSummary + relativePath);
312
- // Add to new cache.
313
- newCache[relativePath] = hashValue;
314
- if (cache[relativePath] === hashValue) {
315
- // Already in cache - skip
316
- return;
327
+ fileHandler: (_f = saveOptions.customFileHandler) !== null && _f !== void 0 ? _f : (async (relativePath, content) => {
328
+ let pathPass = true;
329
+ if (fileExclusions && fileExclusions.generated) {
330
+ for (const exclude of fileExclusions.generated) {
331
+ if (!Array.isArray(exclude)) {
332
+ pathPass = !exclude.test(relativePath);
333
+ }
334
+ }
335
+ }
336
+ if (fileHandlers) {
337
+ for (const handler of fileHandlers) {
338
+ if (handler.path.test(relativePath)) {
339
+ content = await handler.callback(content);
340
+ }
341
+ }
342
+ }
343
+ if (pathPass) {
344
+ // We hash the relative path alongside the content to ensure unique hash.
345
+ const hashValue = hash(content + relativePath);
346
+ // Add to new cache.
347
+ newCache[relativePath] = hashValue;
348
+ if (cache[relativePath] === hashValue) {
349
+ // Already in cache - skip
350
+ return;
351
+ }
352
+ // Not in cache: write to disk
353
+ const realPath = path_1.default.join(outputFolder, relativePath);
354
+ await mkDir(path_1.default.dirname(realPath));
355
+ return await fs_extra_1.default.writeFile(realPath, content);
317
356
  }
318
- // Not in cache: write to disk
319
- const realPath = path_1.default.join(rootFolder, relativePath);
320
- await mkDir(path_1.default.dirname(realPath));
321
- return await fs_extra_1.default.writeFile(realPath, content);
322
357
  })
323
358
  });
324
- async function archiveOutput(packType, outputPath) {
359
+ async function handleResources(packType) {
360
+ const working = path_1.default.join(rootFolder, 'resources', packType);
361
+ let exists = false;
362
+ try {
363
+ await fs_extra_1.default.access(working);
364
+ exists = true;
365
+ }
366
+ catch (e) { }
367
+ if (exists) {
368
+ for await (const file of (0, klaw_1.default)(path_1.default.join(rootFolder, 'resources', packType), { filter: (_path) => {
369
+ const relativePath = path_1.default.join(packType, _path.split(working)[1]);
370
+ let pathPass = true;
371
+ if (fileExclusions && fileExclusions.existing) {
372
+ for (const exclude of fileExclusions.existing) {
373
+ pathPass = Array.isArray(exclude) ? !exclude[0].test(relativePath) : !exclude.test(relativePath);
374
+ }
375
+ }
376
+ return pathPass;
377
+ } })) {
378
+ const relativePath = path_1.default.join(packType, file.path.split(working)[1]);
379
+ try {
380
+ let content = await fs_extra_1.default.readFile(file.path);
381
+ if (fileHandlers) {
382
+ for (const handler of fileHandlers) {
383
+ if (handler.path.test(relativePath)) {
384
+ content = await handler.callback(content);
385
+ }
386
+ }
387
+ }
388
+ // We hash the relative path alongside the content to ensure unique hash.
389
+ const hashValue = hash(content + relativePath);
390
+ // Add to new cache.
391
+ newCache[relativePath] = hashValue;
392
+ if (cache[relativePath] !== hashValue) {
393
+ // Not in cache: write to disk
394
+ const realPath = path_1.default.join(outputFolder, relativePath);
395
+ await mkDir(path_1.default.dirname(realPath));
396
+ await fs_extra_1.default.writeFile(realPath, content);
397
+ }
398
+ }
399
+ catch (e) { }
400
+ }
401
+ }
402
+ }
403
+ async function archiveOutput(packType) {
404
+ const outputPath = path_1.default.join(rootFolder, '.sandstone/output/archives', `${packName}_${packType.type}`);
325
405
  const archive = new adm_zip_1.default();
326
406
  await archive.addLocalFolderPromise(outputPath, {});
327
407
  await archive.writeZipPromise(`${outputPath}.zip`, { overwrite: true });
328
408
  }
329
409
  // TODO: implement linking to make the cache more useful when not archiving.
330
410
  if (!cliOptions.production) {
331
- for (const packType of packTypes) {
332
- const outputPath = path_1.default.join(rootFolder, '.sandstone/output/archives', `${packName}_${packType.type}`);
411
+ for await (const _packType of packTypes) {
412
+ const packType = _packType[1];
413
+ const outputPath = path_1.default.join(rootFolder, '.sandstone/output', packType.type);
333
414
  if (packType.handleOutput) {
334
415
  await packType.handleOutput('output', async (relativePath, encoding = 'utf8') => await fs_extra_1.default.readFile(path_1.default.join(outputPath, relativePath), encoding), async (relativePath, contents) => {
335
416
  if (contents === undefined) {
@@ -340,8 +421,9 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
340
421
  }
341
422
  });
342
423
  }
424
+ handleResources(packType.type);
343
425
  if (packType.archiveOutput) {
344
- archiveOutput(packType, outputPath);
426
+ archiveOutput(packType);
345
427
  }
346
428
  // Handle client
347
429
  if (!(server && packType.networkSides === 'server')) {
@@ -405,7 +487,7 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
405
487
  }
406
488
  }
407
489
  else {
408
- for (const packType of packTypes) {
490
+ for await (const packType of packTypes) {
409
491
  const outputPath = path_1.default.join(rootFolder, '.sandstone/output/archives', `${packName}_${packType.type}`);
410
492
  if (packType.handleOutput) {
411
493
  await packType.handleOutput('output', async (relativePath, encoding = 'utf8') => await fs_extra_1.default.readFile(path_1.default.join(outputPath, relativePath), encoding), async (relativePath, contents) => {
@@ -417,19 +499,25 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
417
499
  }
418
500
  });
419
501
  }
502
+ handleResources(packType.type);
420
503
  if (packType.archiveOutput) {
421
- archiveOutput(packType, outputPath);
504
+ archiveOutput(packType);
422
505
  }
423
506
  }
424
507
  }
425
508
  // Delete old files that aren't cached anymore
426
509
  const oldFilesNames = new Set(Object.keys(cache));
427
510
  Object.keys(newCache).forEach(name => oldFilesNames.delete(name));
428
- await Promise.allSettled([...oldFilesNames.values()].map(name => (0, util_1.promisify)(fs_extra_1.default.rm)(path_1.default.join(outputFolder, name))));
511
+ await Promise.allSettled([...oldFilesNames.values()].map(name => {
512
+ return (0, util_1.promisify)(fs_extra_1.default.rm)(path_1.default.join(outputFolder, name));
513
+ }));
514
+ await (0, delete_empty_1.default)(outputFolder);
429
515
  // Override old cache
430
516
  cache = newCache;
517
+ // Write the cache to disk
518
+ await fs_extra_1.default.writeFile(cacheFile, JSON.stringify(cache));
431
519
  // Run the afterAll script
432
- await ((_e = scripts === null || scripts === void 0 ? void 0 : scripts.afterAll) === null || _e === void 0 ? void 0 : _e.call(scripts));
520
+ await ((_g = scripts === null || scripts === void 0 ? void 0 : scripts.afterAll) === null || _g === void 0 ? void 0 : _g.call(scripts));
433
521
  }
434
522
  /**
435
523
  * Build the project. Will log errors and never throw any.
@@ -440,12 +528,12 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
440
528
  *
441
529
  * @param changedFiles The files that changed since the last build.
442
530
  */
443
- async function buildProject(options, folders, resourceTypes, changedFiles) {
531
+ async function buildProject(options, folders, changedFiles) {
444
532
  try {
445
- await _buildProject(options, folders, resourceTypes, changedFiles);
533
+ await _buildProject(options, folders, changedFiles);
446
534
  }
447
535
  catch (err) {
448
- logError(err);
536
+ console.log(err);
449
537
  }
450
538
  }
451
539
  exports.buildProject = buildProject;
@@ -454,6 +542,7 @@ function logError(err, file) {
454
542
  if (file) {
455
543
  console.error(' ' + chalk_1.default.bgRed.white('BuildError') + chalk_1.default.gray(':'), `While loading "${file}", the following error happened:\n`);
456
544
  }
545
+ debugger;
457
546
  console.error(pe.render(err));
458
547
  }
459
548
  }
@@ -18,7 +18,7 @@ class Build extends command_1.Command {
18
18
  transpileOnly: !flags.strictErrors,
19
19
  project: tsConfigPath,
20
20
  });
21
- (0, buildProject_1.buildProject)(flags, folders, utils_1.datapackResources);
21
+ (0, buildProject_1.buildProject)(flags, folders);
22
22
  }
23
23
  }
24
24
  exports.default = Build;
@@ -6,6 +6,8 @@ export default class Create extends Command {
6
6
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
7
7
  yarn: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
8
8
  npm: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
9
+ library: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
+ version: flags.IOptionFlag<string | undefined>;
9
11
  'pack-name': flags.IOptionFlag<string | undefined>;
10
12
  namespace: flags.IOptionFlag<string | undefined>;
11
13
  'save-root': import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
@@ -6,21 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const command_1 = require("@oclif/command");
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const child_process_1 = require("child_process");
9
- const fs_1 = __importDefault(require("fs"));
10
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
11
10
  const inquirer_1 = __importDefault(require("inquirer"));
12
11
  const path_1 = __importDefault(require("path"));
13
12
  const util_1 = __importDefault(require("util"));
14
- const package_template_json_1 = __importDefault(require("../package.template.json"));
15
13
  const utils_1 = require("../utils");
16
14
  const nanoid_1 = require("nanoid");
17
15
  function toJson(obj, pretty = false) {
18
16
  return util_1.default.inspect(obj, {
19
- depth: +Infinity,
17
+ depth: Number(Infinity),
20
18
  colors: false,
21
- breakLength: +Infinity,
19
+ breakLength: Number(Infinity),
22
20
  compact: !pretty,
23
- maxArrayLength: +Infinity,
21
+ maxArrayLength: Number(Infinity),
24
22
  });
25
23
  }
26
24
  class Create extends command_1.Command {
@@ -28,70 +26,94 @@ class Create extends command_1.Command {
28
26
  const { args, flags } = this.parse(Create);
29
27
  const projectPath = path_1.default.resolve(args['project-name']);
30
28
  const projectName = path_1.default.basename(projectPath);
31
- const packName = await (0, utils_1.getFlagOrPrompt)(flags, 'pack-name', {
32
- message: 'Name of your data pack (can be changed later) >',
29
+ const projectType = Boolean(await (0, utils_1.getFlagOrPrompt)(flags, 'library', {
30
+ message: 'Whether your project will be a library for use in other Sandstone projects >',
33
31
  type: 'input',
34
- default: projectName,
32
+ default: false,
33
+ })) === true ? 'library' : 'pack';
34
+ const versions = [['0.13.6', '0.5.4'], ['0.14.0-alpha.13', '0.5.4'], ['0.14.0-alpha.19', '0.6.2']];
35
+ const stableIndex = 0;
36
+ const { sandstoneVersion } = await inquirer_1.default.prompt({
37
+ name: 'sandstoneVersion',
38
+ type: 'list',
39
+ message: 'Which version of Sandstone do you want to use? These are the only supported versions for new projects.',
40
+ choices: versions.map((version) => ({
41
+ name: version[0].includes('alpha') ? `Alpha Version ${version[0].split('.')[3]} for release ${version[0].split('.')[1]}` : `Major Version 0.${version[0].split('.')[1]}`,
42
+ value: version,
43
+ short: version[0],
44
+ })),
45
+ default: stableIndex,
35
46
  });
47
+ let packName = '';
48
+ let namespace = '';
49
+ if (projectType === 'pack') {
50
+ packName = await (0, utils_1.getFlagOrPrompt)(flags, 'pack-name', {
51
+ message: 'Name of your output pack(s) (can be changed later) >',
52
+ type: 'input',
53
+ default: projectName,
54
+ });
55
+ namespace = await (0, utils_1.getFlagOrPrompt)(flags, 'namespace', {
56
+ message: 'Default namespace (can be changed later) >',
57
+ default: 'default',
58
+ });
59
+ }
36
60
  // Find the save directory
37
61
  const saveOptions = {};
38
- if (flags['save-root']) {
39
- saveOptions.root = true;
40
- }
41
- else if (flags.world) {
42
- saveOptions.world = flags.world;
43
- }
44
- else if (flags['server-path']) {
45
- saveOptions.serverPath = flags['server-path'];
46
- }
47
- else { // TODO: Add support for ssh
48
- // User didn't specify a way to save the file. Ask them.
49
- const { saveChoice } = await inquirer_1.default.prompt({
50
- name: 'saveChoice',
51
- type: 'list',
52
- message: 'Where do you want your packs to be saved (can be changed later)?',
53
- choices: [{
54
- name: 'In the root client (.minecraft) folder',
55
- value: 'root',
56
- short: 'Client folder',
57
- }, {
58
- name: 'In a world',
59
- value: 'world',
60
- short: 'World',
61
- }, {
62
- name: 'In a server',
63
- value: 'server-path',
64
- short: 'Server path',
65
- }],
66
- });
67
- if (saveChoice === 'root') {
62
+ if (sandstoneVersion[0].includes('alpha') && Number(sandstoneVersion[0].split('.')[3]) >= 19) {
63
+ if (flags['save-root']) {
68
64
  saveOptions.root = true;
69
65
  }
70
- else if (saveChoice === 'world') {
71
- const { world } = await inquirer_1.default.prompt({
72
- name: 'World',
73
- message: 'What world do you want to save the packs in? >',
66
+ else if (flags.world) {
67
+ saveOptions.world = flags.world;
68
+ }
69
+ else if (flags['server-path']) {
70
+ saveOptions.serverPath = flags['server-path'];
71
+ }
72
+ else { // TODO: Add support for ssh
73
+ // User didn't specify a way to save the file. Ask them.
74
+ const { saveChoice } = await inquirer_1.default.prompt({
75
+ name: 'saveChoice',
74
76
  type: 'list',
75
- choices: utils_1.getWorldsList,
77
+ message: 'Where do you want your pack(s) to be saved (can be changed later)?',
78
+ choices: [{
79
+ name: 'In the root client (.minecraft) folder',
80
+ value: 'root',
81
+ short: 'Client folder',
82
+ }, {
83
+ name: 'In a world',
84
+ value: 'world',
85
+ short: 'World',
86
+ }, {
87
+ name: 'In a server',
88
+ value: 'server-path',
89
+ short: 'Server path',
90
+ }],
76
91
  });
77
- saveOptions.world = world;
92
+ if (saveChoice === 'root') {
93
+ saveOptions.root = true;
94
+ }
95
+ else if (saveChoice === 'world') {
96
+ const { world } = await inquirer_1.default.prompt({
97
+ name: 'World',
98
+ message: 'What world do you want to save the packs in? >',
99
+ type: 'list',
100
+ choices: utils_1.getWorldsList,
101
+ });
102
+ saveOptions.world = world;
103
+ }
104
+ else { // TODO: Add native folder selector
105
+ const { serverPath } = await inquirer_1.default.prompt({
106
+ name: 'Server path',
107
+ message: 'Where is the server to save the packs in? Relative paths are accepted. >',
108
+ type: 'input',
109
+ });
110
+ saveOptions.serverPath = serverPath;
111
+ }
78
112
  }
79
- else { // TODO: Add native folder selector
80
- const { serverPath } = await inquirer_1.default.prompt({
81
- name: 'Server path',
82
- message: 'Where is the server to save the packs in? Relative paths are accepted. >',
83
- type: 'input',
84
- });
85
- saveOptions.serverPath = serverPath;
113
+ if (flags['client-path']) {
114
+ saveOptions.clientPath = flags['client-path'];
86
115
  }
87
116
  }
88
- if (flags['client-path']) {
89
- saveOptions.clientPath = flags['client-path'];
90
- }
91
- const namespace = await (0, utils_1.getFlagOrPrompt)(flags, 'namespace', {
92
- message: 'Default namespace (can be changed later) >',
93
- default: 'default',
94
- });
95
117
  let useYarn = flags.yarn;
96
118
  if (!flags.yarn && !flags.npm && (0, utils_1.hasYarn)()) {
97
119
  useYarn = (await inquirer_1.default.prompt({
@@ -101,57 +123,39 @@ class Create extends command_1.Command {
101
123
  choices: ['npm', 'yarn'],
102
124
  })).useYarn === 'yarn';
103
125
  }
104
- fs_1.default.mkdirSync(projectPath);
126
+ fs_extra_1.default.mkdirSync(projectPath);
105
127
  // Create project & install dependencies
106
- this.log((0, chalk_1.default) `Installing {rgb(229,193,0) sandstone}, {rgb(229,193,0) sandstone-cli} and {cyan typescript} using {cyan ${useYarn ? 'yarn' : 'npm'}}.`);
107
- if (useYarn) {
108
- /** Init the package, skipping the interactive prompt */
109
- (0, child_process_1.execSync)('yarn init --yes', { cwd: projectPath });
110
- /** Install dependencies */
111
- (0, child_process_1.execSync)('yarn add sandstone', { cwd: projectPath });
112
- (0, child_process_1.execSync)('yarn add --dev typescript @types/node sandstone-cli', { cwd: projectPath });
128
+ this.log((0, chalk_1.default) `Installing {rgb(229,193,0) sandstone@${sandstoneVersion[0]}}, {rgb(229,193,0) sandstone-cli@${sandstoneVersion[1]}} and {cyan typescript} using {cyan ${useYarn ? 'yarn' : 'npm'}}.`);
129
+ const exec = (cmd) => (0, child_process_1.execSync)(cmd, { cwd: projectPath });
130
+ exec('git clone https://github.com/sandstone-mc/sandstone-template.git .');
131
+ exec(`git checkout ${projectType}-${sandstoneVersion[0]}`);
132
+ exec('rm -rf .git');
133
+ exec(`${useYarn ? 'yarn' : 'npm'} install`);
134
+ // TODO: Make profiles for either packs or libraries
135
+ const configPath = path_1.default.join(projectPath, `${projectType === 'library' ? 'test/' : ''}sandstone.config.ts`);
136
+ // Merge with the config values
137
+ let templateConfig = await fs_extra_1.default.readFile(configPath, 'utf8');
138
+ templateConfig = templateConfig.replace('packUid: \'kZZpDK67\'', `packUid: '${toJson((0, nanoid_1.nanoid)(8))}'`);
139
+ let _name = packName;
140
+ let _namespace = namespace;
141
+ if (projectType === 'library') {
142
+ _name += '-testing';
143
+ _namespace += '_test';
113
144
  }
114
- else {
115
- /** Init the package, skipping the interactive prompt */
116
- (0, child_process_1.execSync)('npm init --yes', { cwd: projectPath });
117
- /** Install dependencies */
118
- (0, child_process_1.execSync)('npm install sandstone', { cwd: projectPath });
119
- (0, child_process_1.execSync)('npm install --save-dev typescript @types/node sandstone-cli', { cwd: projectPath });
145
+ templateConfig = templateConfig.replace('name: \'template\'', `name: ${toJson(_name)}`);
146
+ templateConfig = templateConfig.replace('namespace: \'default\'', `namespace: ${toJson(_namespace)}`);
147
+ // TODO: packFormat
148
+ const opts = toJson(Object.fromEntries(Object.entries(saveOptions).filter(([_, value]) => value !== undefined)));
149
+ if (opts !== '{}') {
150
+ templateConfig = templateConfig.replace('saveOptions: {}', `saveOptions: ${opts}`);
120
151
  }
121
- // TODO: Make profiles for either packs or libraries
122
- // Merge with the package.json template
123
- const generatedPackage = JSON.parse(fs_1.default.readFileSync(path_1.default.join(projectPath, 'package.json')).toString());
124
- /** Remove the `main` property */
125
- const { main: _, ...newPackage } = { ...generatedPackage, ...package_template_json_1.default };
126
- // Rewrite package.json
127
- fs_1.default.writeFileSync(path_1.default.join(projectPath, 'package.json'), JSON.stringify(newPackage, null, 2));
128
- // Add files from template
129
- const templateFolder = path_1.default.join(__dirname, '../template/');
130
- await fs_extra_1.default.copy(templateFolder, projectPath);
131
- // Write the sandstone.json file
132
- fs_1.default.writeFileSync(path_1.default.join(projectPath, 'sandstone.config.ts'), `import type { SandstoneConfig } from 'sandstone'
133
-
134
- export default {
135
- name: ${toJson(packName)},
136
- packs: {
137
- datapack: {
138
- description: ${toJson(['A ', { text: 'Sandstone', color: 'gold' }, ' data pack.'])},
139
- packFormat: ${11},
140
- }
141
- },
142
- namespace: ${toJson(namespace)},
143
- packUid: ${toJson((0, nanoid_1.nanoid)(8))},
144
- saveOptions: ${toJson(Object.fromEntries(Object.entries(saveOptions).filter(([_, value]) => value !== undefined)))},
145
- onConflict: {
146
- default: 'warn',
147
- },
148
- } as SandstoneConfig
149
- `);
152
+ // Rewrite config
153
+ fs_extra_1.default.writeFileSync(configPath, templateConfig);
150
154
  const prefix = useYarn ? 'yarn' : 'npm run';
151
155
  this.log((0, chalk_1.default) `{green Success!} Created "${projectName}" at "${projectPath}"`);
152
156
  this.log('Inside that directory, you can run several commands:\n');
153
- this.log((0, chalk_1.default) ` {cyan ${prefix} build}:\n Builds the data pack. {cyan ⛏}\n`);
154
- this.log((0, chalk_1.default) ` {cyan ${prefix} watch}:\n Builds the data pack, and rebuild on each file change. {cyan ⛏}\n`);
157
+ this.log((0, chalk_1.default) ` {cyan ${prefix} build}:\n Builds the packs. {cyan ⛏}\n`);
158
+ this.log((0, chalk_1.default) ` {cyan ${prefix} watch}:\n Builds the packs, and rebuilds on each file change. {cyan ⛏}\n`);
155
159
  this.log('We suggest that you begin by typing:\n');
156
160
  this.log((0, chalk_1.default) ` {cyan cd} ${projectName}\n {cyan ${prefix} watch}`);
157
161
  }
@@ -165,7 +169,9 @@ Create.flags = {
165
169
  help: command_1.flags.help({ char: 'h' }),
166
170
  yarn: command_1.flags.boolean({ description: 'Use yarn instead of npm.', env: 'USE_YARN', exclusive: ['npm'] }),
167
171
  npm: command_1.flags.boolean({ description: 'Use npm.', env: 'USE_NPM', exclusive: ['yarn'] }),
168
- 'pack-name': command_1.flags.string({ char: 'd', env: 'PACK_NAME', description: 'The name of the data pack.' }),
172
+ library: command_1.flags.boolean({ char: 't', env: 'LIBRARY', description: 'Whether the project will be a library for use in other Sandstone projects.' }),
173
+ version: command_1.flags.string({ char: 'v', env: 'SANDSTONE_VERSION', description: 'What version of Sandstone you\'d like to create a project for.' }),
174
+ 'pack-name': command_1.flags.string({ char: 'd', env: 'PACK_NAME', description: 'The name of the pack(s).' }),
169
175
  namespace: command_1.flags.string({ char: 'n', env: 'NAMESPACE', description: 'The default namespace that will be used.' }),
170
176
  'save-root': command_1.flags.boolean({ char: 'r', env: 'SAVE_ROOT', description: 'Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Not compatible with --world.', exclusive: ['world'] }),
171
177
  world: command_1.flags.string({ char: 'w', env: 'WORLD', description: 'The world to save the packs in. Not compatible with --save-root or --server', exclusive: ['save-root', 'server'] }),
@@ -174,6 +180,6 @@ Create.flags = {
174
180
  };
175
181
  Create.args = [{
176
182
  name: 'project-name',
177
- description: 'Name of the project folder. This is not the name of the data pack.',
183
+ description: 'Name of the project folder. This is not the name of the output pack(s).',
178
184
  required: true,
179
185
  }];
@@ -37,7 +37,7 @@ class Watch extends command_1.Command {
37
37
  return;
38
38
  }
39
39
  alreadyBuilding = true;
40
- await (0, buildProject_1.buildProject)(flags, folders, utils_1.datapackResources, paths);
40
+ await (0, buildProject_1.buildProject)(flags, folders, paths);
41
41
  client === null || client === void 0 ? void 0 : client.write('chat', { message: '/reload' });
42
42
  alreadyBuilding = false;
43
43
  if (needRebuild) {
package/lib/utils.d.ts CHANGED
@@ -28,4 +28,3 @@ export declare type ProjectFolders = {
28
28
  sandstoneConfigFolder: string;
29
29
  };
30
30
  export declare function getProjectFolders(projectFolder: string): ProjectFolders;
31
- export declare const datapackResources: string[];
package/lib/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.datapackResources = exports.getProjectFolders = exports.getFileFolder = exports.getWorldPath = exports.getWorldsList = exports.getMinecraftPath = exports.hasYarn = exports.getFlagOrPrompt = void 0;
6
+ exports.getProjectFolders = exports.getFileFolder = exports.getWorldPath = exports.getWorldsList = exports.getMinecraftPath = exports.hasYarn = exports.getFlagOrPrompt = void 0;
7
7
  const inquirer_1 = __importDefault(require("inquirer"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const os_1 = __importDefault(require("os"));
@@ -119,4 +119,3 @@ function getProjectFolders(projectFolder) {
119
119
  };
120
120
  }
121
121
  exports.getProjectFolders = getProjectFolders;
122
- exports.datapackResources = ['mcfunction', 'advancement', 'item_modifier', 'loot_table', 'predicate', 'recipe', 'tag', 'trim_material', 'trim_pattern'];
@@ -1 +1 @@
1
- {"version":"0.6.1","commands":{"build":{"id":"build","description":"Build the packs. ⛏","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand build","$ sand build --verbose","$ sand build --verbose --dry"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"dry":{"name":"dry","type":"boolean","char":"d","description":"Do not save the pack. Mostly useful with `verbose`.","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Log all resulting resources: functions, advancements...","allowNo":false},"namespace":{"name":"namespace","type":"option","description":"The default namespace. Override the value specified in the configuration file."},"world":{"name":"world","type":"option","description":"The world to save the data pack in. Override the value specified in the configuration file."},"root":{"name":"root","type":"boolean","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.","allowNo":false},"clientPath":{"name":"clientPath","type":"option","description":"Path of the client folder. Override the value specified in the configuration file."},"serverPath":{"name":"serverPath","type":"option","description":"Path of the server folder. Override the value specified in the configuration file."},"name":{"name":"name","type":"option","description":"Name of the data pack. Override the value specified in the configuration file."},"description":{"name":"description","type":"option","description":"Description of the data pack. Override the value specified in the configuration file."},"formatVersion":{"name":"formatVersion","type":"option","description":"Pack format version. Override the value specified in the configuration file."},"fullTrace":{"name":"fullTrace","type":"boolean","description":"Show the full stack trace on errors.","allowNo":false},"strictErrors":{"name":"strictErrors","type":"boolean","description":"Stop data pack compilation on type errors.","allowNo":false},"production":{"name":"production","type":"boolean","char":"p","description":"Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to \"production\".","allowNo":false},"autoReload":{"name":"autoReload","type":"option","description":"Automatically reload your data pack in-game. Requires to open the world to LAN with cheats enabled, and to specify the port.","helpValue":"port"}},"args":[{"name":"path","description":"Path of the folder containing source files.","required":true,"default":"./src"},{"name":"config-path","description":"Path of the sandstone.config.ts folder.","required":true,"default":"."}]},"create":{"id":"create","description":"Create a new Sandstone project.","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand create my-pack"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yarn":{"name":"yarn","type":"boolean","description":"Use yarn instead of npm.","allowNo":false},"npm":{"name":"npm","type":"boolean","description":"Use npm.","allowNo":false},"pack-name":{"name":"pack-name","type":"option","char":"d","description":"The name of the data pack."},"namespace":{"name":"namespace","type":"option","char":"n","description":"The default namespace that will be used."},"save-root":{"name":"save-root","type":"boolean","char":"r","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Not compatible with --world.","allowNo":false},"world":{"name":"world","type":"option","char":"w","description":"The world to save the packs in. Not compatible with --save-root or --server"},"server-path":{"name":"server-path","type":"option","char":"s","description":"The server path to write the server-side packs at. Not compatible with --world."},"client-path":{"name":"client-path","type":"option","char":"c","description":"The client path to write packs at."}},"args":[{"name":"project-name","description":"Name of the project folder. This is not the name of the data pack.","required":true}]},"update":{"id":"update","description":"Update Sandstone & Sandstone-CLI.","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand update","$ sand update --cli","$ sand update --sandstone","$ sand update --cli --sandstone --skip"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"cli":{"name":"cli","type":"boolean","description":"Update the Sandstone CLI without asking.","allowNo":false},"sandstone":{"name":"sandstone","type":"boolean","description":"Update the current Sandstone version without asking.","allowNo":false},"skip":{"name":"skip","type":"boolean","description":"Skip all interactive prompts and refuse them.","allowNo":false},"yarn":{"name":"yarn","type":"boolean","description":"Use yarn to install the updates.","allowNo":false},"npm":{"name":"npm","type":"boolean","description":"Use npm to install the updates.","allowNo":false}},"args":[]},"watch":{"id":"watch","description":"Build the packs, and rebuild them on file change. ⛏","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand watch","$ sand watch --verbose","$ sand watch --verbose --dry"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"dry":{"name":"dry","type":"boolean","char":"d","description":"Do not save the pack. Mostly useful with `verbose`.","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Log all resulting resources: functions, advancements...","allowNo":false},"namespace":{"name":"namespace","type":"option","description":"The default namespace. Override the value specified in the configuration file."},"world":{"name":"world","type":"option","description":"The world to save the data pack in. Override the value specified in the configuration file."},"root":{"name":"root","type":"boolean","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.","allowNo":false},"clientPath":{"name":"clientPath","type":"option","description":"Path of the client folder. Override the value specified in the configuration file."},"serverPath":{"name":"serverPath","type":"option","description":"Path of the server folder. Override the value specified in the configuration file."},"name":{"name":"name","type":"option","description":"Name of the data pack. Override the value specified in the configuration file."},"description":{"name":"description","type":"option","description":"Description of the data pack. Override the value specified in the configuration file."},"formatVersion":{"name":"formatVersion","type":"option","description":"Pack format version. Override the value specified in the configuration file."},"fullTrace":{"name":"fullTrace","type":"boolean","description":"Show the full stack trace on errors.","allowNo":false},"strictErrors":{"name":"strictErrors","type":"boolean","description":"Stop data pack compilation on type errors.","allowNo":false},"production":{"name":"production","type":"boolean","char":"p","description":"Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to \"production\".","allowNo":false},"autoReload":{"name":"autoReload","type":"option","description":"Automatically reload your data pack in-game. Requires to open the world to LAN with cheats enabled, and to specify the port.","helpValue":"port"}},"args":[{"name":"path","description":"Path of the folder containing source files.","required":true,"default":"./src"},{"name":"config-path","description":"Path of the sandstone.config.ts folder.","required":true,"default":"."}]}}}
1
+ {"version":"0.6.3","commands":{"build":{"id":"build","description":"Build the packs. ⛏","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand build","$ sand build --verbose","$ sand build --verbose --dry"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"dry":{"name":"dry","type":"boolean","char":"d","description":"Do not save the pack. Mostly useful with `verbose`.","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Log all resulting resources: functions, advancements...","allowNo":false},"namespace":{"name":"namespace","type":"option","description":"The default namespace. Override the value specified in the configuration file."},"world":{"name":"world","type":"option","description":"The world to save the data pack in. Override the value specified in the configuration file."},"root":{"name":"root","type":"boolean","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.","allowNo":false},"clientPath":{"name":"clientPath","type":"option","description":"Path of the client folder. Override the value specified in the configuration file."},"serverPath":{"name":"serverPath","type":"option","description":"Path of the server folder. Override the value specified in the configuration file."},"name":{"name":"name","type":"option","description":"Name of the data pack. Override the value specified in the configuration file."},"description":{"name":"description","type":"option","description":"Description of the data pack. Override the value specified in the configuration file."},"formatVersion":{"name":"formatVersion","type":"option","description":"Pack format version. Override the value specified in the configuration file."},"fullTrace":{"name":"fullTrace","type":"boolean","description":"Show the full stack trace on errors.","allowNo":false},"strictErrors":{"name":"strictErrors","type":"boolean","description":"Stop data pack compilation on type errors.","allowNo":false},"production":{"name":"production","type":"boolean","char":"p","description":"Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to \"production\".","allowNo":false},"autoReload":{"name":"autoReload","type":"option","description":"Automatically reload your data pack in-game. Requires to open the world to LAN with cheats enabled, and to specify the port.","helpValue":"port"}},"args":[{"name":"path","description":"Path of the folder containing source files.","required":true,"default":"./src"},{"name":"config-path","description":"Path of the sandstone.config.ts folder.","required":true,"default":"."}]},"create":{"id":"create","description":"Create a new Sandstone project.","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand create my-pack"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"yarn":{"name":"yarn","type":"boolean","description":"Use yarn instead of npm.","allowNo":false},"npm":{"name":"npm","type":"boolean","description":"Use npm.","allowNo":false},"library":{"name":"library","type":"boolean","char":"t","description":"Whether the project will be a library for use in other Sandstone projects.","allowNo":false},"version":{"name":"version","type":"option","char":"v","description":"What version of Sandstone you'd like to create a project for."},"pack-name":{"name":"pack-name","type":"option","char":"d","description":"The name of the pack(s)."},"namespace":{"name":"namespace","type":"option","char":"n","description":"The default namespace that will be used."},"save-root":{"name":"save-root","type":"boolean","char":"r","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Not compatible with --world.","allowNo":false},"world":{"name":"world","type":"option","char":"w","description":"The world to save the packs in. Not compatible with --save-root or --server"},"server-path":{"name":"server-path","type":"option","char":"s","description":"The server path to write the server-side packs at. Not compatible with --world."},"client-path":{"name":"client-path","type":"option","char":"c","description":"The client path to write packs at."}},"args":[{"name":"project-name","description":"Name of the project folder. This is not the name of the output pack(s).","required":true}]},"update":{"id":"update","description":"Update Sandstone & Sandstone-CLI.","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand update","$ sand update --cli","$ sand update --sandstone","$ sand update --cli --sandstone --skip"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"cli":{"name":"cli","type":"boolean","description":"Update the Sandstone CLI without asking.","allowNo":false},"sandstone":{"name":"sandstone","type":"boolean","description":"Update the current Sandstone version without asking.","allowNo":false},"skip":{"name":"skip","type":"boolean","description":"Skip all interactive prompts and refuse them.","allowNo":false},"yarn":{"name":"yarn","type":"boolean","description":"Use yarn to install the updates.","allowNo":false},"npm":{"name":"npm","type":"boolean","description":"Use npm to install the updates.","allowNo":false}},"args":[]},"watch":{"id":"watch","description":"Build the packs, and rebuild them on file change. ⛏","pluginName":"sandstone-cli","pluginType":"core","aliases":[],"examples":["$ sand watch","$ sand watch --verbose","$ sand watch --verbose --dry"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"dry":{"name":"dry","type":"boolean","char":"d","description":"Do not save the pack. Mostly useful with `verbose`.","allowNo":false},"verbose":{"name":"verbose","type":"boolean","char":"v","description":"Log all resulting resources: functions, advancements...","allowNo":false},"namespace":{"name":"namespace","type":"option","description":"The default namespace. Override the value specified in the configuration file."},"world":{"name":"world","type":"option","description":"The world to save the data pack in. Override the value specified in the configuration file."},"root":{"name":"root","type":"boolean","description":"Save the data pack & resource pack in the .minecraft/datapacks & .minecraft/resource_packs folders. Override the value specified in the configuration file.","allowNo":false},"clientPath":{"name":"clientPath","type":"option","description":"Path of the client folder. Override the value specified in the configuration file."},"serverPath":{"name":"serverPath","type":"option","description":"Path of the server folder. Override the value specified in the configuration file."},"name":{"name":"name","type":"option","description":"Name of the data pack. Override the value specified in the configuration file."},"description":{"name":"description","type":"option","description":"Description of the data pack. Override the value specified in the configuration file."},"formatVersion":{"name":"formatVersion","type":"option","description":"Pack format version. Override the value specified in the configuration file."},"fullTrace":{"name":"fullTrace","type":"boolean","description":"Show the full stack trace on errors.","allowNo":false},"strictErrors":{"name":"strictErrors","type":"boolean","description":"Stop data pack compilation on type errors.","allowNo":false},"production":{"name":"production","type":"boolean","char":"p","description":"Runs Sandstone in production mode. This sets process.env.SANDSTONE_ENV to \"production\".","allowNo":false},"autoReload":{"name":"autoReload","type":"option","description":"Automatically reload your data pack in-game. Requires to open the world to LAN with cheats enabled, and to specify the port.","helpValue":"port"}},"args":[{"name":"path","description":"Path of the folder containing source files.","required":true,"default":"./src"},{"name":"config-path","description":"Path of the sandstone.config.ts folder.","required":true,"default":"."}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sandstone-cli",
3
3
  "description": "The CLI for Sandstone - the data pack creation library.",
4
- "version": "0.6.1",
4
+ "version": "0.6.3",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "TheMrZZ - Florian ERNST",
@@ -23,11 +23,13 @@
23
23
  "@oclif/plugin-help": "^3",
24
24
  "@oclif/plugin-warn-if-update-available": "^1.7.0",
25
25
  "@types/adm-zip": "^0.5.0",
26
- "@types/node": "^18.11.18",
26
+ "@types/delete-empty": "^3.0.2",
27
+ "@types/node": "^18.14.2",
27
28
  "@types/semver": "^7.3.4",
28
29
  "adm-zip": "^0.5.10",
29
30
  "chalk": "^4.1.0",
30
31
  "chokidar": "^3.4.3",
32
+ "delete-empty": "^3.0.0",
31
33
  "fs-extra": "^9.0.1",
32
34
  "inquirer": "^7.3.3",
33
35
  "klaw": "^3.0.0",
@@ -94,7 +96,7 @@
94
96
  "postpack": "rimraf oclif.manifest.json",
95
97
  "posttest": "eslint . --ext .ts --config .eslintrc",
96
98
  "prepack": "npm run build",
97
- "build": "rimraf lib && tsc -b && node ./copyTemplate.js && oclif-dev manifest && oclif-dev readme",
99
+ "build": "rimraf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
98
100
  "watch": "npm run build && chokidar \"src/**/*\" -c \"npm run build\"",
99
101
  "test": "echo NO TESTS",
100
102
  "version": "oclif-dev readme && git add README.md"
@@ -1,10 +0,0 @@
1
- {
2
- "description": "A data pack created with Sandstone",
3
- "engines": {
4
- "node": ">=12.9.0"
5
- },
6
- "scripts": {
7
- "watch": "sand watch",
8
- "build": "sand build"
9
- }
10
- }
@@ -1,20 +0,0 @@
1
- # Sandstone project
2
-
3
- To build the packs, run:
4
- ```ts
5
- npm run build
6
- // or
7
- yarn build
8
- // or
9
- sand build
10
- ```
11
-
12
- To automatically rebuild the packs on each change, run:
13
- ```ts
14
- npm run watch
15
- // or
16
- yarn watch
17
- // or
18
- sand watch
19
- ```
20
-
@@ -1,18 +0,0 @@
1
- /**
2
- * This file is just an example.
3
- * You can delete it!
4
- */
5
-
6
- import { MCFunction, tellraw } from 'sandstone'
7
-
8
- MCFunction('display_message', () => {
9
- tellraw('@a', [
10
- '\n========= Congratulations! =========\n\n',
11
- { text: ' Sandstone', color: 'gold', bold: true }, ' is ', { text: 'successfully installed.\n\n', color: 'green' },
12
- ' Add files to the ', { text: 'src', underlined: true }, ' folder\n',
13
- ' and start creating your data pack!\n',
14
- '==============', { text: '🏹', color: '#D2691E' }, { text: '⚔', color: '#45ACA5' }, { text: '⛏', color: '#FFD700' }, '==============',
15
- ])
16
- }, {
17
- runOnLoad: true,
18
- })
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "module": "commonjs",
5
- "moduleResolution": "node",
6
- // We target a minimum Node version of 12.9.0: https://stackoverflow.com/a/59787575
7
- "target": "es2019",
8
- "lib": [
9
- "es2020"
10
- ],
11
- "strict": false,
12
- "esModuleInterop": false,
13
- "resolveJsonModule": true,
14
- "allowSyntheticDefaultImports": false,
15
- "noEmit": true,
16
- "skipLibCheck": true,
17
- "outDir": "build"
18
- },
19
- "include": [
20
- "src"
21
- ],
22
- }