sandstone-cli 1.0.2 → 1.0.4
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/build/index.js +5 -4
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +1 -1
- package/package.json +1 -1
- package/src/build/index.ts +5 -4
- package/src/utils.ts +2 -2
package/lib/build/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import * as os from 'os';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
4
5
|
import fs from 'fs-extra';
|
|
5
6
|
import PrettyError from 'pretty-error';
|
|
6
7
|
import walk from 'klaw';
|
|
@@ -82,10 +83,10 @@ async function getClientPath() {
|
|
|
82
83
|
*
|
|
83
84
|
* @param projectFolder The folder of the project. It needs a sandstone.config.ts, and it or one of its parent needs a package.json.
|
|
84
85
|
*/
|
|
85
|
-
async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandstoneConfigFolder }) {
|
|
86
|
+
async function _buildProject(cliOptions, { absProjectFolder, projectFolder, rootFolder, sandstoneConfigFolder }) {
|
|
86
87
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
87
88
|
// First, read sandstone.config.ts to get all properties
|
|
88
|
-
const sandstoneConfig = (await import(path.join(sandstoneConfigFolder, 'sandstone.config.ts'))).default;
|
|
89
|
+
const sandstoneConfig = (await import(pathToFileURL(path.join(sandstoneConfigFolder, 'sandstone.config.ts')).toString())).default;
|
|
89
90
|
const { scripts } = sandstoneConfig;
|
|
90
91
|
let { saveOptions } = sandstoneConfig;
|
|
91
92
|
if (saveOptions === undefined)
|
|
@@ -167,11 +168,11 @@ async function _buildProject(cliOptions, { absProjectFolder, rootFolder, sandsto
|
|
|
167
168
|
// Finally, let's import from the index.
|
|
168
169
|
let error = false;
|
|
169
170
|
let sandstonePack;
|
|
170
|
-
const filePath = path.join(
|
|
171
|
+
const filePath = path.join(projectFolder, 'index.ts');
|
|
171
172
|
try {
|
|
172
173
|
// Sometimes, a file might not exist because it has been deleted.
|
|
173
174
|
if (await fs.pathExists(filePath)) {
|
|
174
|
-
sandstonePack = (await import(filePath)).default;
|
|
175
|
+
sandstonePack = (await import(pathToFileURL(filePath).toString())).default;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
catch (e) {
|
package/lib/utils.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare function getWorldPath(worldName: string, minecraftPath?: string |
|
|
|
23
23
|
export declare function getFileFolder(filename: string, from?: string): string | null;
|
|
24
24
|
export type ProjectFolders = {
|
|
25
25
|
absProjectFolder: string;
|
|
26
|
+
projectFolder: string;
|
|
26
27
|
rootFolder: string;
|
|
27
28
|
sandstoneConfigFolder: string;
|
|
28
29
|
};
|
package/lib/utils.js
CHANGED
|
@@ -104,7 +104,7 @@ export function getProjectFolders(projectFolder) {
|
|
|
104
104
|
throw new Error(chalk `{red Failed to find {bold sandstone.config.ts} in the "${absProjectFolder}" folder, or in any parent folder.}`);
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
absProjectFolder, rootFolder, sandstoneConfigFolder
|
|
107
|
+
absProjectFolder, projectFolder, rootFolder, sandstoneConfigFolder
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
export const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
package/package.json
CHANGED
package/src/build/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'path'
|
|
2
2
|
import * as os from 'os'
|
|
3
3
|
import crypto from 'crypto'
|
|
4
|
+
import { pathToFileURL } from 'url'
|
|
4
5
|
import fs from 'fs-extra'
|
|
5
6
|
import PrettyError from 'pretty-error'
|
|
6
7
|
import walk from 'klaw'
|
|
@@ -131,10 +132,10 @@ 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: BuildOptions, { absProjectFolder, rootFolder, sandstoneConfigFolder }: ProjectFolders) {
|
|
135
|
+
async function _buildProject(cliOptions: BuildOptions, { absProjectFolder, projectFolder, rootFolder, sandstoneConfigFolder }: ProjectFolders) {
|
|
135
136
|
|
|
136
137
|
// First, read sandstone.config.ts to get all properties
|
|
137
|
-
const sandstoneConfig = (await import(path.join(sandstoneConfigFolder, 'sandstone.config.ts'))).default
|
|
138
|
+
const sandstoneConfig = (await import(pathToFileURL(path.join(sandstoneConfigFolder, 'sandstone.config.ts')).toString())).default
|
|
138
139
|
|
|
139
140
|
const { scripts } = sandstoneConfig
|
|
140
141
|
|
|
@@ -236,12 +237,12 @@ async function _buildProject(cliOptions: BuildOptions, { absProjectFolder, rootF
|
|
|
236
237
|
|
|
237
238
|
let sandstonePack: any
|
|
238
239
|
|
|
239
|
-
const filePath = path.join(
|
|
240
|
+
const filePath = path.join(projectFolder, 'index.ts')
|
|
240
241
|
|
|
241
242
|
try {
|
|
242
243
|
// Sometimes, a file might not exist because it has been deleted.
|
|
243
244
|
if (await fs.pathExists(filePath)) {
|
|
244
|
-
sandstonePack = (await import(filePath)).default
|
|
245
|
+
sandstonePack = (await import(pathToFileURL(filePath).toString())).default
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
catch (e: any) {
|
package/src/utils.ts
CHANGED
|
@@ -109,7 +109,7 @@ export function getFileFolder(filename: string, from = '.'): string | null {
|
|
|
109
109
|
return fileFolder
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export type ProjectFolders = { absProjectFolder: string, rootFolder: string, sandstoneConfigFolder: string }
|
|
112
|
+
export type ProjectFolders = { absProjectFolder: string, projectFolder: string, rootFolder: string, sandstoneConfigFolder: string }
|
|
113
113
|
|
|
114
114
|
export function getProjectFolders(projectFolder: string): ProjectFolders {
|
|
115
115
|
const absProjectFolder = path.resolve(projectFolder)
|
|
@@ -128,7 +128,7 @@ export function getProjectFolders(projectFolder: string): ProjectFolders {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
return {
|
|
131
|
-
absProjectFolder, rootFolder, sandstoneConfigFolder
|
|
131
|
+
absProjectFolder, projectFolder, rootFolder, sandstoneConfigFolder
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|