lowdefy 4.0.0-alpha.1 → 4.0.0-alpha.7

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.
Files changed (33) hide show
  1. package/dist/commands/build/build.js +21 -19
  2. package/dist/commands/build/installServer.js +43 -0
  3. package/dist/commands/build/runLowdefyBuild.js +43 -0
  4. package/dist/commands/build/runNextBuild.js +36 -0
  5. package/dist/commands/dev/dev.js +9 -57
  6. package/dist/commands/dev/installServer.js +43 -0
  7. package/dist/commands/dev/runDevServer.js +39 -0
  8. package/dist/commands/init/init.js +5 -11
  9. package/dist/commands/init/lowdefyFile.js +1 -1
  10. package/dist/commands/start/runStart.js +36 -0
  11. package/dist/{utils/checkChildProcessError.js → commands/start/start.js} +11 -6
  12. package/dist/index.js +23 -56
  13. package/dist/utils/BatchChanges.js +24 -11
  14. package/dist/utils/checkForUpdatedVersions.js +11 -0
  15. package/dist/utils/{print.js → createPrint.js} +1 -0
  16. package/dist/utils/errorHandler.js +2 -3
  17. package/dist/utils/fetchNpmTarball.js +2 -1
  18. package/dist/utils/getCliJson.js +5 -8
  19. package/dist/utils/getDirectories.js +9 -5
  20. package/dist/utils/getLowdefyYaml.js +10 -12
  21. package/dist/utils/getPackageManager.js +54 -0
  22. package/dist/utils/getSendTelemetry.js +17 -8
  23. package/dist/utils/getServer.js +45 -0
  24. package/dist/utils/runCommand.js +22 -23
  25. package/dist/utils/startUp.js +6 -6
  26. package/package.json +15 -18
  27. package/dist/commands/dev/buildWatcher.js +0 -48
  28. package/dist/commands/dev/envWatcher.js +0 -32
  29. package/dist/commands/dev/getBuild.js +0 -37
  30. package/dist/commands/dev/getExpress.js +0 -71
  31. package/dist/commands/dev/getGraphQL.js +0 -39
  32. package/dist/commands/dev/prepare.js +0 -27
  33. package/dist/commands/dev/versionWatcher.js +0 -36
@@ -12,29 +12,31 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import path from 'path';
16
- import fse from 'fs-extra';
17
- import getFederatedModule from '../../utils/getFederatedModule';
15
+ */ import getServer from '../../utils/getServer.js';
16
+ import installServer from './installServer.js';
17
+ import runLowdefyBuild from './runLowdefyBuild.js';
18
+ import runNextBuild from './runNextBuild.js';
18
19
  async function build({ context }) {
19
- const { default: buildScript } = await getFederatedModule({
20
- module: 'build',
21
- packageName: '@lowdefy/build',
22
- version: context.lowdefyVersion,
20
+ context.print.info('Starting build.');
21
+ await getServer({
22
+ context,
23
+ packageName: '@lowdefy/server'
24
+ });
25
+ await installServer({
23
26
  context
24
27
  });
25
- context.print.log(`Cleaning block meta cache at "${path.resolve(context.cacheDirectory, './meta')}".`);
26
- await fse.emptyDir(path.resolve(context.cacheDirectory, './meta'));
27
- context.print.info('Starting build.');
28
- await buildScript({
29
- blocksServerUrl: context.options.blocksServerUrl,
30
- buildDirectory: context.buildDirectory,
31
- cacheDirectory: context.cacheDirectory,
32
- configDirectory: context.baseDirectory,
33
- logger: context.print,
34
- refResolver: context.options.refResolver
28
+ await runLowdefyBuild({
29
+ context
30
+ });
31
+ await installServer({
32
+ context
33
+ });
34
+ await runNextBuild({
35
+ context
36
+ });
37
+ await context.sendTelemetry({
38
+ sendTypes: true
35
39
  });
36
- await context.sendTelemetry();
37
- context.print.log(`Build artifacts saved at ${context.buildDirectory}.`);
38
40
  context.print.succeed(`Build successful.`);
39
41
  }
40
42
  export default build;
@@ -0,0 +1,43 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ const args = {
17
+ npm: [
18
+ 'install',
19
+ '--legacy-peer-deps'
20
+ ],
21
+ yarn: [
22
+ 'install'
23
+ ]
24
+ };
25
+ async function installServer({ context }) {
26
+ context.print.spin(`Running ${context.packageManager} install.`);
27
+ try {
28
+ await spawnProcess({
29
+ logger: context.print,
30
+ command: context.packageManager,
31
+ args: args[context.packageManager],
32
+ processOptions: {
33
+ cwd: context.directories.server
34
+ },
35
+ silent: false
36
+ });
37
+ } catch (error) {
38
+ console.log(error);
39
+ throw new Error(`${context.packageManager} install failed.`);
40
+ }
41
+ context.print.log(`${context.packageManager} install successful.`);
42
+ }
43
+ export default installServer;
@@ -0,0 +1,43 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ async function runLowdefyBuild({ context }) {
17
+ context.print.log('Running Lowdefy build.');
18
+ try {
19
+ await spawnProcess({
20
+ logger: context.print,
21
+ command: context.packageManager,
22
+ args: [
23
+ 'run',
24
+ 'build:lowdefy'
25
+ ],
26
+ processOptions: {
27
+ cwd: context.directories.server,
28
+ env: {
29
+ ...process.env,
30
+ LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
31
+ LOWDEFY_DIRECTORY_BUILD: context.directories.build,
32
+ LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
33
+ LOWDEFY_DIRECTORY_SERVER: context.directories.server
34
+ }
35
+ },
36
+ silent: false
37
+ });
38
+ } catch (error) {
39
+ throw new Error('Lowdefy build failed.');
40
+ }
41
+ context.print.log('Lowdefy build successful.');
42
+ }
43
+ export default runLowdefyBuild;
@@ -0,0 +1,36 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ async function runNextBuild({ context }) {
17
+ context.print.log('Running Next build.');
18
+ try {
19
+ await spawnProcess({
20
+ logger: context.print,
21
+ command: context.packageManager,
22
+ args: [
23
+ 'run',
24
+ 'build:next'
25
+ ],
26
+ processOptions: {
27
+ cwd: context.directories.server
28
+ },
29
+ silent: false
30
+ });
31
+ } catch (error) {
32
+ throw new Error('Next build failed.');
33
+ }
34
+ context.print.log('Next build successful.');
35
+ }
36
+ export default runNextBuild;
@@ -12,69 +12,21 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ import opener from 'opener';
16
- import buildWatcher from './buildWatcher.js';
17
- import envWatcher from './envWatcher.js';
18
- import getBuild from './getBuild.js';
19
- import getExpress from './getExpress.js';
20
- import getGraphQL from './getGraphQL.js';
21
- import prepare from './prepare.js';
22
- import versionWatcher from './versionWatcher.js';
23
- async function initialBuild({ context }) {
24
- const build = await getBuild({
25
- context
26
- });
27
- try {
28
- await build();
29
- // eslint-disable-next-line no-empty
30
- } catch (error) {
31
- }
32
- return build;
33
- }
34
- async function serverSetup({ context }) {
35
- const gqlServer = await getGraphQL({
36
- context
37
- });
38
- return getExpress({
39
- context,
40
- gqlServer
41
- });
42
- }
15
+ */ import installServer from './installServer.js';
16
+ import runDevServer from './runDevServer.js';
17
+ import getServer from '../../utils/getServer.js';
43
18
  async function dev({ context }) {
44
- await prepare({
45
- context
46
- });
47
- const initialBuildPromise = initialBuild({
48
- context
49
- });
50
- const serverSetupPromise = serverSetup({
51
- context
52
- });
53
- const [build, { expressApp , reloadFn }] = await Promise.all([
54
- initialBuildPromise,
55
- serverSetupPromise,
56
- ]);
57
- buildWatcher({
58
- build,
19
+ context.print.info('Starting development server.');
20
+ await getServer({
59
21
  context,
60
- reloadFn
22
+ packageName: '@lowdefy/server-dev'
61
23
  });
62
- envWatcher({
24
+ await installServer({
63
25
  context
64
26
  });
65
- versionWatcher({
27
+ context.sendTelemetry();
28
+ await runDevServer({
66
29
  context
67
30
  });
68
- context.print.log('Starting Lowdefy development server.');
69
- const port = expressApp.get('port');
70
- expressApp.listen(port, function() {
71
- context.print.info(`Development server listening on port ${port}`);
72
- });
73
- opener(`http://localhost:${port}`);
74
- await context.sendTelemetry({
75
- data: {
76
- type: 'startup'
77
- }
78
- });
79
31
  }
80
32
  export default dev;
@@ -0,0 +1,43 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ const args = {
17
+ npm: [
18
+ 'install',
19
+ '--legacy-peer-deps'
20
+ ],
21
+ yarn: [
22
+ 'install'
23
+ ]
24
+ };
25
+ async function installServer({ context }) {
26
+ context.print.spin(`Running ${context.packageManager} install.`);
27
+ try {
28
+ await spawnProcess({
29
+ logger: context.print,
30
+ command: context.packageManager,
31
+ args: args[context.packageManager],
32
+ processOptions: {
33
+ cwd: context.directories.dev
34
+ },
35
+ silent: false
36
+ });
37
+ } catch (error) {
38
+ console.log(error);
39
+ throw new Error(`${context.packageManager} install failed.`);
40
+ }
41
+ context.print.log(`${context.packageManager} install successful.`);
42
+ }
43
+ export default installServer;
@@ -0,0 +1,39 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ async function runDevServer({ context }) {
17
+ await spawnProcess({
18
+ logger: context.print,
19
+ args: [
20
+ 'run',
21
+ 'start'
22
+ ],
23
+ command: context.packageManager,
24
+ processOptions: {
25
+ cwd: context.directories.dev,
26
+ env: {
27
+ ...process.env,
28
+ LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
29
+ LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
30
+ LOWDEFY_PACKAGE_MANAGER: context.packageManager,
31
+ LOWDEFY_SERVER_DEV_WATCH: JSON.stringify(context.options.watch),
32
+ LOWDEFY_SERVER_DEV_WATCH_IGNORE: JSON.stringify(context.options.watchIgnore),
33
+ PORT: context.options.port
34
+ }
35
+ },
36
+ silent: false
37
+ });
38
+ }
39
+ export default runDevServer;
@@ -23,18 +23,12 @@ async function init({ context }) {
23
23
  throw new Error('Cannot initialize a Lowdefy project, a "lowdefy.yaml" file already exists');
24
24
  }
25
25
  context.print.log(`Initializing Lowdefy project`);
26
- await writeFile({
27
- filePath: lowdefyFilePath,
28
- content: lowdefyFile({
29
- version: context.cliVersion
30
- })
31
- });
26
+ await writeFile(lowdefyFilePath, lowdefyFile({
27
+ version: context.cliVersion
28
+ }));
32
29
  context.print.log(`Created 'lowdefy.yaml'.`);
33
- await writeFile({
34
- filePath: path.resolve('./.gitignore'),
35
- content: `.lowdefy/**
36
- .env`
37
- });
30
+ await writeFile(path.resolve('./.gitignore'), `.lowdefy/**
31
+ .env`);
38
32
  context.print.log(`Created '.gitignore'.`);
39
33
  await context.sendTelemetry();
40
34
  context.print.succeed(`Project initialized.`);
@@ -36,7 +36,7 @@ pages:
36
36
  title: Welcome to your Lowdefy app
37
37
  subTitle: We are excited to see what you are going to build
38
38
  icon:
39
- name: HeartTwoTone
39
+ name: AiTwoToneHeart
40
40
  color: '#f00'
41
41
  areas:
42
42
  extra:
@@ -0,0 +1,36 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import { spawnProcess } from '@lowdefy/node-utils';
16
+ async function runStart({ context }) {
17
+ context.print.spin(`Running "${context.packageManager} run start".`);
18
+ await spawnProcess({
19
+ logger: context.print,
20
+ args: [
21
+ 'run',
22
+ 'start'
23
+ ],
24
+ command: context.packageManager,
25
+ processOptions: {
26
+ cwd: context.directories.server,
27
+ env: {
28
+ ...process.env,
29
+ LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
30
+ PORT: context.options.port
31
+ }
32
+ },
33
+ silent: false
34
+ });
35
+ }
36
+ export default runStart;
@@ -12,10 +12,15 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function checkChildProcessError({ context , processOutput , message }) {
16
- if (processOutput.status === 1) {
17
- context.print.error(processOutput.stderr.toString('utf8'));
18
- throw new Error(message);
19
- }
15
+ */ import runStart from './runStart.js';
16
+ // TODO: Handle "spawn yarn ENOENT" error if no built server exists.
17
+ async function build({ context }) {
18
+ context.print.info('Starting server.');
19
+ context.sendTelemetry({
20
+ sendTypes: true
21
+ });
22
+ await runStart({
23
+ context
24
+ });
20
25
  }
21
- export default checkChildProcessError;
26
+ export default build;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  /*
2
3
  Copyright 2020-2021 Lowdefy, Inc
3
4
 
@@ -13,64 +14,30 @@
13
14
  See the License for the specific language governing permissions and
14
15
  limitations under the License.
15
16
  */ import { readFile } from '@lowdefy/node-utils';
16
- import program from 'commander';
17
- // import build from './commands/build/build.js';
18
- // import dev from './commands/dev/dev.js';
17
+ import { Command } from 'commander';
18
+ import build from './commands/build/build.js';
19
+ import dev from './commands/dev/dev.js';
19
20
  import init from './commands/init/init.js';
21
+ import start from './commands/start/start.js';
20
22
  import runCommand from './utils/runCommand.js';
21
23
  const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url).pathname));
22
- const { description , version } = packageJson;
23
- program.name('lowdefy').description(description).version(version, '-v, --version');
24
- // program
25
- // .command('build')
26
- // .description('Build a Lowdefy deployment.')
27
- // .usage(`[options]`)
28
- // .option(
29
- // '--base-directory <base-directory>',
30
- // 'Change base directory. Default is the current working directory.'
31
- // )
32
- // .option(
33
- // '--blocks-server-url <blocks-server-url>',
34
- // 'The URL from where Lowdefy blocks will be served.'
35
- // )
36
- // .option('--disable-telemetry', 'Disable telemetry.')
37
- // .option(
38
- // '--output-directory <output-directory>',
39
- // 'Change the directory to which build artifacts are saved. Default is "<base-directory>/.lowdefy/build".'
40
- // )
41
- // .option(
42
- // '--ref-resolver <ref-resolver-function-path>',
43
- // 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.'
44
- // )
45
- // .action(runCommand(build));
46
- // program
47
- // .command('dev')
48
- // .description('Start a Lowdefy development server.')
49
- // .usage(`[options]`)
50
- // .option(
51
- // '--base-directory <base-directory>',
52
- // 'Change base directory. Default is the current working directory.'
53
- // )
54
- // .option(
55
- // '--blocks-server-url <blocks-server-url>',
56
- // 'The URL from where Lowdefy blocks will be served.'
57
- // )
58
- // .option('--disable-telemetry', 'Disable telemetry.')
59
- // .option('--port <port>', 'Change the port the server is hosted at. Default is 3000.')
60
- // .option(
61
- // '--ref-resolver <ref-resolver-function-path>',
62
- // 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.'
63
- // )
64
- // .option(
65
- // '--watch <paths...>',
66
- // 'A list of paths to files or directories that should be watched for changes.'
67
- // )
68
- // .option(
69
- // '--watch-ignore <paths...>',
70
- // 'A list of paths to files or directories that should be ignored by the file watcher. Globs are supported.'
71
- // )
72
- // .action(runCommand(dev));
24
+ const { description , version: cliVersion } = packageJson;
25
+ const program = new Command();
26
+ program.name('lowdefy').description(description).version(cliVersion, '-v, --version');
27
+ program.command('build').description('Build a Lowdefy production app.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--output-directory <output-directory>', 'Change the directory to which build artifacts are saved. Default is "<config-directory>/.lowdefy".').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--ref-resolver <ref-resolver-function-path>', 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.').option('--server-directory <server-directory>', 'Change the server directory. Default is "<config-directory>/.lowdefy/server".').action(runCommand({
28
+ cliVersion,
29
+ handler: build
30
+ }));
31
+ program.command('dev').description('Start a Lowdefy development server.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--port <port>', 'Change the port the development server is hosted at. Default is 3000.').option('--ref-resolver <ref-resolver-function-path>', 'Path to a JavaScript file containing a _ref resolver function to be used as the app default _ref resolver.').option('--watch <paths...>', 'A list of paths to files or directories that should be watched for changes. Globs are supported. Specify each path to watch separated by spaces.').option('--watch-ignore <paths...>', 'A list of paths to files or directories that should be ignored by the file watcher. Globs are supported. Specify each path to watch separated by spaces.').option('--dev-directory <dev-directory>', 'Change the development server directory. Default is "<config-directory>/.lowdefy/dev".').action(runCommand({
32
+ cliVersion,
33
+ handler: dev
34
+ }));
73
35
  program.command('init').description('Initialize a Lowdefy project.').usage(`[options]`).action(runCommand({
74
- cliVersion: version
75
- })(init));
36
+ cliVersion,
37
+ handler: init
38
+ }));
39
+ program.command('start').description('Start a Lowdefy production app.').usage(`[options]`).option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').option('--disable-telemetry', 'Disable telemetry.').option('--output-directory <output-directory>', 'Change the directory to which build artifacts are saved. Default is "<config-directory>/.lowdefy".').option('--package-manager <package-manager>', 'The package manager to use. Options are "npm" or "yarn".').option('--port <port>', 'Change the port the server is hosted at. Default is 3000.').option('--server-directory <server-directory>', 'Change the server directory. Default is "<config-directory>/.lowdefy/server".').action(runCommand({
40
+ cliVersion,
41
+ handler: start
42
+ }));
76
43
  program.parse(process.argv);
@@ -13,7 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ let BatchChanges = class BatchChanges {
16
- newChange() {
16
+ newChange(...args) {
17
+ this.args.push(args);
17
18
  this.delay = this.minDelay;
18
19
  this._startTimer();
19
20
  }
@@ -21,28 +22,40 @@
21
22
  if (this.timer) {
22
23
  clearTimeout(this.timer);
23
24
  }
24
- this.timer = setTimeout(this._call, this.delay);
25
+ if (this.running) {
26
+ this.repeat = true;
27
+ } else {
28
+ this.timer = setTimeout(this._call, this.delay);
29
+ }
25
30
  }
26
31
  async _call() {
32
+ this.running = true;
27
33
  try {
28
- await this.fn();
34
+ const args = this.args;
35
+ this.args = [];
36
+ await this.fn(args);
37
+ this.running = false;
38
+ if (this.repeat) {
39
+ this.repeat = false;
40
+ this._call();
41
+ }
29
42
  } catch (error) {
30
- this.context.print.error(error.message, {
31
- timestamp: true
32
- });
43
+ this.running = false;
44
+ this.context.print.error(error.message);
33
45
  this.delay *= 2;
34
- this.context.print.warn(`Retrying in ${this.delay / 1000}s.`, {
35
- timestamp: true
36
- });
46
+ this.context.print.warn(`Retrying in ${this.delay / 1000}s.`);
37
47
  this._startTimer();
38
48
  }
39
49
  }
40
50
  constructor({ fn , context , minDelay }){
41
- this.fn = fn;
51
+ this._call = this._call.bind(this);
52
+ this.args = [];
42
53
  this.context = context;
43
54
  this.delay = minDelay || 500;
55
+ this.fn = fn;
44
56
  this.minDelay = minDelay || 500;
45
- this._call = this._call.bind(this);
57
+ this.repeat = false;
58
+ this.running = false;
46
59
  }
47
60
  };
48
61
  export default BatchChanges;
@@ -14,6 +14,14 @@
14
14
  limitations under the License.
15
15
  */ import axios from 'axios';
16
16
  async function checkForUpdatedVersions({ cliVersion , lowdefyVersion , print }) {
17
+ if (isExperimentalVersion(cliVersion) || isExperimentalVersion(lowdefyVersion)) {
18
+ print.warn(`
19
+ ---------------------------------------------------
20
+ You are using an experimental version of Lowdefy.
21
+ Features may change at any time.
22
+ ---------------------------------------------------`);
23
+ return;
24
+ }
17
25
  const registryUrl = 'https://registry.npmjs.org/lowdefy';
18
26
  try {
19
27
  const packageInfo = await axios.get(registryUrl);
@@ -39,4 +47,7 @@ async function checkForUpdatedVersions({ cliVersion , lowdefyVersion , print })
39
47
  print.warn('Failed to check for latest Lowdefy version.');
40
48
  }
41
49
  }
50
+ function isExperimentalVersion(version) {
51
+ return version.includes('alpha') || version.includes('beta') || version.includes('rc');
52
+ }
42
53
  export default checkForUpdatedVersions;
@@ -60,6 +60,7 @@ function createBasicPrint() {
60
60
  // Memoise print so that error handler can get the same spinner object
61
61
  let print;
62
62
  function createPrint() {
63
+ // TODO: Add debug
63
64
  if (print) return print;
64
65
  if (process.env.CI === 'true') {
65
66
  print = createBasicPrint();
@@ -13,9 +13,8 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import axios from 'axios';
16
- import createPrint from './print.js';
17
- async function logError({ error , context ={
18
- } }) {
16
+ import createPrint from './createPrint.js';
17
+ async function logError({ error , context ={} }) {
19
18
  try {
20
19
  await axios.request({
21
20
  method: 'post',
@@ -49,7 +49,8 @@ async function fetchNpmTarball({ packageName , version , directory }) {
49
49
  await decompress(tarball.data, directory, {
50
50
  plugins: [
51
51
  decompressTargz()
52
- ]
52
+ ],
53
+ strip: 1
53
54
  });
54
55
  }
55
56
  export default fetchNpmTarball;