sandstone-cli 1.1.8 → 1.1.10
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/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.6'), sv('1.1.9')]];
|
|
30
30
|
const stableIndex = 0;
|
|
31
31
|
const { version } = await inquirer.prompt({
|
|
32
32
|
name: 'version',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function installNativeCommand(): Promise<void>;
|
|
1
|
+
export declare function installNativeCommand(_libraries: string[]): Promise<void>;
|
|
2
2
|
export declare function installVanillaCommand(_libraries: string[]): Promise<void>;
|
|
3
3
|
export declare function uninstallVanillaCommand(_libraries: string[]): Promise<void>;
|
|
4
4
|
export declare function refreshCommand(): Promise<void>;
|
|
@@ -1,10 +1,72 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { exec } from 'child_process';
|
|
3
4
|
import { buildCommand } from './build.js';
|
|
4
5
|
import inquirer from 'inquirer';
|
|
5
6
|
const _fetch = import('node-fetch');
|
|
6
|
-
export async function installNativeCommand() {
|
|
7
|
-
|
|
7
|
+
export async function installNativeCommand(_libraries) {
|
|
8
|
+
let libraries = _libraries.map((lib) => [lib, false]);
|
|
9
|
+
let count = libraries.length || 0;
|
|
10
|
+
const fetch = (await _fetch).default;
|
|
11
|
+
const manifest = await (await fetch('https://raw.githubusercontent.com/sandstone-mc/sandstone-libraries/main/manifest.json')).json();
|
|
12
|
+
const search = async () => {
|
|
13
|
+
const { selected } = await inquirer.prompt({
|
|
14
|
+
name: 'selected',
|
|
15
|
+
type: 'checkbox',
|
|
16
|
+
message: 'Which libraries to add?',
|
|
17
|
+
choices: manifest.libraries.map((library) => ({
|
|
18
|
+
name: library.name,
|
|
19
|
+
value: library.package,
|
|
20
|
+
})),
|
|
21
|
+
});
|
|
22
|
+
if (selected && selected.length !== 0) {
|
|
23
|
+
libraries.push(...selected.map((lib) => [lib, true]));
|
|
24
|
+
count += selected.length;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if (count === 0) {
|
|
28
|
+
await search();
|
|
29
|
+
}
|
|
30
|
+
if (count > 0) {
|
|
31
|
+
let adding = false;
|
|
32
|
+
for await (const [library, searched] of libraries) {
|
|
33
|
+
if (searched) {
|
|
34
|
+
if (!adding)
|
|
35
|
+
adding = [];
|
|
36
|
+
adding.push(library);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
let exists = manifest.libraries.find((lib) => lib.name === library);
|
|
40
|
+
if (exists) {
|
|
41
|
+
if (!adding)
|
|
42
|
+
adding = [];
|
|
43
|
+
adding.push(exists.package);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
count--;
|
|
47
|
+
console.log(`${library} doesn't exist!`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (adding) {
|
|
52
|
+
console.log(`Installing ${adding.join(', ')}...`);
|
|
53
|
+
const pnpm = await fs.exists(path.resolve('./pnpm-lock.yaml'));
|
|
54
|
+
const yarn = await fs.exists(path.resolve('./yarn.lock'));
|
|
55
|
+
const npm = await fs.exists(path.resolve('./package-lock.json'));
|
|
56
|
+
if (pnpm) {
|
|
57
|
+
exec(`pnpm i ${adding.join(' ')}`);
|
|
58
|
+
}
|
|
59
|
+
else if (yarn) {
|
|
60
|
+
exec(`yarn add ${adding.join(' ')}`);
|
|
61
|
+
}
|
|
62
|
+
else if (npm) {
|
|
63
|
+
exec(`npm i ${adding.join(' ')}`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.error('error: no package manager lockfile');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
8
70
|
}
|
|
9
71
|
export async function installVanillaCommand(_libraries) {
|
|
10
72
|
let libraries = _libraries.map((lib) => [lib, false]);
|
|
@@ -19,16 +81,14 @@ export async function installVanillaCommand(_libraries) {
|
|
|
19
81
|
const search = async (term) => {
|
|
20
82
|
const options = [];
|
|
21
83
|
const optionColumn = [0, 0, 0];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const owner = await (await fetch(`${base}/users/${meta.owner}`)).json();
|
|
25
|
-
const { display: { description } } = await (await fetch(`${base}/packs/${id}`)).json();
|
|
84
|
+
const scopes = ['data.display.description', 'meta.rawId', 'meta.stats.downloads.total', 'owner.displayName'].map((scope) => `scope=${scope}`).join('&');
|
|
85
|
+
for await (const { id, displayName, meta, data, owner } of await (await fetch(`${base}/packs?category=Library&sort=downloads&${scopes}${term ? `&search=${encodeURIComponent(term)}` : ''}`)).json()) {
|
|
26
86
|
const option = {
|
|
27
87
|
id: meta.rawId,
|
|
28
88
|
name: displayName,
|
|
29
89
|
owner: owner.displayName,
|
|
30
90
|
downloads: `${meta.stats.downloads.total}`,
|
|
31
|
-
description: description,
|
|
91
|
+
description: data.display.description,
|
|
32
92
|
};
|
|
33
93
|
if (manifest && !manifest[id] && !manifest[meta.rawId]) {
|
|
34
94
|
if (option.name.length > optionColumn[0])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sandstone-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
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.
|
|
44
|
+
"@types/node": "^20.10.0",
|
|
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.6'), sv('1.1.9')]] as const
|
|
49
49
|
|
|
50
50
|
const stableIndex = 0
|
|
51
51
|
|
|
@@ -1,21 +1,98 @@
|
|
|
1
1
|
import fs from 'fs-extra'
|
|
2
2
|
import path from 'path'
|
|
3
|
+
import { exec } from 'child_process'
|
|
3
4
|
import { buildCommand } from './build.js'
|
|
4
5
|
import inquirer from 'inquirer'
|
|
5
6
|
|
|
6
7
|
const _fetch = import('node-fetch')
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
type LibraryManifest = {
|
|
10
|
+
libraries: {
|
|
11
|
+
name: string,
|
|
12
|
+
package: string,
|
|
13
|
+
}[]
|
|
10
14
|
}
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
export async function installNativeCommand(_libraries: string[]) {
|
|
17
|
+
let libraries: [string, boolean][] = _libraries.map((lib) => [lib, false])
|
|
18
|
+
|
|
19
|
+
let count = libraries.length || 0
|
|
20
|
+
|
|
21
|
+
const fetch = (await _fetch).default
|
|
22
|
+
|
|
23
|
+
const manifest = await (await fetch('https://raw.githubusercontent.com/sandstone-mc/sandstone-libraries/main/manifest.json')).json() as LibraryManifest
|
|
24
|
+
|
|
25
|
+
const search = async () => {
|
|
26
|
+
const { selected } = await inquirer.prompt({
|
|
27
|
+
name: 'selected',
|
|
28
|
+
type: 'checkbox',
|
|
29
|
+
message: 'Which libraries to add?',
|
|
30
|
+
choices: manifest.libraries.map((library) => ({
|
|
31
|
+
name: library.name,
|
|
32
|
+
value: library.package,
|
|
33
|
+
})),
|
|
34
|
+
}) as {
|
|
35
|
+
selected: string[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (selected && selected.length !== 0) {
|
|
39
|
+
libraries.push(...selected.map((lib) => [lib, true] as [string, boolean]))
|
|
40
|
+
|
|
41
|
+
count += selected.length
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (count === 0) {
|
|
46
|
+
await search()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (count > 0) {
|
|
50
|
+
let adding: string[] | false = false
|
|
51
|
+
|
|
52
|
+
for await (const [library, searched] of libraries) {
|
|
53
|
+
if (searched) {
|
|
54
|
+
if (!adding) adding = []
|
|
55
|
+
adding.push(library)
|
|
56
|
+
} else {
|
|
57
|
+
let exists = manifest.libraries.find((lib) => lib.name === library)
|
|
13
58
|
|
|
14
|
-
|
|
59
|
+
if (exists) {
|
|
60
|
+
if (!adding) adding = []
|
|
61
|
+
adding.push(exists.package)
|
|
62
|
+
} else {
|
|
63
|
+
count--
|
|
15
64
|
|
|
16
|
-
|
|
65
|
+
console.log(`${library} doesn't exist!`)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (adding) {
|
|
70
|
+
console.log(`Installing ${adding.join(', ')}...`)
|
|
71
|
+
|
|
72
|
+
const pnpm = await fs.exists(path.resolve('./pnpm-lock.yaml'))
|
|
73
|
+
const yarn = await fs.exists(path.resolve('./yarn.lock'))
|
|
74
|
+
const npm = await fs.exists(path.resolve('./package-lock.json'))
|
|
75
|
+
|
|
76
|
+
if (pnpm) {
|
|
77
|
+
exec(`pnpm i ${adding.join(' ')}`)
|
|
78
|
+
} else if (yarn) {
|
|
79
|
+
exec(`yarn add ${adding.join(' ')}`)
|
|
80
|
+
} else if (npm) {
|
|
81
|
+
exec(`npm i ${adding.join(' ')}`)
|
|
82
|
+
} else {
|
|
83
|
+
console.error('error: no package manager lockfile')
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
17
88
|
|
|
18
|
-
type
|
|
89
|
+
type SmithedSearch = {
|
|
90
|
+
id: string,
|
|
91
|
+
displayName: string,
|
|
92
|
+
data: { display: { description: string } },
|
|
93
|
+
meta: { rawId: string, stats: { downloads: { total: number } }, owner: string }
|
|
94
|
+
owner: { displayName: string }
|
|
95
|
+
}[]
|
|
19
96
|
|
|
20
97
|
export async function installVanillaCommand(_libraries: string[]) {
|
|
21
98
|
let libraries: [string, boolean][] = _libraries.map((lib) => [lib, false])
|
|
@@ -35,18 +112,16 @@ export async function installVanillaCommand(_libraries: string[]) {
|
|
|
35
112
|
|
|
36
113
|
const optionColumn = [0, 0, 0]
|
|
37
114
|
|
|
38
|
-
|
|
115
|
+
const scopes = ['data.display.description', 'meta.rawId', 'meta.stats.downloads.total', 'owner.displayName'].map((scope) => `scope=${scope}`).join('&')
|
|
39
116
|
|
|
40
|
-
|
|
41
|
-
const owner = await(await fetch(`${base}/users/${meta.owner}`)).json() as SmithedUser
|
|
42
|
-
const { display: { description }} = await(await fetch(`${base}/packs/${id}`)).json() as SmithedPack
|
|
117
|
+
for await (const { id, displayName, meta, data, owner } of (await (await fetch(`${base}/packs?category=Library&sort=downloads&${scopes}${term ? `&search=${encodeURIComponent(term)}` : ''}`)).json() as SmithedSearch)) {
|
|
43
118
|
|
|
44
119
|
const option = {
|
|
45
120
|
id: meta.rawId,
|
|
46
121
|
name: displayName,
|
|
47
122
|
owner: owner.displayName,
|
|
48
123
|
downloads: `${meta.stats.downloads.total}`,
|
|
49
|
-
description: description,
|
|
124
|
+
description: data.display.description,
|
|
50
125
|
}
|
|
51
126
|
|
|
52
127
|
if (manifest && !manifest[id] && !manifest[meta.rawId]) {
|