@dynamicweb/cli 1.0.8 → 1.0.9
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/bin/commands/command.js
CHANGED
package/bin/commands/database.js
CHANGED
|
@@ -58,7 +58,7 @@ async function download(env, user, path, verbose) {
|
|
|
58
58
|
return res;
|
|
59
59
|
}).then(async (res) => {
|
|
60
60
|
if (!res) {
|
|
61
|
-
|
|
61
|
+
process.exit(1);
|
|
62
62
|
}
|
|
63
63
|
const fileStream = fs.createWriteStream(_path.resolve(`${_path.resolve(path)}/${filename}`));
|
|
64
64
|
await new Promise((resolve, reject) => {
|
package/bin/commands/files.js
CHANGED
|
@@ -237,6 +237,8 @@ async function getFilesStructure(env, user, dirPath, recursive, includeFiles) {
|
|
|
237
237
|
return await res.json();
|
|
238
238
|
} else {
|
|
239
239
|
console.log(res);
|
|
240
|
+
console.log(res.json());
|
|
241
|
+
process.exit(1);
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
|
|
@@ -247,8 +249,11 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
247
249
|
form.append('skipExistingFiles', String(!overwrite));
|
|
248
250
|
form.append('allowOverwrite', String(overwrite));
|
|
249
251
|
localFilePaths.forEach((localPath, index) => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
let fileToUpload = resolveFilePath(localPath)
|
|
253
|
+
console.log(fileToUpload)
|
|
254
|
+
if (fileToUpload === undefined)
|
|
255
|
+
return;
|
|
256
|
+
form.append('files', fs.createReadStream(path.resolve(fileToUpload)));
|
|
252
257
|
});
|
|
253
258
|
let res = await fetch(`${env.protocol}://${env.host}/Admin/Api/Upload?` + new URLSearchParams({"createEmptyFiles": createEmpty, "createMissingDirectories": true}), {
|
|
254
259
|
method: 'POST',
|
|
@@ -265,6 +270,26 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
265
270
|
else {
|
|
266
271
|
console.log(res)
|
|
267
272
|
console.log(res.json())
|
|
268
|
-
|
|
273
|
+
process.exit(1);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function resolveFilePath(filePath) {
|
|
278
|
+
let p = path.parse(path.resolve(filePath))
|
|
279
|
+
let regex = wildcardToRegExp(p.base);
|
|
280
|
+
let resolvedPath = fs.readdirSync(p.dir).filter((allFilesPaths) => allFilesPaths.match(regex) !== null)[0]
|
|
281
|
+
if (resolvedPath === undefined)
|
|
282
|
+
{
|
|
283
|
+
console.log('Could not find any files with the name ' + filePath);
|
|
284
|
+
process.exit(1);
|
|
269
285
|
}
|
|
286
|
+
return resolvedPath;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function wildcardToRegExp(wildcard) {
|
|
290
|
+
return new RegExp('^' + wildcard
|
|
291
|
+
.replace(/\./g, '\\.')
|
|
292
|
+
.replace(/\*/g, '.*')
|
|
293
|
+
.replace(/\?/g, '.')
|
|
294
|
+
+ '$');
|
|
270
295
|
}
|
package/bin/commands/install.js
CHANGED
|
@@ -2,7 +2,7 @@ import fetch from 'node-fetch';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { setupEnv, getAgent } from './env.js';
|
|
4
4
|
import { setupUser } from './login.js';
|
|
5
|
-
import { uploadFiles } from './files.js';
|
|
5
|
+
import { uploadFiles, resolveFilePath } from './files.js';
|
|
6
6
|
|
|
7
7
|
export function installCommand() {
|
|
8
8
|
return {
|
|
@@ -24,9 +24,8 @@ export function installCommand() {
|
|
|
24
24
|
async function handleInstall(argv) {
|
|
25
25
|
let env = await setupEnv(argv);
|
|
26
26
|
let user = await setupUser(argv, env);
|
|
27
|
-
|
|
28
|
-
await
|
|
29
|
-
await installAddin(env, user, resolvedPath)
|
|
27
|
+
await uploadFiles(env, user, [ argv.filePath ], 'System/AddIns/Local', false, true);
|
|
28
|
+
await installAddin(env, user, resolveFilePath(argv.filePath))
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
async function installAddin(env, user, resolvedPath) {
|
|
@@ -54,5 +53,6 @@ async function installAddin(env, user, resolvedPath) {
|
|
|
54
53
|
else {
|
|
55
54
|
console.log('Request failed, returned error:')
|
|
56
55
|
console.log(await res.json())
|
|
56
|
+
process.exit(1);
|
|
57
57
|
}
|
|
58
58
|
}
|
package/bin/commands/login.js
CHANGED
|
@@ -135,6 +135,8 @@ async function login(username, password, env, protocol, verbose) {
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
if (res.ok) {
|
|
138
|
+
console.log(res)
|
|
139
|
+
console.log(res.json())
|
|
138
140
|
let user = parseCookies(res.headers.get('set-cookie')).user;
|
|
139
141
|
if (!user) return;
|
|
140
142
|
return await getToken(user, env, protocol, verbose)
|
package/bin/commands/query.js
CHANGED
package/package.json
CHANGED