@based/cli
Advanced tools
Comparing version 8.0.0-alpha.4 to 8.0.0-alpha.5
@@ -0,1 +1,2 @@ | ||
import { type BasedBundleOptions } from '@based/bundle'; | ||
import type { BasedFunctionConfig } from '@based/functions'; | ||
@@ -12,3 +13,8 @@ import type { Command } from 'commander'; | ||
files?: string[]; | ||
build?: Build; | ||
}; | ||
type Build = { | ||
watch: BasedBundleOptions['watch']; | ||
plugins: BasedBundleOptions['plugins']; | ||
}; | ||
type ConfigStore = { | ||
@@ -15,0 +21,0 @@ config: Config; |
import { readFile, readdir } from 'node:fs/promises'; | ||
import { isAbsolute, join, relative } from 'node:path'; | ||
import { bundle } from '@based/bundle'; | ||
import { bundle, } from '@based/bundle'; | ||
import { hash, hashCompact } from '@saulx/hash'; | ||
@@ -171,2 +171,6 @@ import { queued } from '@saulx/utils'; | ||
const browserEntryPoints = []; | ||
let browserWatch = { | ||
include: [], | ||
}; | ||
const browserEsbuildPlugins = []; | ||
const favicons = new Set(); | ||
@@ -191,5 +195,10 @@ const files = {}; | ||
} | ||
// if (!('bundle' in config) || config.bundle) { | ||
if (config.build?.plugins) { | ||
browserEsbuildPlugins.push(...config.build.plugins); | ||
} | ||
configStore.app = abs(config.main, dir); | ||
browserEntryPoints.push(configStore.app); | ||
if (config.build?.watch) { | ||
browserWatch = config.build?.watch; | ||
} | ||
if (config.favicon) { | ||
@@ -200,3 +209,2 @@ configStore.favicon = abs(config.favicon, dir); | ||
} | ||
// } | ||
} | ||
@@ -255,2 +263,3 @@ if (config.files) { | ||
entryPoints: browserEntryPoints, | ||
watch: browserWatch, | ||
sourcemap: true, | ||
@@ -261,2 +270,3 @@ platform: 'browser', | ||
plugins: [ | ||
...browserEsbuildPlugins, | ||
replaceBasedConfigPlugin({ | ||
@@ -263,0 +273,0 @@ url: staticPath, |
@@ -213,3 +213,2 @@ import { networkInterfaces } from 'node:os'; | ||
[config.name]: { | ||
// name 'smurk' | ||
type: 'function', | ||
@@ -216,0 +215,0 @@ async fn() { |
@@ -215,3 +215,3 @@ import { tmpdir } from 'node:os'; | ||
// )), | ||
context.i18n('commands.init.methods.summary.dependencies', project.dependencies?.join(', ')), | ||
context.i18n('commands.init.methods.summary.dependencies', [...project.dependencies, ...project.devDependencies]?.join(', ')), | ||
context.i18n('commands.init.methods.summary.saveIn', project.path), | ||
@@ -261,3 +261,3 @@ ].filter(Boolean)); | ||
await saveAsFile(basedProjectTemplate, project.path, project.format); | ||
context.spinner.stop('Project created!'); | ||
context.spinner.stop('<green>♥</green> Project created!'); | ||
const npm = await confirm({ | ||
@@ -264,0 +264,0 @@ message: 'Do you want to install your dependencies now?', |
@@ -1,1 +0,2 @@ | ||
export {}; | ||
import { Command } from 'commander'; | ||
export declare const login: (program: Command) => Promise<void>; |
@@ -1,2 +0,9 @@ | ||
export {}; | ||
import { login as loginFn } from '../../shared/login.js'; | ||
export const login = async (program) => { | ||
const cmd = program.command('login'); | ||
cmd.action(async () => { | ||
const { destroy } = await loginFn(program, true); | ||
destroy(); | ||
}); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,1 @@ | ||
import { Command } from 'commander'; | ||
export declare const globalOptions: (program: Command) => Promise<void>; | ||
export declare const globalOptions: (program: any) => Promise<void>; |
@@ -47,8 +47,8 @@ import { findUp } from 'find-up'; | ||
program | ||
.option('-c, --cluster <cluster>', 'Define the cluster to use', args.cluster) | ||
.requiredOption('-o, --org <org>', 'Specify the organization', args.org) | ||
.requiredOption('-p, --project <project>', 'Specify the project name', args.project) | ||
.requiredOption('-e, --env <env>', 'Specify witch environment (can be a name or "#branch" if you want to deploy by branch)', args.env) | ||
.option('-aK, --api-key <api-key>', 'API Key generated on Based.io for Service Account'); | ||
.option('-c, --cluster <cluster>', 'Based cluster', args.cluster) | ||
.requiredOption('-o, --org <org>', 'Organization name', args.org) | ||
.requiredOption('-p, --project <project>', 'Project name', args.project) | ||
.requiredOption('-e, --env <env>', 'Environment name', args.env) | ||
.option('--api-key <api-key>', 'API key for service account'); | ||
}; | ||
//# sourceMappingURL=globalOptions.js.map |
import { BasedClient, BasedOpts } from '@based/client'; | ||
import { AppContext } from './AppContext.js'; | ||
export declare const getBasedClient: (context: AppContext, opts: BasedOpts) => BasedClient; | ||
export declare const getBasedClient: (opts: BasedOpts) => BasedClient; |
import { BasedClient } from '@based/client'; | ||
import { hashObjectIgnoreKeyOrderNest } from '@saulx/hash'; | ||
import { clearTimeout } from 'node:timers'; | ||
import { spinner } from './spinner.js'; | ||
const store = {}; | ||
class SharedBasedClient extends BasedClient { | ||
context; | ||
constructor(context, opts) { | ||
super(opts); | ||
this.context = context; | ||
} | ||
async setAuthState(args) { | ||
// override async call(name, ...args) { | ||
// const spinner = ora(name).start() | ||
// const res = await super.call(name, ...args) | ||
// spinner.succeed() | ||
// return res | ||
// } | ||
async connect(...args) { | ||
await super.connect(...args); | ||
const [emoji, target] = this.opts.org === 'saulx' && this.opts.project === 'based-cloud' | ||
? ['📡', 'Based Cloud'] | ||
: this.opts.optionalKey | ||
? ['🌎', 'the environment manager'] | ||
: ['🪐', 'the environment']; | ||
// this.context.print.loading(`Connecting to ${target}...`) | ||
const timeout = setTimeout(() => { | ||
this.context.print.stop().fail(`Could not connect. Check your '<b>based.json</b>' file or your arguments.`, true); | ||
}, 5e3); | ||
const authState = await super.setAuthState(args); | ||
clearTimeout(timeout); | ||
this.context.print.stop().success(`${emoji} Connected to ${target}.`); | ||
return authState; | ||
? ['📡', 'based cloud'] | ||
: ['🪐', 'environment']; | ||
const timer = setTimeout(async () => { | ||
spinner.text = `connecting ${target}`; | ||
spinner.start(); | ||
await this.once('connect'); | ||
spinner.stop(); | ||
}, 1e3); | ||
await this.once('connect'); | ||
clearTimeout(timer); | ||
console.info(`${emoji} connected ${target}`); | ||
} | ||
@@ -37,7 +38,7 @@ async destroy() { | ||
} | ||
export const getBasedClient = (context, opts) => { | ||
export const getBasedClient = (opts) => { | ||
const key = String(hashObjectIgnoreKeyOrderNest(opts)); | ||
store[key] ??= { | ||
users: 0, | ||
client: new SharedBasedClient(context, opts), | ||
client: new SharedBasedClient(opts), | ||
}; | ||
@@ -44,0 +45,0 @@ store[key].users++; |
@@ -1,3 +0,1 @@ | ||
import { type Ora } from 'ora'; | ||
export declare const spinner: Ora; | ||
//# sourceMappingURL=spinner.d.ts.map | ||
export declare const spinner: import("ora").Ora; |
import ora from 'ora'; | ||
export const spinner = ora({ discardStdin: false, hideCursor: true }); | ||
export const spinner = ora(); | ||
//# sourceMappingURL=spinner.js.map |
import { readJSON } from 'fs-extra/esm'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { dirname, join } from 'node:path'; | ||
import { AppContext } from './shared/index.js'; | ||
export const version = async (program) => { | ||
const context = AppContext.getInstance(program); | ||
const { version } = await readJSON(join(fileURLToPath(dirname(import.meta.url)), '../package.json')); | ||
context.set('appName', 'Based CLI'); | ||
context.set('appVersion', version); | ||
context.set('appTitle', `<b>Based CLI</b> <dim>${version}</dim>`); | ||
context.print.info(context.get('appTitle')); | ||
program.version(version, '-v, --version'); | ||
program.version(version); | ||
}; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@based/cli", | ||
"version": "8.0.0-alpha.4", | ||
"version": "8.0.0-alpha.5", | ||
"description": "based cli", | ||
@@ -11,5 +11,5 @@ "type": "module", | ||
"scripts": { | ||
"docs": "ts-node --esm ./scripts/readme.ts", | ||
"docs": "tsx ./scripts/readme.ts", | ||
"dev": "node bin/cmd.js", | ||
"build": "tsc -b", | ||
"build": "npm run docs && tsc -b", | ||
"watch": "tsc -b --watch" | ||
@@ -35,11 +35,11 @@ }, | ||
"@types/ws": "^8.5.12", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.6.2", | ||
"tsx": "^4.19.2", | ||
"typescript": "^5.2.2", | ||
"vitest": "^2.1.1" | ||
}, | ||
"dependencies": { | ||
"@based/bundle": "../bundle", | ||
"@based/client": "^6.10.1", | ||
"@based/bundle": "^0.3.0", | ||
"@based/client": "^6.11.1", | ||
"@based/i18n": "^0.2.0", | ||
"@based/server": "^9.1.0", | ||
"@based/server": "^9.1.2", | ||
"@clack/prompts": "^0.7.0", | ||
@@ -46,0 +46,0 @@ "@inquirer/prompts": "^6.0.1", |
@@ -70,2 +70,8 @@ # @based/cli | ||
### Disconnect | ||
Disconnect your user locally. | ||
_Example:_ `npx @based/cli disconnect` | ||
### Auth | ||
@@ -81,2 +87,16 @@ | ||
### Init | ||
_Example:_ `npx @based/cli init [options]` | ||
| Option | Description | | ||
|--------|-------------| | ||
| `-n, --name <name>` | Give a name to your project. | | ||
| `-d, --description <description>` | Give a description to your project. | | ||
| `--path <path>` | The path to save the Based Project File. | | ||
| `--format <format>` | The extension of file you prefer (available formats: ts, js, json). | | ||
| `-dp, --dependencies <packages...>` | Choose the dependencies you want to be added to your project (available tools: typescript, vitest, biome, react). | | ||
| `--queries <queries...>` | You can pre-create your Based Query Functions. | | ||
| `-f, --functions <functions...>` | You can pre-create your Based Cloud Functions. | | ||
### Backups | ||
@@ -188,4 +208,4 @@ | ||
|--------|-------------| | ||
| `--path <path>` | The path to save the file. | | ||
| `-n, --name <name>` | The name of your machine. | | ||
| `-s, --standby` | Set the standby mode of your machines. | | ||
| `-n, --name <name>` | Give a name to your machine. | | ||
| `-d, --description <description>` | Give a description to your machine. | | ||
@@ -196,3 +216,24 @@ | `-do, --domains <domains...>` | Your domains to be assigned to the machine. | | ||
| `--max <max>` | The maximum number of machines that you want to scale your app. | | ||
| `--path <path>` | The path to save the file. | | ||
| `--format <format>` | The extension of file you prefer (available formats: ts, js, json). | | ||
#### Get | ||
To download your infra file in your repo. | ||
| Option | Description | | ||
|--------|-------------| | ||
| `-m, --machine <machine>` | If you want to filter and get only a specific machine. | | ||
| `--path <path>` | The path to save the file. | | ||
| `--format <format>` | The extension of file you prefer (available formats: ts, js, json). | | ||
#### Overview | ||
Check the status from your infra, live connections, machines and services. | ||
| Option | Description | | ||
|--------|-------------| | ||
| `--monitor` | To display the overview in an interactive UI. | | ||
| `--stream` | To display the overview in real time. | | ||
### Deploy | ||
@@ -199,0 +240,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 3 instances in 1 package
133774523
257
0
9
336
7781
25
+ Added@based/bundle@0.3.0(transitive)
+ Added@esbuild/aix-ppc64@0.21.5(transitive)
+ Added@esbuild/android-arm@0.21.5(transitive)
+ Added@esbuild/android-arm64@0.21.5(transitive)
+ Added@esbuild/android-x64@0.21.5(transitive)
+ Added@esbuild/darwin-arm64@0.21.5(transitive)
+ Added@esbuild/darwin-x64@0.21.5(transitive)
+ Added@esbuild/freebsd-arm64@0.21.5(transitive)
+ Added@esbuild/freebsd-x64@0.21.5(transitive)
+ Added@esbuild/linux-arm@0.21.5(transitive)
+ Added@esbuild/linux-arm64@0.21.5(transitive)
+ Added@esbuild/linux-ia32@0.21.5(transitive)
+ Added@esbuild/linux-loong64@0.21.5(transitive)
+ Added@esbuild/linux-mips64el@0.21.5(transitive)
+ Added@esbuild/linux-ppc64@0.21.5(transitive)
+ Added@esbuild/linux-riscv64@0.21.5(transitive)
+ Added@esbuild/linux-s390x@0.21.5(transitive)
+ Added@esbuild/linux-x64@0.21.5(transitive)
+ Added@esbuild/netbsd-x64@0.21.5(transitive)
+ Added@esbuild/openbsd-x64@0.21.5(transitive)
+ Added@esbuild/sunos-x64@0.21.5(transitive)
+ Added@esbuild/win32-arm64@0.21.5(transitive)
+ Added@esbuild/win32-ia32@0.21.5(transitive)
+ Added@esbuild/win32-x64@0.21.5(transitive)
+ Added@jspm/core@2.1.0(transitive)
+ Added@parcel/watcher@2.5.0(transitive)
+ Added@parcel/watcher-android-arm64@2.5.0(transitive)
+ Added@parcel/watcher-darwin-arm64@2.5.0(transitive)
+ Added@parcel/watcher-darwin-x64@2.5.0(transitive)
+ Added@parcel/watcher-freebsd-x64@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm-musl@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm64-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-arm64-musl@2.5.0(transitive)
+ Added@parcel/watcher-linux-x64-glibc@2.5.0(transitive)
+ Added@parcel/watcher-linux-x64-musl@2.5.0(transitive)
+ Added@parcel/watcher-win32-arm64@2.5.0(transitive)
+ Added@parcel/watcher-win32-ia32@2.5.0(transitive)
+ Added@parcel/watcher-win32-x64@2.5.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addeddom-serializer@2.0.0(transitive)
+ Addeddomelementtype@2.3.0(transitive)
+ Addeddomhandler@5.0.3(transitive)
+ Addeddomutils@3.2.2(transitive)
+ Addedentities@4.5.0(transitive)
+ Addedesbuild@0.21.5(transitive)
+ Addedesbuild-plugin-polyfill-node@0.3.0(transitive)
+ Addedhtmlparser2@9.1.0(transitive)
+ Addedimport-meta-resolve@3.1.1(transitive)
+ Addedinlines@0.4.0-alpha.26(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedpretty-bytes@6.1.1(transitive)
+ Addedreact@19.0.0(transitive)
+ Addedtypescript@5.7.2(transitive)
Updated@based/bundle@^0.3.0
Updated@based/client@^6.11.1
Updated@based/server@^9.1.2