cloudron 4.15.2 → 5.0.1
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/cloudron +2 -1
- package/bin/cloudron-appstore +1 -1
- package/bin/cloudron-backup +1 -1
- package/bin/cloudron-env +1 -1
- package/package.json +8 -8
- package/src/actions.js +42 -14
- package/src/templates/CloudronManifest.appstore.json.ejs +24 -0
- package/src/templates/Dockerfile.ejs +7 -1
- package/src/templates/start.sh.ejs +3 -0
package/bin/cloudron
CHANGED
|
@@ -122,6 +122,7 @@ program.command('inspect')
|
|
|
122
122
|
|
|
123
123
|
program.command('init')
|
|
124
124
|
.description('Creates a new CloudronManifest.json and Dockerfile')
|
|
125
|
+
.option('--appstore', 'Appstore template')
|
|
125
126
|
.action(actions.init);
|
|
126
127
|
|
|
127
128
|
program.command('install')
|
|
@@ -257,7 +258,7 @@ program.command('update')
|
|
|
257
258
|
|
|
258
259
|
const knownCommand = program.commands.some(function (command) { return command._name === process.argv[2] || command._alias === process.argv[2]; });
|
|
259
260
|
if (!knownCommand) {
|
|
260
|
-
console.log('Unknown command: ' + process.argv[2]
|
|
261
|
+
console.log('Unknown command: ' + process.argv[2] + '.\nTry ' + 'cloudron help');
|
|
261
262
|
process.exit(1);
|
|
262
263
|
}
|
|
263
264
|
})();
|
package/bin/cloudron-appstore
CHANGED
|
@@ -71,7 +71,7 @@ if (!process.argv.slice(2).length) {
|
|
|
71
71
|
|
|
72
72
|
var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2] || command._alias === process.argv[2]; });
|
|
73
73
|
if (!knownCommand) {
|
|
74
|
-
console.log('Unknown command: ' + process.argv[2]
|
|
74
|
+
console.log('Unknown command: ' + process.argv[2] + '.\nTry ' + 'cloudron appstore help');
|
|
75
75
|
process.exit(1);
|
|
76
76
|
}
|
|
77
77
|
return;
|
package/bin/cloudron-backup
CHANGED
|
@@ -56,7 +56,7 @@ if (!process.argv.slice(2).length) {
|
|
|
56
56
|
|
|
57
57
|
var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2] || command._alias === process.argv[2]; });
|
|
58
58
|
if (!knownCommand) {
|
|
59
|
-
console.log('Unknown command: ' + process.argv[2]
|
|
59
|
+
console.log('Unknown command: ' + process.argv[2] + '.\nTry ' + 'cloudron backup help');
|
|
60
60
|
process.exit(1);
|
|
61
61
|
}
|
|
62
62
|
return;
|
package/bin/cloudron-env
CHANGED
|
@@ -39,7 +39,7 @@ if (!process.argv.slice(2).length) {
|
|
|
39
39
|
|
|
40
40
|
var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2] || command._alias === process.argv[2]; });
|
|
41
41
|
if (!knownCommand) {
|
|
42
|
-
console.log('Unknown command: ' + process.argv[2]
|
|
42
|
+
console.log('Unknown command: ' + process.argv[2] + '.\nTry ' + 'cloudron env help');
|
|
43
43
|
process.exit(1);
|
|
44
44
|
}
|
|
45
45
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudron",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Cloudron Commandline Tool",
|
|
6
6
|
"main": "main.js",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"async": "^3.2.3",
|
|
21
21
|
"cloudron-manifestformat": "^5.15.2",
|
|
22
22
|
"commander": "^6.1.0",
|
|
23
|
-
"debug": "^4.3.
|
|
23
|
+
"debug": "^4.3.4",
|
|
24
24
|
"delay": "^5.0.0",
|
|
25
25
|
"easy-table": "^1.2.0",
|
|
26
|
-
"ejs": "^3.1.
|
|
27
|
-
"eventsource": "^
|
|
28
|
-
"micromatch": "^4.0.
|
|
26
|
+
"ejs": "^3.1.8",
|
|
27
|
+
"eventsource": "^2.0.2",
|
|
28
|
+
"micromatch": "^4.0.5",
|
|
29
29
|
"once": "^1.4.0",
|
|
30
30
|
"open": "^8.4.0",
|
|
31
31
|
"progress": "^2.0.3",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"readline-sync": "^1.4.10",
|
|
34
34
|
"safetydance": "^2.2.0",
|
|
35
35
|
"split": "^1.0.1",
|
|
36
|
-
"superagent": "^7.
|
|
36
|
+
"superagent": "^7.1.3",
|
|
37
37
|
"tar-fs": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.12.0.tgz",
|
|
38
|
-
"underscore": "^1.13.
|
|
38
|
+
"underscore": "^1.13.3"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">= 14.x.x"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"expect.js": "^0.3.1",
|
|
45
45
|
"memorystream": "^0.3.1",
|
|
46
|
-
"mocha": "^
|
|
46
|
+
"mocha": "^10.0.0",
|
|
47
47
|
"rimraf": "^3.0.2"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/actions.js
CHANGED
|
@@ -14,7 +14,6 @@ const assert = require('assert'),
|
|
|
14
14
|
path = require('path'),
|
|
15
15
|
ProgressBar = require('progress'),
|
|
16
16
|
ProgressStream = require('progress-stream'),
|
|
17
|
-
querystring = require('querystring'),
|
|
18
17
|
readlineSync = require('readline-sync'),
|
|
19
18
|
safe = require('safetydance'),
|
|
20
19
|
spawn = require('child_process').spawn,
|
|
@@ -1309,19 +1308,30 @@ async function exec(cmd, options) {
|
|
|
1309
1308
|
|
|
1310
1309
|
if (tty && !stdin.isTTY) exit('stdin is not tty');
|
|
1311
1310
|
|
|
1311
|
+
const request = createRequest('POST', `/api/v1/apps/${app.id}/exec`, options);
|
|
1312
|
+
const response = await request.send({ cmd, tty });
|
|
1313
|
+
if (response.statusCode !== 200) return exit(`Failed to create exec: ${requestError(response)}`);
|
|
1314
|
+
const execId = response.body.id;
|
|
1315
|
+
|
|
1316
|
+
async function exitWithCode() {
|
|
1317
|
+
const response2 = await createRequest('GET', `/api/v1/apps/${app.id}/exec/${execId}`, options);
|
|
1318
|
+
if (response2.statusCode !== 200) return exit(`Failed to get exec code: ${requestError(response2)}`);
|
|
1319
|
+
|
|
1320
|
+
process.exit(response2.body.exitCode);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1312
1323
|
const { adminFqdn, token, rejectUnauthorized } = requestOptions(options);
|
|
1313
1324
|
|
|
1314
|
-
const
|
|
1315
|
-
rows: stdout.rows,
|
|
1316
|
-
columns: stdout.columns,
|
|
1325
|
+
const searchParams = new URLSearchParams({
|
|
1326
|
+
rows: stdout.rows || 24,
|
|
1327
|
+
columns: stdout.columns || 80,
|
|
1317
1328
|
access_token: token,
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
};
|
|
1329
|
+
tty
|
|
1330
|
+
});
|
|
1321
1331
|
|
|
1322
1332
|
const req = https.request({
|
|
1323
1333
|
hostname: adminFqdn,
|
|
1324
|
-
path: `/api/v1/apps/${app.id}/exec
|
|
1334
|
+
path: `/api/v1/apps/${app.id}/exec/${execId}/start?${searchParams.toString()}`,
|
|
1325
1335
|
method: 'GET',
|
|
1326
1336
|
headers: {
|
|
1327
1337
|
'Connection': 'Upgrade',
|
|
@@ -1345,8 +1355,8 @@ async function exec(cmd, options) {
|
|
|
1345
1355
|
stdin.setRawMode(true);
|
|
1346
1356
|
stdin.pipe(socket, { end: false }); // the remote will close the connection
|
|
1347
1357
|
socket.pipe(stdout); // in tty mode, stdout/stderr is merged
|
|
1348
|
-
socket.on('end',
|
|
1349
|
-
} else {// create stdin process on demand
|
|
1358
|
+
socket.on('end', exitWithCode); // server closed the socket
|
|
1359
|
+
} else { // create stdin process on demand
|
|
1350
1360
|
if (typeof stdin === 'function') stdin = stdin();
|
|
1351
1361
|
|
|
1352
1362
|
stdin.on('data', function (d) {
|
|
@@ -1361,7 +1371,7 @@ async function exec(cmd, options) {
|
|
|
1361
1371
|
socket.write(buf);
|
|
1362
1372
|
});
|
|
1363
1373
|
|
|
1364
|
-
stdout.on('close',
|
|
1374
|
+
stdout.on('close', exitWithCode); // this is only emitted when stdout is a file and not the terminal
|
|
1365
1375
|
|
|
1366
1376
|
demuxStream(socket, stdout, process.stderr); // can get separate streams in non-tty mode
|
|
1367
1377
|
socket.on('end', function () { // server closed the socket
|
|
@@ -1371,7 +1381,7 @@ async function exec(cmd, options) {
|
|
|
1371
1381
|
socket.end();
|
|
1372
1382
|
|
|
1373
1383
|
// process._getActiveHandles(); process._getActiveRequests();
|
|
1374
|
-
if (stdout === process.stdout) setImmediate(
|
|
1384
|
+
if (stdout === process.stdout) setImmediate(exitWithCode); // otherwise, we rely on the 'close' event above
|
|
1375
1385
|
});
|
|
1376
1386
|
}
|
|
1377
1387
|
});
|
|
@@ -1450,13 +1460,16 @@ function pull(remote, local, options) {
|
|
|
1450
1460
|
}
|
|
1451
1461
|
}
|
|
1452
1462
|
|
|
1453
|
-
function init() {
|
|
1463
|
+
function init(options) {
|
|
1454
1464
|
const manifestFilePath = helper.locateManifest();
|
|
1455
1465
|
if (manifestFilePath && path.dirname(manifestFilePath) === process.cwd()) return exit('CloudronManifest.json already exists in current directory');
|
|
1456
1466
|
|
|
1457
|
-
const
|
|
1467
|
+
const manifestTemplateFilename = options.appstore ? 'CloudronManifest.appstore.json.ejs' : 'CloudronManifest.json.ejs';
|
|
1468
|
+
|
|
1469
|
+
const manifestTemplate = fs.readFileSync(path.join(__dirname, 'templates/', manifestTemplateFilename), 'utf8');
|
|
1458
1470
|
const dockerfileTemplate = fs.readFileSync(path.join(__dirname, 'templates/', 'Dockerfile.ejs'), 'utf8');
|
|
1459
1471
|
const dockerignoreTemplate = fs.readFileSync(path.join(__dirname, 'templates/', 'dockerignore.ejs'), 'utf8');
|
|
1472
|
+
const startShTemplate = fs.readFileSync(path.join(__dirname, 'templates/', 'start.sh.ejs'), 'utf8');
|
|
1460
1473
|
|
|
1461
1474
|
const data = {
|
|
1462
1475
|
version: '0.1.0',
|
|
@@ -1481,6 +1494,21 @@ function init() {
|
|
|
1481
1494
|
fs.writeFileSync('.dockerignore', dockerignore, 'utf8');
|
|
1482
1495
|
}
|
|
1483
1496
|
|
|
1497
|
+
if (fs.existsSync('start.sh')) {
|
|
1498
|
+
console.log('start.sh already exists, skipping');
|
|
1499
|
+
} else {
|
|
1500
|
+
const dockerignore = ejs.render(startShTemplate, {});
|
|
1501
|
+
fs.writeFileSync('start.sh', dockerignore, 'utf8');
|
|
1502
|
+
fs.chmodSync('start.sh', 0o0775);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
if (options.appstore) {
|
|
1506
|
+
if (!fs.existsSync('.gitignore')) fs.writeFileSync('.gitignore', 'node_modules/\n', 'utf8');
|
|
1507
|
+
if (!fs.existsSync('DESCRIPTION.md')) fs.writeFileSync('DESCRIPTION.md', '## About\n\nThis app changes everything\n\n', 'utf8');
|
|
1508
|
+
if (!fs.existsSync('POSTINSTALL.md')) fs.writeFileSync('POSTINSTALL.md', 'Post installation information\n\n', 'utf8');
|
|
1509
|
+
if (!fs.existsSync('CHANGELOG')) fs.writeFileSync('CHANGELOG', '[0.1.0]\n* Initial version\n\n', 'utf8');
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1484
1512
|
console.log();
|
|
1485
1513
|
console.log('Now edit the CloudronManifest.json');
|
|
1486
1514
|
console.log();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "<%- version %>",
|
|
3
|
+
"upstreamVersion": "",
|
|
4
|
+
"minBoxVersion": "7.1.0",
|
|
5
|
+
"title": "",
|
|
6
|
+
"author": "",
|
|
7
|
+
"description": "file://DESCRIPTION.md",
|
|
8
|
+
"tagline": "",
|
|
9
|
+
"website": "",
|
|
10
|
+
"contactEmail": "",
|
|
11
|
+
"icon": "file://logo.png",
|
|
12
|
+
"healthCheckPath": "/",
|
|
13
|
+
"mediaLinks": [],
|
|
14
|
+
"httpPort": <%- httpPort %>,
|
|
15
|
+
"tags": [],
|
|
16
|
+
"changelog": "file://CHANGELOG",
|
|
17
|
+
"postInstallMessage": "file://POSTINSTALL.md",
|
|
18
|
+
"documentationUrl": "",
|
|
19
|
+
"forumUrl": "",
|
|
20
|
+
"addons": {
|
|
21
|
+
"localstorage": {}
|
|
22
|
+
},
|
|
23
|
+
"manifestVersion": 2
|
|
24
|
+
}
|