lowdefy 4.0.0-rc.9 → 4.0.0

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.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,17 +15,19 @@
15
15
  */ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js';
16
16
  import getServer from '../../utils/getServer.js';
17
17
  import installServer from '../../utils/installServer.js';
18
- import readDotEnv from '../../utils/readDotEnv.js';
19
18
  import resetServerPackageJson from '../../utils/resetServerPackageJson.js';
20
19
  import runLowdefyBuild from '../../utils/runLowdefyBuild.js';
21
20
  import runNextBuild from '../../utils/runNextBuild.js';
22
- async function build({ context }) {
21
+ async function build({ context }) {
23
22
  context.print.info('Starting build.');
24
- readDotEnv(context);
25
23
  const directory = context.directories.server;
24
+ let packageName = '@lowdefy/server-community';
25
+ if (!context.options.communityEdition) {
26
+ packageName = '@lowdefy/server-enterprise';
27
+ }
26
28
  await getServer({
27
29
  context,
28
- packageName: '@lowdefy/server',
30
+ packageName,
29
31
  directory
30
32
  });
31
33
  await resetServerPackageJson({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ import installServer from '../../utils/installServer.js';
17
17
  import resetServerPackageJson from '../../utils/resetServerPackageJson.js';
18
18
  import runDevServer from './runDevServer.js';
19
19
  import getServer from '../../utils/getServer.js';
20
- async function dev({ context }) {
20
+ async function dev({ context }) {
21
21
  const directory = context.directories.dev;
22
22
  context.print.info('Starting development server.');
23
23
  await getServer({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { spawnProcess } from '@lowdefy/node-utils';
16
16
  import createStdOutLineHandler from '../../utils/createStdOutLineHandler.js';
17
- async function runDevServer({ context , directory }) {
17
+ async function runDevServer({ context, directory }) {
18
18
  await spawnProcess({
19
19
  args: [
20
20
  'run',
@@ -31,10 +31,12 @@ async function runDevServer({ context , directory }) {
31
31
  LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
32
32
  LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
33
33
  LOWDEFY_LOG_LEVEL: context.options.logLevel,
34
+ LOWDEFY_LICENSE_ENTITLEMENTS: JSON.stringify(context.license.entitlements),
34
35
  LOWDEFY_SERVER_DEV_OPEN_BROWSER: !!context.options.open,
35
36
  LOWDEFY_SERVER_DEV_WATCH: JSON.stringify(context.options.watch),
36
37
  LOWDEFY_SERVER_DEV_WATCH_IGNORE: JSON.stringify(context.options.watchIgnore),
37
- PORT: context.options.port
38
+ PORT: context.options.port,
39
+ NEXT_TELEMETRY_DISABLED: context.options.disableTelemetry ? '1' : undefined
38
40
  }
39
41
  },
40
42
  silent: false
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -16,21 +16,21 @@
16
16
  import fs from 'fs';
17
17
  import { writeFile } from '@lowdefy/node-utils';
18
18
  import lowdefyFile from './lowdefyFile.js';
19
- async function init({ context }) {
19
+ async function init({ context }) {
20
20
  const lowdefyFilePath = path.resolve('./lowdefy.yaml');
21
21
  const fileExists = fs.existsSync(lowdefyFilePath);
22
22
  if (fileExists) {
23
23
  throw new Error('Cannot initialize a Lowdefy project, a "lowdefy.yaml" file already exists');
24
24
  }
25
- context.print.log(`Initializing Lowdefy project.`);
25
+ context.print.log('Initializing Lowdefy project.');
26
26
  await writeFile(lowdefyFilePath, lowdefyFile({
27
27
  version: context.cliVersion
28
28
  }));
29
- context.print.log(`Created 'lowdefy.yaml'.`);
29
+ context.print.log("Created 'lowdefy.yaml'.");
30
30
  await writeFile(path.resolve('./.gitignore'), `.lowdefy/**
31
31
  .env`);
32
- context.print.log(`Created '.gitignore'.`);
32
+ context.print.log("Created '.gitignore'.");
33
33
  await context.sendTelemetry();
34
- context.print.succeed(`Project initialized.`);
34
+ context.print.succeed('Project initialized.');
35
35
  }
36
36
  export default init;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
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
- */ export default (({ version })=>`
15
+ */ export default (({ version })=>`
16
16
  lowdefy: ${version}
17
17
  name: Lowdefy starter
18
18
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,15 +15,15 @@
15
15
  */ import path from 'path';
16
16
  import url from 'url';
17
17
  import { readFile, writeFile } from '@lowdefy/node-utils';
18
- async function initDocker({ context }) {
19
- context.print.log(`Initializing Docker deployment.`);
18
+ async function initDocker({ context }) {
19
+ context.print.log('Initializing Docker deployment.');
20
20
  const dockerfile = await readFile(url.fileURLToPath(new URL('./Dockerfile', import.meta.url)));
21
21
  await writeFile(path.join(context.directories.config, 'Dockerfile'), dockerfile);
22
- context.print.log(`Created 'Dockerfile'.`);
22
+ context.print.log("Created 'Dockerfile'.");
23
23
  const dockerignore = await readFile(url.fileURLToPath(new URL('./.dockerignore', import.meta.url)));
24
24
  await writeFile(path.join(context.directories.config, '.dockerignore'), dockerignore);
25
- context.print.log(`Created '.dockerignore'.`);
25
+ context.print.log("Created '.dockerignore'.");
26
26
  await context.sendTelemetry();
27
- context.print.succeed(`Docker deployment initialized.`);
27
+ context.print.succeed('Docker deployment initialized.');
28
28
  }
29
29
  export default initDocker;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,15 +15,15 @@
15
15
  */ import path from 'path';
16
16
  import url from 'url';
17
17
  import { readFile, writeFile } from '@lowdefy/node-utils';
18
- async function initVercel({ context }) {
19
- context.print.log(`Initializing Vercel deployment.`);
18
+ async function initVercel({ context }) {
19
+ context.print.log('Initializing Vercel deployment.');
20
20
  const installScript = await readFile(url.fileURLToPath(new URL('./vercel.install.sh', import.meta.url)));
21
21
  await writeFile(path.join(context.directories.config, 'deploy', 'vercel.install.sh'), installScript);
22
- context.print.log(`Created 'vercel.install.sh'.`);
22
+ context.print.log("Created 'vercel.install.sh'.");
23
23
  const readMe = await readFile(url.fileURLToPath(new URL('./README.md', import.meta.url)));
24
24
  await writeFile(path.join(context.directories.config, 'deploy', 'README.md'), readMe);
25
- context.print.log(`Created 'README.md'.`);
25
+ context.print.log("Created 'README.md'.");
26
26
  await context.sendTelemetry();
27
- context.print.succeed(`Vercel deployment initialized.`);
27
+ context.print.succeed('Vercel deployment initialized.');
28
28
  }
29
29
  export default initVercel;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { spawnProcess } from '@lowdefy/node-utils';
16
16
  import createStdOutLineHandler from '../../utils/createStdOutLineHandler.js';
17
- async function runStart({ context , directory }) {
17
+ async function runStart({ context, directory }) {
18
18
  await spawnProcess({
19
19
  args: [
20
20
  'run',
@@ -29,7 +29,8 @@ async function runStart({ context , directory }) {
29
29
  env: {
30
30
  ...process.env,
31
31
  LOWDEFY_LOG_LEVEL: context.options.logLevel,
32
- PORT: context.options.port
32
+ PORT: context.options.port,
33
+ NEXT_TELEMETRY_DISABLED: context.options.disableTelemetry ? '1' : undefined
33
34
  }
34
35
  }
35
36
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,13 +13,11 @@
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';
17
16
  // TODO: Handle "spawn yarn ENOENT" error if no built server exists.
18
- async function build({ context }) {
17
+ async function build({ context }) {
19
18
  context.sendTelemetry({
20
19
  sendTypes: true
21
20
  });
22
- readDotEnv(context);
23
21
  const serverProcess = runStart({
24
22
  context,
25
23
  directory: context.directories.server
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
- Copyright 2020-2023 Lowdefy, Inc
3
+ Copyright 2020-2024 Lowdefy, Inc
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this file except in compliance with the License.
@@ -14,12 +14,12 @@
14
14
  See the License for the specific language governing permissions and
15
15
  limitations under the License.
16
16
  */ const nodeMajorVersion = process.version.split(/^v(\d+)/)[1];
17
- if (Number(nodeMajorVersion) < 14) {
17
+ if (Number(nodeMajorVersion) < 18) {
18
18
  // TODO: This error handled with telemetry.
19
- throw new Error(`Nodejs versions below v14 are not supported. You are using ${process.version}. Update Nodejs to the latest LTS version to use Lowdefy.`);
19
+ throw new Error(`Nodejs versions below v18 are not supported. You are using ${process.version}. Update Nodejs to the latest LTS version to use Lowdefy.`);
20
20
  }
21
21
  async function run() {
22
- const { default: program } = await import('./program.js');
22
+ const { default: program } = await import('./program.js');
23
23
  program.parse(process.argv);
24
24
  }
25
25
  run().then(()=>{});
package/dist/program.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -23,10 +23,11 @@ import start from './commands/start/start.js';
23
23
  import runCommand from './utils/runCommand.js';
24
24
  const require = createRequire(import.meta.url);
25
25
  const packageJson = require('../package.json');
26
- const { description , version: cliVersion } = packageJson;
26
+ const { description, version: cliVersion } = packageJson;
27
27
  const program = new Command();
28
28
  program.name('lowdefy').description(description).version(cliVersion, '-v, --version');
29
29
  const options = {
30
+ communityEdition: new Option('--community-edition', 'Use the Apache 2.0 licensed community edition server.').env('LOWDEFY_COMMUNITY_EDITION'),
30
31
  configDirectory: new Option('--config-directory <config-directory>', 'Change config directory. Default is the current working directory.').env('LOWDEFY_DIRECTORY_CONFIG'),
31
32
  devDirectory: new Option('--dev-directory <dev-directory>', 'Change the development server directory. Default is "<config-directory>/.lowdefy/dev".').env('LOWDEFY_DIRECTORY_DEV'),
32
33
  disableTelemetry: new Option('--disable-telemetry', 'Disable telemetry.').env('LOWDEFY_DISABLE_TELEMETRY'),
@@ -42,27 +43,27 @@ const options = {
42
43
  watch: new 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.'),
43
44
  watchIgnore: new 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.')
44
45
  };
45
- program.command('build').description('Build a Lowdefy production app.').usage(`[options]`).addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).option('--no-next-build', 'Do not build the Next.js server.').addOption(options.refResolver).addOption(options.serverDirectory).action(runCommand({
46
+ program.command('build').description('Build a Lowdefy production app.').usage('[options]').addOption(options.communityEdition).addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).option('--no-next-build', 'Do not build the Next.js server.').addOption(options.refResolver).addOption(options.serverDirectory).action(runCommand({
46
47
  cliVersion,
47
48
  handler: build
48
49
  }));
49
- program.command('dev').description('Start a Lowdefy development server.').usage(`[options]`).addOption(options.configDirectory).addOption(options.devDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).option('--no-open', 'Do not open a new tab in the default browser.').addOption(options.port).addOption(options.refResolver).addOption(options.watch).addOption(options.watchIgnore).action(runCommand({
50
+ program.command('dev').description('Start a Lowdefy development server.').usage('[options]').addOption(options.configDirectory).addOption(options.devDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).option('--no-open', 'Do not open a new tab in the default browser.').addOption(options.port).addOption(options.refResolver).addOption(options.watch).addOption(options.watchIgnore).action(runCommand({
50
51
  cliVersion,
51
52
  handler: dev
52
53
  }));
53
- program.command('init').description('Initialize a Lowdefy project.').usage(`[options]`).addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
54
+ program.command('init').description('Initialize a Lowdefy project.').usage('[options]').addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
54
55
  cliVersion,
55
56
  handler: init
56
57
  }));
57
- program.command('init-docker').description('Initialize Dockerfile.').usage(`[options]`).addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
58
+ program.command('init-docker').description('Initialize Dockerfile.').usage('[options]').addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
58
59
  cliVersion,
59
60
  handler: initDocker
60
61
  }));
61
- program.command('init-vercel').description('Initialize Vercel deployment installation scripts.').usage(`[options]`).addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
62
+ program.command('init-vercel').description('Initialize Vercel deployment installation scripts.').usage('[options]').addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).action(runCommand({
62
63
  cliVersion,
63
64
  handler: initVercel
64
65
  }));
65
- program.command('start').description('Start a Lowdefy production app.').usage(`[options]`).addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).addOption(options.port).addOption(options.serverDirectory).action(runCommand({
66
+ program.command('start').description('Start a Lowdefy production app.').usage('[options]').addOption(options.configDirectory).addOption(options.disableTelemetry).addOption(options.logLevel).addOption(options.port).addOption(options.serverDirectory).action(runCommand({
66
67
  cliVersion,
67
68
  handler: start
68
69
  }));
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { readFile, writeFile } from '@lowdefy/node-utils';
17
- async function addCustomPluginsAsDeps({ context , directory }) {
17
+ async function addCustomPluginsAsDeps({ context, directory }) {
18
18
  const packageJsonPath = path.join(directory, 'package.json');
19
19
  const packageJson = JSON.parse(await readFile(packageJsonPath));
20
20
  const dependencies = packageJson.dependencies;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { execSync } from 'child_process';
16
- function checkPnpmIsInstalled({ print , pnpmCmd }) {
16
+ function checkPnpmIsInstalled({ print, pnpmCmd }) {
17
17
  try {
18
18
  execSync(`${pnpmCmd} --version`, {
19
19
  stdio: 'ignore'
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ function filterLevels(logger, level) {
45
45
  });
46
46
  return logger;
47
47
  }
48
- function createOraPrint({ logLevel }) {
48
+ function createOraPrint({ logLevel }) {
49
49
  const spinner = ora({
50
50
  spinner: 'random',
51
51
  prefixText: ()=>dim(getTime()),
@@ -74,8 +74,8 @@ function createOraPrint({ logLevel }) {
74
74
  }
75
75
  }, logLevel);
76
76
  }
77
- function createBasicPrint({ logLevel ='info' }) {
78
- const { error , info , log , warn , debug } = console;
77
+ function createBasicPrint({ logLevel = 'info' }) {
78
+ const { error, info, log, warn, debug } = console;
79
79
  return filterLevels({
80
80
  error,
81
81
  info,
@@ -88,7 +88,7 @@ function createBasicPrint({ logLevel ='info' }) {
88
88
  }
89
89
  // Memoise print so that error handler can get the same spinner object
90
90
  let print;
91
- function createPrint({ logLevel }) {
91
+ function createPrint({ logLevel }) {
92
92
  if (print) return print;
93
93
  if (process.env.CI === 'true' || process.env.CI === '1') {
94
94
  print = createBasicPrint({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,10 +12,10 @@
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 createStdOutLineHandler({ context }) {
15
+ */ function createStdOutLineHandler({ context }) {
16
16
  function stdOutLineHandler(line) {
17
17
  try {
18
- const { print , msg } = JSON.parse(line);
18
+ const { print, msg } = JSON.parse(line);
19
19
  context.print[print](msg);
20
20
  } catch (error) {
21
21
  context.print.log(line);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import axios from 'axios';
16
16
  import createPrint from './createPrint.js';
17
- async function logError({ error , context ={} }) {
17
+ async function logError({ error, context = {} }) {
18
18
  try {
19
19
  await axios.request({
20
20
  method: 'post',
@@ -32,11 +32,11 @@ async function logError({ error , context ={} }) {
32
32
  stack: error.stack
33
33
  }
34
34
  });
35
- } catch (error1) {
35
+ } catch (_) {
36
36
  // pass
37
37
  }
38
38
  }
39
- async function errorHandler({ context , error }) {
39
+ async function errorHandler({ context, error }) {
40
40
  const print = createPrint({
41
41
  logLevel: 'info'
42
42
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  */ import axios from 'axios';
16
16
  import decompress from 'decompress';
17
17
  import decompressTargz from 'decompress-targz';
18
- async function fetchNpmTarball({ packageName , version , directory }) {
18
+ async function fetchNpmTarball({ packageName, version, directory }) {
19
19
  const registryUrl = `https://registry.npmjs.org/${packageName}`;
20
20
  let packageInfo;
21
21
  try {
@@ -37,11 +37,11 @@ async function fetchNpmTarball({ packageName , version , directory }) {
37
37
  tarball = await axios.get(packageInfo.data.versions[version].dist.tarball, {
38
38
  responseType: 'arraybuffer'
39
39
  });
40
- } catch (error1) {
41
- if (error1.response && error1.response.status === 404) {
40
+ } catch (error) {
41
+ if (error.response && error.response.status === 404) {
42
42
  throw new Error(`Package "${packageName}" tarball could not be found at ${packageInfo.data.versions[version].dist.tarball}.`);
43
43
  }
44
- throw error1;
44
+ throw error;
45
45
  }
46
46
  if (!tarball || !tarball.data) {
47
47
  throw new Error(`Package "${packageName}" tarball could not be found at ${packageInfo.data.versions[version].dist.tarball}.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -44,12 +44,12 @@
44
44
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
45
45
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46
46
  */ import net from 'net';
47
- async function findPort() {
47
+ function findPort() {
48
48
  return new Promise((resolve, reject)=>{
49
49
  const server = net.createServer();
50
50
  server.on('error', reject);
51
51
  server.listen(0, ()=>{
52
- const { port } = server.address();
52
+ const { port } = server.address();
53
53
  server.on('close', resolve.bind(null, port));
54
54
  server.close();
55
55
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  */ import path from 'path';
16
16
  import { readFile, writeFile } from '@lowdefy/node-utils';
17
17
  import { v4 as uuid } from 'uuid';
18
- async function getCliJson({ configDirectory }) {
18
+ async function getCliJson({ configDirectory }) {
19
19
  const filePath = path.resolve(configDirectory, './.lowdefy/cli.json');
20
20
  const cliJson = await readFile(filePath);
21
21
  if (!cliJson) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
- function getDirectories({ configDirectory , options }) {
16
+ function getDirectories({ configDirectory, options }) {
17
17
  const dotLowdefy = path.resolve(configDirectory, '.lowdefy');
18
18
  const server = options.serverDirectory ? path.resolve(options.serverDirectory) : path.join(dotLowdefy, 'server');
19
19
  // TODO: Read server directory from env var
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  import { get, type } from '@lowdefy/helpers';
17
17
  import { readFile } from '@lowdefy/node-utils';
18
18
  import YAML from 'yaml';
19
- async function getLowdefyYaml({ configDirectory , requiresLowdefyYaml }) {
19
+ async function getLowdefyYaml({ configDirectory, requiresLowdefyYaml }) {
20
20
  let lowdefyYaml = await readFile(path.join(configDirectory, 'lowdefy.yaml'));
21
21
  if (!lowdefyYaml) {
22
22
  lowdefyYaml = await readFile(path.join(configDirectory, 'lowdefy.yml'));
@@ -36,7 +36,7 @@ async function getLowdefyYaml({ configDirectory , requiresLowdefyYaml }) {
36
36
  throw new Error(`Could not parse "lowdefy.yaml" file. Received error ${error.message}.`);
37
37
  }
38
38
  if (!lowdefy.lowdefy) {
39
- throw new Error(`No version specified in "lowdefy.yaml" file. Specify a version in the "lowdefy" field.`);
39
+ throw new Error('No version specified in "lowdefy.yaml" file. Specify a version in the "lowdefy" field.');
40
40
  }
41
41
  if (!type.isString(lowdefy.lowdefy)) {
42
42
  throw new Error(`Version number specified in "lowdefy.yaml" file should be a string. Received ${JSON.stringify(lowdefy.lowdefy)}.`);
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
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 getOptions({ commandLineOptions , cliConfig }) {
15
+ */ function getOptions({ commandLineOptions, cliConfig }) {
16
16
  // commandLineOptions take precedence over config in lowdefy.yaml
17
17
  const options = {
18
18
  ...cliConfig,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -15,14 +15,14 @@
15
15
  */ import path from 'path';
16
16
  import axios from 'axios';
17
17
  import { readFile } from '@lowdefy/node-utils';
18
- async function getTypes({ directories }) {
18
+ async function getTypes({ directories }) {
19
19
  return JSON.parse(await readFile(path.join(directories.build, 'types.json')));
20
20
  }
21
- function getSendTelemetry({ appId , cliVersion , command , directories , lowdefyVersion , options }) {
21
+ function getSendTelemetry({ appId, cliVersion, command, directories, license, lowdefyVersion, options }) {
22
22
  if (options.disableTelemetry) {
23
23
  return ()=>{};
24
24
  }
25
- async function sendTelemetry({ data ={} , sendTypes =false } = {}) {
25
+ async function sendTelemetry({ data = {}, sendTypes = false } = {}) {
26
26
  let types;
27
27
  if (sendTypes) {
28
28
  types = await getTypes({
@@ -32,7 +32,7 @@ function getSendTelemetry({ appId , cliVersion , command , directories , lowdefy
32
32
  try {
33
33
  await axios.request({
34
34
  method: 'post',
35
- url: 'https://api.lowdefy.net/telemetry/cli',
35
+ url: 'https://api.lowdefy.net/v4/telemetry/cli',
36
36
  headers: {
37
37
  'User-Agent': `Lowdefy CLI v${cliVersion}`
38
38
  },
@@ -41,6 +41,7 @@ function getSendTelemetry({ appId , cliVersion , command , directories , lowdefy
41
41
  app_id: appId,
42
42
  cli_version: cliVersion,
43
43
  command,
44
+ license_id: license?.id,
44
45
  lowdefy_version: lowdefyVersion,
45
46
  types
46
47
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  import path from 'path';
17
17
  import { cleanDirectory, readFile } from '@lowdefy/node-utils';
18
18
  import fetchNpmTarball from './fetchNpmTarball.js';
19
- async function getServer({ context , packageName , directory }) {
19
+ async function getServer({ context, packageName, directory }) {
20
20
  if (context.lowdefyVersion === 'local') {
21
21
  context.print.warn(`Running local ${packageName}.`);
22
22
  return;
@@ -37,7 +37,7 @@ async function getServer({ context , packageName , directory }) {
37
37
  await fetchNpmTarball({
38
38
  packageName,
39
39
  version: context.lowdefyVersion,
40
- directory: directory
40
+ directory
41
41
  });
42
42
  context.print.log(`Fetched ${packageName} from npm.`);
43
43
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { spawnProcess } from '@lowdefy/node-utils';
16
- async function installServer({ context , directory }) {
16
+ async function installServer({ context, directory }) {
17
17
  context.print.spin('Installing dependencies.');
18
18
  try {
19
19
  await spawnProcess({
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  import dotenv from 'dotenv';
17
17
  function readDotEnv(context) {
18
18
  dotenv.config({
19
- path: path.join(context.directories.config, '.env'),
19
+ path: path.join(context.configDirectory, '.env'),
20
20
  silent: true
21
21
  });
22
22
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { copyFileOrDirectory } from '@lowdefy/node-utils';
17
- async function resetServerPackageJson({ directory }) {
17
+ async function resetServerPackageJson({ directory }) {
18
18
  await copyFileOrDirectory(path.join(directory, 'package.original.json'), path.join(directory, 'package.json'));
19
19
  }
20
20
  export default resetServerPackageJson;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import errorHandler from './errorHandler.js';
16
16
  import startUp from './startUp.js';
17
- const runCommand = ({ cliVersion , handler })=>{
17
+ const runCommand = ({ cliVersion, handler })=>{
18
18
  async function run(options, command) {
19
19
  const context = {
20
20
  cliVersion
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import { spawnProcess } from '@lowdefy/node-utils';
16
16
  import createStdOutLineHandler from './createStdOutLineHandler.js';
17
- async function runLowdefyBuild({ context , directory }) {
17
+ async function runLowdefyBuild({ context, directory }) {
18
18
  context.print.spin('Running Lowdefy build.');
19
19
  try {
20
20
  await spawnProcess({
@@ -32,7 +32,8 @@ async function runLowdefyBuild({ context , directory }) {
32
32
  ...process.env,
33
33
  LOWDEFY_BUILD_REF_RESOLVER: context.options.refResolver,
34
34
  LOWDEFY_DIRECTORY_CONFIG: context.directories.config,
35
- LOWDEFY_LOG_LEVEL: context.options.logLevel
35
+ LOWDEFY_LOG_LEVEL: context.options.logLevel,
36
+ LOWDEFY_LICENSE_ENTITLEMENTS: JSON.stringify(context.license.entitlements)
36
37
  }
37
38
  }
38
39
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -13,10 +13,10 @@
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  */ import { spawnProcess } from '@lowdefy/node-utils';
16
- function createStdOutLineHandler({ context }) {
16
+ function createStdOutLineHandler({ context }) {
17
17
  function stdOutLineHandler(line) {
18
18
  // Matches next build output of form: ┌ λ / 261 B 403 kB
19
- const match = line.match(/┌ λ \/\s*\d* [a-zA-Z]*\s*(\d* [a-zA-Z]*)/);
19
+ const match = line.match(/┌ λ \/\s*\d* [a-zA-Z]*\s*(\d* [a-zA-Z]*)/u);
20
20
  if (match) {
21
21
  context.print.info(`Home page first load JS size: ${match[1]}.`);
22
22
  }
@@ -24,7 +24,7 @@ function createStdOutLineHandler({ context }) {
24
24
  }
25
25
  return stdOutLineHandler;
26
26
  }
27
- async function runNextBuild({ context , directory }) {
27
+ async function runNextBuild({ context, directory }) {
28
28
  context.print.spin('Running Next build.');
29
29
  try {
30
30
  await spawnProcess({
@@ -38,6 +38,10 @@ async function runNextBuild({ context , directory }) {
38
38
  }),
39
39
  processOptions: {
40
40
  cwd: directory
41
+ },
42
+ env: {
43
+ ...process.env,
44
+ NEXT_TELEMETRY_DISABLED: context.options.disableTelemetry ? '1' : undefined
41
45
  }
42
46
  });
43
47
  } catch (error) {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,26 +14,29 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { type } from '@lowdefy/helpers';
17
- import validateVersion from './validateVersion.js';
18
17
  import checkPnpmIsInstalled from './checkPnpmIsInstalled.js';
18
+ import createPrint from './createPrint.js';
19
19
  import getCliJson from './getCliJson.js';
20
20
  import getDirectories from './getDirectories.js';
21
21
  import getLowdefyYaml from './getLowdefyYaml.js';
22
22
  import getOptions from './getOptions.js';
23
23
  import getSendTelemetry from './getSendTelemetry.js';
24
- import createPrint from './createPrint.js';
25
- async function startUp({ context , options ={} , command }) {
24
+ import readDotEnv from './readDotEnv.js';
25
+ import validateLicense from './validateLicense.js';
26
+ import validateVersion from './validateVersion.js';
27
+ async function startUp({ context, options = {}, command }) {
26
28
  context.command = command.name();
27
29
  context.commandLineOptions = options;
28
30
  context.configDirectory = path.resolve(options.configDirectory || process.cwd());
31
+ readDotEnv(context);
29
32
  context.requiresLowdefyYaml = ![
30
33
  'init'
31
34
  ].includes(command.name());
32
- const { cliConfig , lowdefyVersion , plugins } = await getLowdefyYaml(context);
35
+ const { cliConfig, lowdefyVersion, plugins } = await getLowdefyYaml(context);
33
36
  context.cliConfig = cliConfig;
34
37
  context.lowdefyVersion = lowdefyVersion;
35
38
  context.plugins = plugins;
36
- const { appId } = await getCliJson(context);
39
+ const { appId } = await getCliJson(context);
37
40
  context.appId = appId;
38
41
  context.options = getOptions(context);
39
42
  context.print = createPrint({
@@ -43,6 +46,7 @@ async function startUp({ context , options ={} , command }) {
43
46
  context.pnpmCmd = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
44
47
  checkPnpmIsInstalled(context);
45
48
  await validateVersion(context);
49
+ context.license = await validateLicense(context);
46
50
  context.sendTelemetry = getSendTelemetry(context);
47
51
  if (type.isNone(lowdefyVersion)) {
48
52
  context.print.log(`Running 'lowdefy ${context.command}'.`);
@@ -0,0 +1,54 @@
1
+ /*
2
+ Copyright 2020-2024 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 { keygenValidateLicense } from '@lowdefy/node-utils';
16
+ const config = {
17
+ dev: {
18
+ accountId: 'bf35f4ae-53a8-45c6-9eed-2d1fc9f53bd6',
19
+ productId: '4254760d-e760-4932-bb96-ba767e6ae780',
20
+ publicKey: 'MCowBQYDK2VwAyEAN27y1DiHiEDYFbNGjgfFdWygxrVSetq6rApWq3psJZI='
21
+ },
22
+ prod: {
23
+ accountId: '63b3d4e4-39e1-4ccc-8c58-6b8f97ddf4fa',
24
+ productId: 'd19a5af0-4147-4a65-8b6d-0706d7804bc1',
25
+ publicKey: 'MCowBQYDK2VwAyEAFPoseE3gi+YsJziigc1kFKOkdUIBiUMd9RZujTh23Fc='
26
+ }
27
+ };
28
+ // TODO: Messages
29
+ async function validateLicense({ print }) {
30
+ const license = await keygenValidateLicense({
31
+ config: config[process.env.LOWDEFY_LICENSE_ENV ?? 'prod']
32
+ });
33
+ if (license.code == 'NO_LICENSE') {
34
+ return license;
35
+ }
36
+ if (license.code == 'EXPIRED') {
37
+ print.warn(`
38
+ ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
39
+ ┃ Your Lowdefy license has expired. ┃
40
+ ┠──────────────────────────────────────────────────┨
41
+ ┃ Please renew your license at ┃
42
+ ┃ https://cloud.lowdefy.com ┃
43
+ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`);
44
+ return license;
45
+ }
46
+ if (license.code == 'NO_LICENSE') {
47
+ return license;
48
+ }
49
+ if (license.code !== 'VALID') {
50
+ throw new Error('Invalid license.');
51
+ }
52
+ return license;
53
+ }
54
+ export default validateLicense;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2020-2023 Lowdefy, Inc
2
+ Copyright 2020-2024 Lowdefy, Inc
3
3
 
4
4
  Licensed under the Apache License, Version 2.0 (the "License");
5
5
  you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import axios from 'axios';
16
16
  import semver from 'semver';
17
- async function validateVersion({ cliVersion , lowdefyVersion , print , requiresLowdefyYaml }) {
17
+ async function validateVersion({ cliVersion, lowdefyVersion, print, requiresLowdefyYaml }) {
18
18
  if (!requiresLowdefyYaml) {
19
19
  return;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lowdefy",
3
- "version": "4.0.0-rc.9",
3
+ "version": "4.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy CLI",
6
6
  "homepage": "https://lowdefy.com",
@@ -31,35 +31,36 @@
31
31
  "dist/*"
32
32
  ],
33
33
  "exports": "./dist/index.js",
34
- "scripts": {
35
- "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start --copy-files",
36
- "clean": "rm -rf dist && rm -rf .lowdefy",
37
- "start": "node ./dist/index.js",
38
- "prepublishOnly": "pnpm build",
39
- "test": "FORCE_COLOR=3 node --experimental-vm-modules node_modules/jest/bin/jest.js"
40
- },
41
34
  "dependencies": {
42
- "@lowdefy/helpers": "4.0.0-rc.9",
43
- "@lowdefy/node-utils": "4.0.0-rc.9",
44
- "axios": "1.2.2",
45
- "commander": "9.4.1",
35
+ "@lowdefy/helpers": "4.0.0",
36
+ "@lowdefy/node-utils": "4.0.0",
37
+ "axios": "1.6.2",
38
+ "commander": "11.1.0",
46
39
  "decompress": "4.2.1",
47
40
  "decompress-targz": "4.1.1",
48
- "dotenv": "16.0.3",
49
- "ora": "6.1.2",
50
- "semver": "7.3.8",
51
- "uuid": "9.0.0",
52
- "yaml": "2.2.2"
41
+ "dotenv": "16.3.1",
42
+ "ora": "7.0.1",
43
+ "semver": "7.5.4",
44
+ "uuid": "9.0.1",
45
+ "yaml": "2.3.4"
53
46
  },
54
47
  "devDependencies": {
55
- "@jest/globals": "28.1.0",
56
- "@swc/cli": "0.1.59",
57
- "@swc/core": "1.3.24",
58
- "@swc/jest": "0.2.24",
59
- "jest": "28.1.0"
48
+ "@jest/globals": "28.1.3",
49
+ "@swc/cli": "0.1.63",
50
+ "@swc/core": "1.3.99",
51
+ "@swc/jest": "0.2.29",
52
+ "jest": "28.1.3"
53
+ },
54
+ "engines": {
55
+ "node": ">=18"
60
56
  },
61
57
  "publishConfig": {
62
58
  "access": "public"
63
59
  },
64
- "gitHead": "d20e6ac424643feca527a732dc2b0710713c8243"
65
- }
60
+ "scripts": {
61
+ "build": "swc src --out-dir dist --config-file ../../.swcrc --delete-dir-on-start --copy-files",
62
+ "clean": "rm -rf dist && rm -rf .lowdefy",
63
+ "start": "node ./dist/index.js",
64
+ "test": "FORCE_COLOR=3 node --experimental-vm-modules node_modules/jest/bin/jest.js"
65
+ }
66
+ }