lowdefy 4.0.0-rc.1 → 4.0.0-rc.10

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.
@@ -19,7 +19,7 @@ import readDotEnv from '../../utils/readDotEnv.js';
19
19
  import resetServerPackageJson from '../../utils/resetServerPackageJson.js';
20
20
  import runLowdefyBuild from '../../utils/runLowdefyBuild.js';
21
21
  import runNextBuild from '../../utils/runNextBuild.js';
22
- async function build({ context }) {
22
+ async function build({ context }) {
23
23
  context.print.info('Starting build.');
24
24
  readDotEnv(context);
25
25
  const directory = context.directories.server;
@@ -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({
@@ -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',
@@ -16,7 +16,7 @@
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) {
@@ -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
 
@@ -15,7 +15,7 @@
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 }) {
18
+ async function initDocker({ context }) {
19
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);
@@ -15,7 +15,7 @@
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 }) {
18
+ async function initVercel({ context }) {
19
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);
@@ -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',
@@ -15,7 +15,7 @@
15
15
  */ import runStart from './runStart.js';
16
16
  import readDotEnv from '../../utils/readDotEnv.js';
17
17
  // TODO: Handle "spawn yarn ENOENT" error if no built server exists.
18
- async function build({ context }) {
18
+ async function build({ context }) {
19
19
  context.sendTelemetry({
20
20
  sendTypes: true
21
21
  });
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ if (Number(nodeMajorVersion) < 14) {
19
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.`);
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
@@ -23,7 +23,7 @@ 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 = {
@@ -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;
@@ -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'
@@ -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({
@@ -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);
@@ -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 (error) {
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
  });
@@ -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}.`);
@@ -49,7 +49,7 @@ async function findPort() {
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
  });
@@ -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) {
@@ -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
@@ -16,15 +16,13 @@
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 , command }) {
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'));
23
23
  }
24
24
  if (!lowdefyYaml) {
25
- if (![
26
- 'init'
27
- ].includes(command)) {
25
+ if (requiresLowdefyYaml) {
28
26
  throw new Error(`Could not find "lowdefy.yaml" file in specified config directory ${configDirectory}.`);
29
27
  }
30
28
  return {
@@ -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,
@@ -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, 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({
@@ -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;
@@ -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({
@@ -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;
@@ -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
@@ -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({
@@ -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
- 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
19
  const match = line.match(/┌ λ \/\s*\d* [a-zA-Z]*\s*(\d* [a-zA-Z]*)/);
@@ -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({
@@ -14,7 +14,7 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { type } from '@lowdefy/helpers';
17
- import checkForUpdatedVersions from './checkForUpdatedVersions.js';
17
+ import validateVersion from './validateVersion.js';
18
18
  import checkPnpmIsInstalled from './checkPnpmIsInstalled.js';
19
19
  import getCliJson from './getCliJson.js';
20
20
  import getDirectories from './getDirectories.js';
@@ -22,15 +22,18 @@ import getLowdefyYaml from './getLowdefyYaml.js';
22
22
  import getOptions from './getOptions.js';
23
23
  import getSendTelemetry from './getSendTelemetry.js';
24
24
  import createPrint from './createPrint.js';
25
- async function startUp({ context , options ={} , command }) {
25
+ async function startUp({ context, options = {}, command }) {
26
26
  context.command = command.name();
27
27
  context.commandLineOptions = options;
28
28
  context.configDirectory = path.resolve(options.configDirectory || process.cwd());
29
- const { cliConfig , lowdefyVersion , plugins } = await getLowdefyYaml(context);
29
+ context.requiresLowdefyYaml = ![
30
+ 'init'
31
+ ].includes(command.name());
32
+ const { cliConfig, lowdefyVersion, plugins } = await getLowdefyYaml(context);
30
33
  context.cliConfig = cliConfig;
31
34
  context.lowdefyVersion = lowdefyVersion;
32
35
  context.plugins = plugins;
33
- const { appId } = await getCliJson(context);
36
+ const { appId } = await getCliJson(context);
34
37
  context.appId = appId;
35
38
  context.options = getOptions(context);
36
39
  context.print = createPrint({
@@ -39,7 +42,7 @@ async function startUp({ context , options ={} , command }) {
39
42
  context.directories = getDirectories(context);
40
43
  context.pnpmCmd = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
41
44
  checkPnpmIsInstalled(context);
42
- await checkForUpdatedVersions(context);
45
+ await validateVersion(context);
43
46
  context.sendTelemetry = getSendTelemetry(context);
44
47
  if (type.isNone(lowdefyVersion)) {
45
48
  context.print.log(`Running 'lowdefy ${context.command}'.`);
@@ -14,7 +14,10 @@
14
14
  limitations under the License.
15
15
  */ import axios from 'axios';
16
16
  import semver from 'semver';
17
- async function checkForUpdatedVersions({ cliVersion , lowdefyVersion , print }) {
17
+ async function validateVersion({ cliVersion, lowdefyVersion, print, requiresLowdefyYaml }) {
18
+ if (!requiresLowdefyYaml) {
19
+ return;
20
+ }
18
21
  if (lowdefyVersion === 'local') {
19
22
  return;
20
23
  }
@@ -71,4 +74,4 @@ async function checkForUpdatedVersions({ cliVersion , lowdefyVersion , print })
71
74
  function isExperimentalVersion(version) {
72
75
  return version.includes('alpha') || version.includes('beta') || version.includes('rc');
73
76
  }
74
- export default checkForUpdatedVersions;
77
+ export default validateVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lowdefy",
3
- "version": "4.0.0-rc.1",
3
+ "version": "4.0.0-rc.10",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy CLI",
6
6
  "homepage": "https://lowdefy.com",
@@ -39,27 +39,27 @@
39
39
  "test": "FORCE_COLOR=3 node --experimental-vm-modules node_modules/jest/bin/jest.js"
40
40
  },
41
41
  "dependencies": {
42
- "@lowdefy/helpers": "4.0.0-rc.1",
43
- "@lowdefy/node-utils": "4.0.0-rc.1",
42
+ "@lowdefy/helpers": "4.0.0-rc.10",
43
+ "@lowdefy/node-utils": "4.0.0-rc.10",
44
44
  "axios": "1.2.2",
45
45
  "commander": "9.4.1",
46
46
  "decompress": "4.2.1",
47
47
  "decompress-targz": "4.1.1",
48
48
  "dotenv": "16.0.3",
49
49
  "ora": "6.1.2",
50
- "semver": "7.3.8",
50
+ "semver": "7.5.2",
51
51
  "uuid": "9.0.0",
52
- "yaml": "2.2.1"
52
+ "yaml": "2.2.2"
53
53
  },
54
54
  "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"
55
+ "@jest/globals": "28.1.3",
56
+ "@swc/cli": "0.1.62",
57
+ "@swc/core": "1.3.70",
58
+ "@swc/jest": "0.2.27",
59
+ "jest": "28.1.3"
60
60
  },
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "ecc4f16c19eede929eda177db524cf13a8053379"
64
+ "gitHead": "537af074f27770e32da9da8d48490f2eda94b406"
65
65
  }