From 507e89a4d48bb099a9581cd108b567f28bd855f9 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Wed, 19 Oct 2022 18:48:38 +0800 Subject: [PATCH] chore: update content --- README.md | 4 +-- install.js | 72 ------------------------------------------------------ lerna.json | 6 ----- 3 files changed, 2 insertions(+), 80 deletions(-) delete mode 100755 install.js delete mode 100644 lerna.json diff --git a/README.md b/README.md index ed9dadde8..8119a0abe 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,12 @@ curl -fsSL https://raw.githubusercontent.com/logto-io/logto/HEAD/docker-compose. TAG=prerelease docker compose -p logto -f - up ``` -#### One-liner script +#### npm-init Requires [Node.js](https://nodejs.org/) `^16.13.0` + [PostgreSQL](https://postgresql.org/) `^14.0`. ```bash -node -e "$(printf "%s" "$(curl -fsSL https://raw.githubusercontent.com/logto-io/logto/HEAD/install.js)")" +npm init @logto ``` ## Language support diff --git a/install.js b/install.js deleted file mode 100755 index b0c2dc6ff..000000000 --- a/install.js +++ /dev/null @@ -1,72 +0,0 @@ -const { execSync, spawn, spawnSync } = require('child_process'); -const { existsSync } = require('fs'); -const readline = require('readline'); - -const isVersionGreaterThan = (version, targetMajor) => Number(version.split('.')[0]) >= targetMajor; - -const trimV = (version) => version.startsWith('v') ? version.slice(1) : version; - -const question = async (query) => new Promise((resolve) => { - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - }); - rl.question(query, (answer) => { - rl.close(); - resolve(answer); - }); -}); - -const confirm = async (query) => { - const answer = await question(`${query} (Y/n) `); - return answer === '' || ['y', 'yes', 'yep', 'yeah'].includes(answer.toLowerCase()); -}; - -const safeExecSync = (command) => { - try { - return execSync(command, { encoding: 'utf-8' }); - } catch {} -}; - -const directory = 'logto'; -const nodeMajorVersion = 16; -const postgresMajorVersion = 14; - -(async () => { - if (existsSync(directory)) { - throw new Error(`\`${directory}\` already exists in the current directory.`); - } - - const nodeVersion = execSync('node -v', { encoding: 'utf-8' }); - - if (!isVersionGreaterThan(trimV(nodeVersion), nodeMajorVersion)) { - throw new Error(`Logto requires NodeJS >= ${nodeMajorVersion}.0.0.`); - } - - const pgOutput = safeExecSync('postgres --version') ?? ''; - const pgArray = pgOutput.split(' '); - const pgVersion = pgArray[pgArray.length - 1]; - - if (!isVersionGreaterThan(trimV(pgVersion), postgresMajorVersion)) { - const answer = await confirm(`Logto requires PostgreSQL >= ${postgresMajorVersion}.0.0 but cannot find in the current environment.\nDo you have a remote PostgreSQL instance ready?`); - if (!answer) { - process.exit(1); - } - } - - // Download and extract - spawnSync( - 'sh', - ['-c', 'curl -L https://github.com/logto-io/logto/releases/latest/download/logto.tar.gz | tar -xz'], - { stdio: 'inherit' }, - ); - - const startCommand = `cd ${directory} && npm start`; - const answer = await confirm('Would you like to start Logto now?'); - - if (answer) { - spawn('sh', ['-c', startCommand], { stdio: 'inherit' }); - } else { - console.log(`You can use \`${startCommand}\` to start Logto. Happy hacking!`); - } -})(); diff --git a/lerna.json b/lerna.json deleted file mode 100644 index 6001156ef..000000000 --- a/lerna.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0-beta.12", - "npmClient": "pnpm", - "useWorkspaces": true, - "changelogPreset": "conventionalcommits" -}