cloudron 7.0.1 → 7.0.2

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 CHANGED
@@ -19,7 +19,7 @@ program.version(pkg.version);
19
19
  // global options
20
20
  program.option('--server <server>', 'Cloudron domain')
21
21
  .option('--token <token>', 'Cloudron token')
22
- .option('--allow-selfsigned', 'Accept self signed SSL certificate')
22
+ .option('--allow-selfsigned', 'Accept self signed SSL certificate') // do not removed, used in e2e!
23
23
  .option('--accept-selfsigned', 'Accept self signed SSL certificate')
24
24
  .option('--no-wait', 'Do not wait for the operation to finish');
25
25
 
@@ -26,7 +26,7 @@ program.command('build', { isDefault: true })
26
26
  .description('Build an app. This is the default subcommand')
27
27
  .option('--build-arg <namevalue>', 'Build arg passed to docker. Can be used multiple times', collectArgs, [])
28
28
  .option('-f, --file <dockerfile>', 'Name of the Dockerfile')
29
- .option('--set-repository [repository url]', 'Change the repository. This url is stored for future builds for this project. e.g registry/username/projectname')
29
+ .option('--repository [repository url]', 'Change the repository. This url is stored for future builds for this project. e.g registry/username/projectname')
30
30
  .option('--no-cache', 'Do not use cache')
31
31
  .option('--no-push', 'Do not push built image to registry')
32
32
  .option('--raw', 'Raw output build log')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudron",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "license": "MIT",
5
5
  "description": "Cloudron Commandline Tool",
6
6
  "type": "module",
@@ -16,6 +16,20 @@ import stream from 'stream/promises';
16
16
  import superagent from '@cloudron/superagent';
17
17
  import tar from 'tar-fs';
18
18
 
19
+ function getEffectiveBuildServiceConfig(options) {
20
+ const buildServiceConfig = config.getBuildServiceConfig();
21
+
22
+ if (options.buildServiceUrl) {
23
+ buildServiceConfig.type = 'remote';
24
+ buildServiceConfig.url = options.buildServiceUrl;
25
+ if (buildServiceConfig.url.indexOf('://') === -1) buildServiceConfig.url = `https://${buildServiceConfig.url}`;
26
+ }
27
+
28
+ if (options.buildServiceToken) buildServiceConfig.token = options.buildServiceToken;
29
+
30
+ return buildServiceConfig;
31
+ }
32
+
19
33
  function requestError(response) {
20
34
  if (response.status === 401 || response.status === 403) return 'Invalid token. Use cloudron build login again.';
21
35
 
@@ -26,9 +40,9 @@ function requestError(response) {
26
40
  async function login(localOptions, cmd) {
27
41
  const options = cmd.optsWithGlobals();
28
42
 
29
- const buildServiceConfig = config.getBuildServiceConfig();
43
+ const buildServiceConfig = getEffectiveBuildServiceConfig(options);
30
44
 
31
- let url = options.buildServiceUrl || buildServiceConfig.url;
45
+ let url = buildServiceConfig.url;
32
46
  if (!url) {
33
47
  url = await readline.question('Build Service URL: ', {});
34
48
  if (!url) return exit('No build service URL provided.');
@@ -37,7 +51,7 @@ async function login(localOptions, cmd) {
37
51
 
38
52
  console.log(`Build Service login (${url}):`);
39
53
 
40
- const token = options.buildServiceToken || await readline.question('Token: ', {});
54
+ const token = buildServiceConfig.token || await readline.question('Token: ', {});
41
55
 
42
56
  const response = await superagent.get(`${url}/api/v1/profile`).query({ accessToken: token }).ok(() => true);
43
57
  if (response.status === 401 || response.status === 403) return exit(`Authentication error: ${requestError(response)}`);
@@ -191,8 +205,8 @@ async function buildLocal(manifest, sourceDir, appConfig, options) {
191
205
  config.setAppBuildConfig(sourceDir, appConfig);
192
206
  }
193
207
 
194
- async function buildRemote(manifest, sourceDir, appConfig, options) {
195
- console.log('Using build service', config.getBuildServiceConfig().url);
208
+ async function buildRemote(manifest, sourceDir, appConfig, options, buildServiceConfig) {
209
+ console.log('Using build service', buildServiceConfig.url);
196
210
 
197
211
  let tag;
198
212
  if (options.tag) {
@@ -211,8 +225,6 @@ async function buildRemote(manifest, sourceDir, appConfig, options) {
211
225
  else if (fs.existsSync(`${sourceDir}/Dockerfile.cloudron`)) dockerfile = 'Dockerfile.cloudron';
212
226
  else if (fs.existsSync(`${sourceDir}/cloudron/Dockerfile`)) dockerfile = 'cloudron/Dockerfile';
213
227
 
214
- const buildServiceConfig = config.getBuildServiceConfig();
215
-
216
228
  console.log(`Building ${dockerfile} as ${dockerImage}`);
217
229
 
218
230
  const sourceArchiveFilePath = path.join(os.tmpdir(), path.basename(sourceDir) + '.tar.gz');
@@ -282,12 +294,12 @@ async function build(localOptions, cmd) {
282
294
  const sourceDir = path.dirname(manifestFilePath);
283
295
 
284
296
  const appConfig = config.getAppBuildConfig(sourceDir);
285
- const buildServiceConfig = config.getBuildServiceConfig();
297
+ const buildServiceConfig = getEffectiveBuildServiceConfig(options);
286
298
 
287
299
  let repository = appConfig.repository;
288
- if (!repository || options.setRepository) {
289
- if (typeof options.setRepository === 'string') {
290
- repository = options.setRepository;
300
+ if (!repository || options.repository) {
301
+ if (typeof options.repository === 'string') {
302
+ repository = options.repository;
291
303
  } else {
292
304
  repository = await readline.question(`Enter docker repository (e.g registry/username/${manifest.id || path.basename(sourceDir)}): `, {});
293
305
  if (!repository) exit('No repository provided');
@@ -303,7 +315,7 @@ async function build(localOptions, cmd) {
303
315
 
304
316
  appConfig.gitCommit = execSync('git rev-parse HEAD', { encoding: 'utf8' }).trim(); // when the build gets saved, save the gitCommit also
305
317
  if (buildServiceConfig.type === 'remote' && buildServiceConfig.url) {
306
- await buildRemote(manifest, sourceDir, appConfig, options);
318
+ await buildRemote(manifest, sourceDir, appConfig, options, buildServiceConfig);
307
319
  } else {
308
320
  await buildLocal(manifest, sourceDir, appConfig, options);
309
321
  }
@@ -312,7 +324,7 @@ async function build(localOptions, cmd) {
312
324
  async function logs(localOptions, cmd) {
313
325
  const options = cmd.optsWithGlobals();
314
326
 
315
- const buildServiceConfig = config.getBuildServiceConfig();
327
+ const buildServiceConfig = getEffectiveBuildServiceConfig(options);
316
328
  if (buildServiceConfig.type !== 'remote') return exit('This command only works with the build service. Use cloudron build login first.');
317
329
 
318
330
  if (!options.id) return exit('buildId is required');
@@ -324,7 +336,7 @@ async function logs(localOptions, cmd) {
324
336
  async function status(localOptions, cmd) {
325
337
  const options = cmd.optsWithGlobals();
326
338
 
327
- const buildServiceConfig = config.getBuildServiceConfig();
339
+ const buildServiceConfig = getEffectiveBuildServiceConfig(options);
328
340
  if (buildServiceConfig.type !== 'remote') return exit('This command only works with the build service. Use cloudron build login first.');
329
341
 
330
342
  if (!options.id) return exit('buildId is required');
@@ -337,7 +349,7 @@ async function status(localOptions, cmd) {
337
349
  async function push(localOptions, cmd) {
338
350
  const options = cmd.optsWithGlobals();
339
351
 
340
- const buildServiceConfig = config.getBuildServiceConfig();
352
+ const buildServiceConfig = getEffectiveBuildServiceConfig(options);
341
353
  if (buildServiceConfig.type !== 'remote') return exit('This command only works with the build service. Use cloudron build login first.');
342
354
 
343
355
  if (!options.id) return exit('buildId is required');
@@ -377,10 +389,10 @@ async function clear(/* localOptions, cmd */) {
377
389
  config.unsetAppBuildConfig(sourceDir);
378
390
  }
379
391
 
380
- async function info(/* localOptions, cmd */) {
381
- // const options = cmd.optsWithGlobals();
392
+ async function info(localOptions, cmd) {
393
+ const options = cmd.optsWithGlobals();
382
394
 
383
- const buildService = config.getBuildServiceConfig();
395
+ const buildService = getEffectiveBuildServiceConfig(options);
384
396
  console.log(`Build service type: ${buildService.type || 'local'}`);
385
397
  if (buildService.type === 'remote') console.log(`Build service URL: ${buildService.url}`);
386
398