@dynamicweb/cli 1.0.8 → 1.0.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/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
|
@@ -104,6 +104,7 @@ async function handleFiles(argv) {
|
|
|
104
104
|
if (argv.recursive) {
|
|
105
105
|
await processDirectory(env, user, resolvedPath, argv.outPath, resolvedPath, argv.createEmpty, true, argv.overwrite);
|
|
106
106
|
} else {
|
|
107
|
+
console.log(resolvedPath)
|
|
107
108
|
let filesInDir = getFilesInDirectory(resolvedPath);
|
|
108
109
|
await uploadFiles(env, user, filesInDir, argv.outPath, argv.createEmpty, argv.overwrite);
|
|
109
110
|
}
|
|
@@ -112,7 +113,7 @@ async function handleFiles(argv) {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
function getFilesInDirectory(dirPath) {
|
|
115
|
-
return fs.readdirSync(dirPath)
|
|
116
|
+
return fs.statSync(dirPath).isFile() ? [ dirPath ] : fs.readdirSync(dirPath)
|
|
116
117
|
.map(file => path.join(dirPath, file))
|
|
117
118
|
.filter(file => fs.statSync(file).isFile());
|
|
118
119
|
}
|
|
@@ -237,6 +238,8 @@ async function getFilesStructure(env, user, dirPath, recursive, includeFiles) {
|
|
|
237
238
|
return await res.json();
|
|
238
239
|
} else {
|
|
239
240
|
console.log(res);
|
|
241
|
+
console.log(res.json());
|
|
242
|
+
process.exit(1);
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
245
|
|
|
@@ -247,8 +250,11 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
247
250
|
form.append('skipExistingFiles', String(!overwrite));
|
|
248
251
|
form.append('allowOverwrite', String(overwrite));
|
|
249
252
|
localFilePaths.forEach((localPath, index) => {
|
|
250
|
-
|
|
251
|
-
|
|
253
|
+
let fileToUpload = resolveFilePath(localPath)
|
|
254
|
+
console.log(fileToUpload)
|
|
255
|
+
if (fileToUpload === undefined)
|
|
256
|
+
return;
|
|
257
|
+
form.append('files', fs.createReadStream(path.resolve(fileToUpload)));
|
|
252
258
|
});
|
|
253
259
|
let res = await fetch(`${env.protocol}://${env.host}/Admin/Api/Upload?` + new URLSearchParams({"createEmptyFiles": createEmpty, "createMissingDirectories": true}), {
|
|
254
260
|
method: 'POST',
|
|
@@ -265,6 +271,26 @@ export async function uploadFiles(env, user, localFilePaths, destinationPath, cr
|
|
|
265
271
|
else {
|
|
266
272
|
console.log(res)
|
|
267
273
|
console.log(res.json())
|
|
268
|
-
|
|
274
|
+
process.exit(1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export function resolveFilePath(filePath) {
|
|
279
|
+
let p = path.parse(path.resolve(filePath))
|
|
280
|
+
let regex = wildcardToRegExp(p.base);
|
|
281
|
+
let resolvedPath = fs.readdirSync(p.dir).filter((allFilesPaths) => allFilesPaths.match(regex) !== null)[0]
|
|
282
|
+
if (resolvedPath === undefined)
|
|
283
|
+
{
|
|
284
|
+
console.log('Could not find any files with the name ' + filePath);
|
|
285
|
+
process.exit(1);
|
|
269
286
|
}
|
|
287
|
+
return path.join(p.dir, resolvedPath);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function wildcardToRegExp(wildcard) {
|
|
291
|
+
return new RegExp('^' + wildcard
|
|
292
|
+
.replace(/\./g, '\\.')
|
|
293
|
+
.replace(/\*/g, '.*')
|
|
294
|
+
.replace(/\?/g, '.')
|
|
295
|
+
+ '$');
|
|
270
296
|
}
|
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