sandstone-cli 1.1.5 → 1.1.7
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 +1 -1
- package/lib/commands/create.js +1 -1
- package/lib/utils.d.ts +5 -11
- package/lib/utils.js +27 -48
- package/package.json +2 -2
- package/src/commands/create.ts +1 -1
- package/src/utils.ts +37 -63
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The CLI for Sandstone - the datapack creation library.
|
|
|
5
5
|
|
|
6
6
|
[](https://npmjs.org/package/sandstone-cli)
|
|
7
7
|
[](https://npmjs.org/package/sandstone-cli)
|
|
8
|
-
[](https://github.com/
|
|
8
|
+
[](https://github.com/sandstone-mc/sandstone-cli/blob/master/package.json)
|
|
9
9
|
|
|
10
10
|
<!-- toc -->
|
|
11
11
|
* [Usage](#usage)
|
package/lib/commands/create.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function createCommand(_project, opts) {
|
|
|
26
26
|
default: false,
|
|
27
27
|
})).projectType) === true ? 'library' : 'pack';
|
|
28
28
|
const sv = (v) => new SemVer(v);
|
|
29
|
-
const versions = [[sv('0.13.6'), sv('0.5.4')], [sv('0.14.0-alpha.13'), sv('0.5.4')], [sv('1.0.0-alpha.
|
|
29
|
+
const versions = [[sv('0.13.6'), sv('0.5.4')], [sv('0.14.0-alpha.13'), sv('0.5.4')], [sv('1.0.0-alpha.5'), sv('1.1.6')]];
|
|
30
30
|
const stableIndex = 0;
|
|
31
31
|
const { version } = await inquirer.prompt({
|
|
32
32
|
name: 'version',
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
export declare function hasYarn(): boolean;
|
|
2
2
|
export declare function hasPnpm(): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* Get the .minecraft path
|
|
5
|
-
*/
|
|
6
|
-
export declare function getMinecraftPath(): string;
|
|
7
|
-
export declare function getWorldsList(): string[];
|
|
8
|
-
/**
|
|
9
|
-
* @param worldName The name of the world
|
|
10
|
-
* @param minecraftPath The optional location of the .minecraft folder.
|
|
11
|
-
* If left unspecified, the .minecraft will be found automatically.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getWorldPath(worldName: string, minecraftPath?: string | undefined): string;
|
|
14
3
|
/**
|
|
15
4
|
* Recursively search for a file.
|
|
16
5
|
* Starts in the current folder, and go to the parent, recursively.
|
|
@@ -29,3 +18,8 @@ export type ProjectFolders = {
|
|
|
29
18
|
};
|
|
30
19
|
export declare function getProjectFolders(projectFolder: string): ProjectFolders;
|
|
31
20
|
export declare const capitalize: (s: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Get the .minecraft path
|
|
23
|
+
*/
|
|
24
|
+
export declare function getMinecraftPath(): string;
|
|
25
|
+
export declare function getWorldsList(): string[];
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import os from 'os';
|
|
3
2
|
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
import chalk from 'chalk-template';
|
|
6
6
|
export function hasYarn() {
|
|
@@ -21,53 +21,6 @@ export function hasPnpm() {
|
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Get the .minecraft path
|
|
26
|
-
*/
|
|
27
|
-
export function getMinecraftPath() {
|
|
28
|
-
function getMCPath() {
|
|
29
|
-
switch (os.platform()) {
|
|
30
|
-
case 'win32':
|
|
31
|
-
return path.join(os.homedir(), 'AppData/Roaming/.minecraft');
|
|
32
|
-
case 'darwin':
|
|
33
|
-
return path.join(os.homedir(), 'Library/Application Support/minecraft');
|
|
34
|
-
case 'linux':
|
|
35
|
-
default:
|
|
36
|
-
return path.join(os.homedir(), '.minecraft');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const mcPath = getMCPath();
|
|
40
|
-
if (!fs.existsSync(mcPath)) {
|
|
41
|
-
throw new Error('Unable to locate the .minecraft folder. Please specify it manually.');
|
|
42
|
-
}
|
|
43
|
-
return mcPath;
|
|
44
|
-
}
|
|
45
|
-
export function getWorldsList() {
|
|
46
|
-
const mcPath = getMinecraftPath();
|
|
47
|
-
const savesPath = path.join(mcPath, 'saves');
|
|
48
|
-
return fs.readdirSync(savesPath, { withFileTypes: true }).filter((f) => f.isDirectory).map((f) => f.name);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @param worldName The name of the world
|
|
52
|
-
* @param minecraftPath The optional location of the .minecraft folder.
|
|
53
|
-
* If left unspecified, the .minecraft will be found automatically.
|
|
54
|
-
*/
|
|
55
|
-
export function getWorldPath(worldName, minecraftPath = undefined) {
|
|
56
|
-
let mcPath;
|
|
57
|
-
if (minecraftPath) {
|
|
58
|
-
mcPath = minecraftPath;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
mcPath = getMinecraftPath();
|
|
62
|
-
}
|
|
63
|
-
const savesPath = path.join(mcPath, 'saves');
|
|
64
|
-
const worldPath = path.join(savesPath, worldName);
|
|
65
|
-
if (!fs.existsSync(worldPath)) {
|
|
66
|
-
const existingWorlds = fs.readdirSync(savesPath, { withFileTypes: true }).filter((f) => f.isDirectory).map((f) => f.name);
|
|
67
|
-
throw new Error(`Unable to locate the "${worldPath}" folder. Word ${worldName} does not exists. List of existing worlds: ${JSON.stringify(existingWorlds, null, 2)}`);
|
|
68
|
-
}
|
|
69
|
-
return worldPath;
|
|
70
|
-
}
|
|
71
24
|
/**
|
|
72
25
|
* Recursively search for a file.
|
|
73
26
|
* Starts in the current folder, and go to the parent, recursively.
|
|
@@ -108,3 +61,29 @@ export function getProjectFolders(projectFolder) {
|
|
|
108
61
|
};
|
|
109
62
|
}
|
|
110
63
|
export const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
64
|
+
/**
|
|
65
|
+
* Get the .minecraft path
|
|
66
|
+
*/
|
|
67
|
+
export function getMinecraftPath() {
|
|
68
|
+
function getMCPath() {
|
|
69
|
+
switch (os.platform()) {
|
|
70
|
+
case 'win32':
|
|
71
|
+
return path.join(os.homedir(), 'AppData/Roaming/.minecraft');
|
|
72
|
+
case 'darwin':
|
|
73
|
+
return path.join(os.homedir(), 'Library/Application Support/minecraft');
|
|
74
|
+
case 'linux':
|
|
75
|
+
default:
|
|
76
|
+
return path.join(os.homedir(), '.minecraft');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const mcPath = getMCPath();
|
|
80
|
+
if (!fs.existsSync(mcPath)) {
|
|
81
|
+
throw new Error('Unable to locate the .minecraft folder. Please specify it manually.');
|
|
82
|
+
}
|
|
83
|
+
return mcPath;
|
|
84
|
+
}
|
|
85
|
+
export function getWorldsList() {
|
|
86
|
+
const mcPath = getMinecraftPath();
|
|
87
|
+
const savesPath = path.join(mcPath, 'saves');
|
|
88
|
+
return fs.readdirSync(savesPath, { withFileTypes: true }).filter((f) => f.isDirectory).map((f) => f.name);
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sandstone-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "The CLI for Sandstone - the minecraft pack creation library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/sandstone-mc/sandstone-cli#readme",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@types/node": "^20.8.
|
|
44
|
+
"@types/node": "^20.8.9",
|
|
45
45
|
"chalk": "^5.3.0",
|
|
46
46
|
"chalk-template": "^1.1.0",
|
|
47
47
|
"chokidar": "^3.5.3",
|
package/src/commands/create.ts
CHANGED
|
@@ -45,7 +45,7 @@ export async function createCommand(_project: string, opts: CreateOptions) {
|
|
|
45
45
|
|
|
46
46
|
const sv = (v: string) => new SemVer(v)
|
|
47
47
|
|
|
48
|
-
const versions = [[sv('0.13.6'), sv('0.5.4')], [sv('0.14.0-alpha.13'), sv('0.5.4')], [sv('1.0.0-alpha.
|
|
48
|
+
const versions = [[sv('0.13.6'), sv('0.5.4')], [sv('0.14.0-alpha.13'), sv('0.5.4')], [sv('1.0.0-alpha.5'), sv('1.1.6')]] as const
|
|
49
49
|
|
|
50
50
|
const stableIndex = 0
|
|
51
51
|
|
package/src/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs'
|
|
2
|
-
import os from 'os'
|
|
3
2
|
import path from 'path'
|
|
3
|
+
import os from 'os'
|
|
4
4
|
import { execSync } from 'child_process'
|
|
5
5
|
import chalk from 'chalk-template'
|
|
6
6
|
|
|
@@ -21,67 +21,6 @@ export function hasPnpm(): boolean {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/**
|
|
25
|
-
* Get the .minecraft path
|
|
26
|
-
*/
|
|
27
|
-
export function getMinecraftPath(): string {
|
|
28
|
-
function getMCPath(): string {
|
|
29
|
-
switch (os.platform()) {
|
|
30
|
-
case 'win32':
|
|
31
|
-
return path.join(os.homedir(), 'AppData/Roaming/.minecraft')
|
|
32
|
-
case 'darwin':
|
|
33
|
-
return path.join(os.homedir(), 'Library/Application Support/minecraft')
|
|
34
|
-
case 'linux':
|
|
35
|
-
default:
|
|
36
|
-
return path.join(os.homedir(), '.minecraft')
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const mcPath = getMCPath()
|
|
41
|
-
|
|
42
|
-
if (!fs.existsSync(mcPath)) {
|
|
43
|
-
throw new Error('Unable to locate the .minecraft folder. Please specify it manually.')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return mcPath
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function getWorldsList(): string[] {
|
|
50
|
-
const mcPath = getMinecraftPath()
|
|
51
|
-
const savesPath = path.join(mcPath, 'saves')
|
|
52
|
-
|
|
53
|
-
return fs.readdirSync(
|
|
54
|
-
savesPath,
|
|
55
|
-
{ withFileTypes: true }
|
|
56
|
-
).filter((f) => f.isDirectory).map((f) => f.name)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @param worldName The name of the world
|
|
61
|
-
* @param minecraftPath The optional location of the .minecraft folder.
|
|
62
|
-
* If left unspecified, the .minecraft will be found automatically.
|
|
63
|
-
*/
|
|
64
|
-
export function getWorldPath(worldName: string, minecraftPath: string | undefined = undefined): string {
|
|
65
|
-
let mcPath: string
|
|
66
|
-
|
|
67
|
-
if (minecraftPath) {
|
|
68
|
-
mcPath = minecraftPath
|
|
69
|
-
} else {
|
|
70
|
-
mcPath = getMinecraftPath()
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const savesPath = path.join(mcPath, 'saves')
|
|
74
|
-
const worldPath = path.join(savesPath, worldName)
|
|
75
|
-
|
|
76
|
-
if (!fs.existsSync(worldPath)) {
|
|
77
|
-
const existingWorlds = fs.readdirSync(savesPath, { withFileTypes: true }).filter((f) => f.isDirectory).map((f) => f.name)
|
|
78
|
-
|
|
79
|
-
throw new Error(`Unable to locate the "${worldPath}" folder. Word ${worldName} does not exists. List of existing worlds: ${JSON.stringify(existingWorlds, null, 2)}`)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return worldPath
|
|
83
|
-
}
|
|
84
|
-
|
|
85
24
|
/**
|
|
86
25
|
* Recursively search for a file.
|
|
87
26
|
* Starts in the current folder, and go to the parent, recursively.
|
|
@@ -132,4 +71,39 @@ export function getProjectFolders(projectFolder: string): ProjectFolders {
|
|
|
132
71
|
}
|
|
133
72
|
}
|
|
134
73
|
|
|
135
|
-
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1)
|
|
74
|
+
export const capitalize = (s: string) => s.charAt(0).toUpperCase() + s.slice(1)
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get the .minecraft path
|
|
78
|
+
*/
|
|
79
|
+
export function getMinecraftPath(): string {
|
|
80
|
+
function getMCPath(): string {
|
|
81
|
+
switch (os.platform()) {
|
|
82
|
+
case 'win32':
|
|
83
|
+
return path.join(os.homedir(), 'AppData/Roaming/.minecraft')
|
|
84
|
+
case 'darwin':
|
|
85
|
+
return path.join(os.homedir(), 'Library/Application Support/minecraft')
|
|
86
|
+
case 'linux':
|
|
87
|
+
default:
|
|
88
|
+
return path.join(os.homedir(), '.minecraft')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const mcPath = getMCPath()
|
|
93
|
+
|
|
94
|
+
if (!fs.existsSync(mcPath)) {
|
|
95
|
+
throw new Error('Unable to locate the .minecraft folder. Please specify it manually.')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return mcPath
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function getWorldsList(): string[] {
|
|
102
|
+
const mcPath = getMinecraftPath()
|
|
103
|
+
const savesPath = path.join(mcPath, 'saves')
|
|
104
|
+
|
|
105
|
+
return fs.readdirSync(
|
|
106
|
+
savesPath,
|
|
107
|
+
{ withFileTypes: true }
|
|
108
|
+
).filter((f) => f.isDirectory).map((f) => f.name)
|
|
109
|
+
}
|