lowdefy 4.0.0-alpha.12 → 4.0.0-alpha.15

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.
@@ -16,10 +16,12 @@
16
16
  import copyPluginsFolder from '../../utils/copyPluginsFolder.js';
17
17
  import getServer from '../../utils/getServer.js';
18
18
  import installServer from '../../utils/installServer.js';
19
+ import readDotEnv from '../../utils/readDotEnv.js';
19
20
  import runLowdefyBuild from '../../utils/runLowdefyBuild.js';
20
21
  import runNextBuild from '../../utils/runNextBuild.js';
21
22
  async function build({ context }) {
22
23
  context.print.info('Starting build.');
24
+ readDotEnv(context);
23
25
  const directory = context.directories.server;
24
26
  await getServer({
25
27
  context,
@@ -46,10 +48,12 @@ async function build({ context }) {
46
48
  context,
47
49
  directory
48
50
  });
49
- await runNextBuild({
50
- context,
51
- directory
52
- });
51
+ if (context.options.nextBuild !== false) {
52
+ await runNextBuild({
53
+ context,
54
+ directory
55
+ });
56
+ }
53
57
  await context.sendTelemetry({
54
58
  sendTypes: true
55
59
  });
@@ -28,6 +28,7 @@ async function runDevServer({ context , directory }) {
28
28
  LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
29
29
  LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
30
30
  LOWDEFY_PACKAGE_MANAGER: context.packageManager,
31
+ LOWDEFY_SERVER_DEV_OPEN_BROWSER: !!context.options.open,
31
32
  LOWDEFY_SERVER_DEV_WATCH: JSON.stringify(context.options.watch),
32
33
  LOWDEFY_SERVER_DEV_WATCH_IGNORE: JSON.stringify(context.options.watchIgnore),
33
34
  PORT: context.options.port
@@ -63,5 +63,4 @@ pages:
63
63
  content: |
64
64
  Made by a Lowdefy 🤖
65
65
 
66
- `
67
- );
66
+ `);
@@ -26,7 +26,6 @@ async function runStart({ context , directory }) {
26
26
  cwd: directory,
27
27
  env: {
28
28
  ...process.env,
29
- LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
30
29
  PORT: context.options.port
31
30
  }
32
31
  },
@@ -13,12 +13,14 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import runStart from './runStart.js';
16
+ import readDotEnv from '../../utils/readDotEnv.js';
16
17
  // TODO: Handle "spawn yarn ENOENT" error if no built server exists.
17
18
  async function build({ context }) {
18
19
  context.print.info('Starting server.');
19
20
  context.sendTelemetry({
20
21
  sendTypes: true
21
22
  });
23
+ readDotEnv(context);
22
24
  await runStart({
23
25
  context,
24
26
  directory: context.directories.server
package/dist/index.js CHANGED
@@ -13,23 +13,23 @@
13
13
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
- */ import { fileURLToPath } from 'url';
17
- import { readFile } from '@lowdefy/node-utils';
16
+ */ import { createRequire } from 'module';
18
17
  import { Command } from 'commander';
19
18
  import build from './commands/build/build.js';
20
19
  import dev from './commands/dev/dev.js';
21
20
  import init from './commands/init/init.js';
22
21
  import start from './commands/start/start.js';
23
22
  import runCommand from './utils/runCommand.js';
24
- const packageJson = JSON.parse(await readFile(fileURLToPath(new URL('../package.json', import.meta.url))));
23
+ const require = createRequire(import.meta.url);
24
+ const packageJson = require('../package.json');
25
25
  const { description , version: cliVersion } = packageJson;
26
26
  const program = new Command();
27
27
  program.name('lowdefy').description(description).version(cliVersion, '-v, --version');
28
- 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
+ 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('--no-next-build', 'Do not build the Next.js server.').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({
29
29
  cliVersion,
30
30
  handler: build
31
31
  }));
32
- 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
+ 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('--no-open', 'Do not open a new tab in the default browser.').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({
33
33
  cliVersion,
34
34
  handler: dev
35
35
  }));
@@ -37,7 +37,7 @@ program.command('init').description('Initialize a Lowdefy project.').usage(`[opt
37
37
  cliVersion,
38
38
  handler: init
39
39
  }));
40
- 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
+ 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('--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({
41
41
  cliVersion,
42
42
  handler: start
43
43
  }));
@@ -24,24 +24,18 @@ function getTime() {
24
24
  function createOraPrint() {
25
25
  const spinner = ora({
26
26
  spinner: 'random',
27
- prefixText: ()=>chalk.dim(getTime())
28
- ,
27
+ prefixText: ()=>chalk.dim(getTime()),
29
28
  color: 'blue'
30
29
  });
31
30
  return {
32
31
  type: 'ora',
33
- error: (text)=>spinner.fail(chalk.red(text))
34
- ,
35
- info: (text)=>spinner.info(chalk.blue(text))
36
- ,
32
+ error: (text)=>spinner.fail(chalk.red(text)),
33
+ info: (text)=>spinner.info(chalk.blue(text)),
37
34
  log: (text)=>spinner.start(text).stopAndPersist({
38
35
  symbol: '∙'
39
- })
40
- ,
41
- spin: (text)=>spinner.start(text)
42
- ,
43
- succeed: (text)=>spinner.succeed(chalk.green(text))
44
- ,
36
+ }),
37
+ spin: (text)=>spinner.start(text),
38
+ succeed: (text)=>spinner.succeed(chalk.green(text)),
45
39
  warn: (text)=>spinner.warn(chalk.yellow(text))
46
40
  };
47
41
  }
@@ -62,7 +56,7 @@ let print;
62
56
  function createPrint() {
63
57
  // TODO: Add debug
64
58
  if (print) return print;
65
- if (process.env.CI === 'true') {
59
+ if (process.env.CI === 'true' || process.env.CI === '1') {
66
60
  print = createBasicPrint();
67
61
  return print;
68
62
  }
@@ -14,17 +14,14 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  function getDirectories({ configDirectory , options }) {
17
- let dotLowdefy;
18
- if (options.outputDirectory) {
19
- dotLowdefy = path.resolve(options.outputDirectory);
20
- } else {
21
- dotLowdefy = path.resolve(configDirectory, '.lowdefy');
22
- }
17
+ const dotLowdefy = path.resolve(configDirectory, '.lowdefy');
18
+ const server = options.serverDirectory ? path.resolve(options.serverDirectory) : path.join(dotLowdefy, 'server');
19
+ // TODO: Read server directory from env var
20
+ // Priority should be CLI arguments, env var, CLI options in Lowdefy config
23
21
  return {
24
22
  config: configDirectory,
25
- build: path.join(dotLowdefy, 'server', 'build'),
26
- dotLowdefy,
27
- server: options.serverDirectory ? path.resolve(options.serverDirectory) : path.join(dotLowdefy, 'server'),
23
+ build: path.join(server, 'build'),
24
+ server,
28
25
  dev: options.devDirectory ? path.resolve(options.devDirectory) : path.join(dotLowdefy, 'dev')
29
26
  };
30
27
  }
@@ -0,0 +1,23 @@
1
+ /*
2
+ Copyright 2020-2022 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 path from 'path';
16
+ import dotenv from 'dotenv';
17
+ function readDotEnv(context) {
18
+ dotenv.config({
19
+ path: path.join(context.directories.config, '.env'),
20
+ silent: true
21
+ });
22
+ }
23
+ export default readDotEnv;
@@ -21,17 +21,15 @@ async function runLowdefyBuild({ context , directory }) {
21
21
  command: context.packageManagerCmd,
22
22
  args: [
23
23
  'run',
24
- 'build:lowdefy'
24
+ 'build:lowdefy',
25
+ '--ref-resolver',
26
+ context.options.refResolver,
27
+ '--config-directory',
28
+ context.directories.config,
25
29
  ],
26
30
  processOptions: {
27
31
  cwd: directory,
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
- }
32
+ env: process.env
35
33
  },
36
34
  silent: false
37
35
  });
@@ -26,7 +26,7 @@ async function startUp({ context , options ={} , command }) {
26
26
  context.command = command.name();
27
27
  context.commandLineOptions = options;
28
28
  context.print = createPrint();
29
- context.configDirectory = path.resolve(options.configDirectory || process.cwd());
29
+ context.configDirectory = path.resolve(options.configDirectory || process.env.LOWDEFY_DIRECTORY_CONFIG || process.cwd());
30
30
  const { cliConfig , lowdefyVersion , plugins } = await getLowdefyYaml(context);
31
31
  context.cliConfig = cliConfig;
32
32
  context.lowdefyVersion = lowdefyVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lowdefy",
3
- "version": "4.0.0-alpha.12",
3
+ "version": "4.0.0-alpha.15",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy CLI",
6
6
  "homepage": "https://lowdefy.com",
@@ -40,26 +40,27 @@
40
40
  "test": "FORCE_COLOR=3 yarn node --experimental-vm-modules $(yarn bin jest)"
41
41
  },
42
42
  "dependencies": {
43
- "@lowdefy/helpers": "4.0.0-alpha.12",
44
- "@lowdefy/node-utils": "4.0.0-alpha.12",
45
- "axios": "0.25.0",
43
+ "@lowdefy/helpers": "4.0.0-alpha.15",
44
+ "@lowdefy/node-utils": "4.0.0-alpha.15",
45
+ "axios": "0.27.2",
46
46
  "chalk": "4.1.2",
47
47
  "commander": "9.0.0",
48
48
  "decompress": "4.2.1",
49
49
  "decompress-targz": "4.1.1",
50
+ "dotenv": "16.0.1",
50
51
  "ora": "5.4.1",
51
52
  "uuid": "8.3.2",
52
- "yaml": "2.0.0-10"
53
+ "yaml": "2.1.1"
53
54
  },
54
55
  "devDependencies": {
55
- "@jest/globals": "27.5.1",
56
- "@swc/cli": "0.1.55",
57
- "@swc/core": "1.2.135",
58
- "@swc/jest": "0.2.17",
59
- "jest": "27.5.1"
56
+ "@jest/globals": "28.1.0",
57
+ "@swc/cli": "0.1.57",
58
+ "@swc/core": "1.2.194",
59
+ "@swc/jest": "0.2.21",
60
+ "jest": "28.1.0"
60
61
  },
61
62
  "publishConfig": {
62
63
  "access": "public"
63
64
  },
64
- "gitHead": "41b6138a81bee7da362dad06345bc9f87b2c2133"
65
+ "gitHead": "b4e4538475e997f95baa37f01f39689240e6f01c"
65
66
  }