From 23a22eb4dd12c0a9bae9696d5d225c48c1668d04 Mon Sep 17 00:00:00 2001 From: Gabriel Pinto Date: Fri, 4 Oct 2024 18:44:00 +0100 Subject: [PATCH] chore: remove cli and expose entrypoint --- package-lock.json | 11 ++--- packages/next-on-fleek/package.json | 5 ++- packages/next-on-fleek/src/cli.ts | 68 ----------------------------- packages/next-on-fleek/src/index.ts | 8 ++-- 4 files changed, 12 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1b0050e1..4856ebe0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ } }, "internal-packages/eslint-config-next-on-fleek": { + "name": "@fleek-platform/eslint-config-next-on-fleek", "dependencies": { "@typescript-eslint/eslint-plugin": "^5.58.0", "@typescript-eslint/parser": "^5.58.0", @@ -69,7 +70,9 @@ "vitest": "^0.32.2" } }, - "internal-packages/next-on-fleek-tsconfig": {}, + "internal-packages/next-on-fleek-tsconfig": { + "name": "@fleek-platform/next-on-fleek-tsconfig" + }, "internal-packages/next-on-pages-tsconfig": { "name": "@fleek-platform/next-on-fleek-tsconfig", "extraneous": true @@ -15237,7 +15240,8 @@ } }, "packages/next-on-fleek": { - "version": "1.13.3", + "name": "@fleek-platform/next-on-fleek", + "version": "1.14.0", "license": "MIT", "dependencies": { "@fleek-platform/sdk": "^2.1.5", @@ -15258,9 +15262,6 @@ "parallel-transform-web": "^1.0.1", "semver": "^7.5.2" }, - "bin": { - "next-on-fleek": "bin/index.js" - }, "devDependencies": { "@changesets/cli": "^2.26.0", "@fleek-platform/next-on-fleek-tsconfig": "*", diff --git a/packages/next-on-fleek/package.json b/packages/next-on-fleek/package.json index 6394a1685..a21663177 100644 --- a/packages/next-on-fleek/package.json +++ b/packages/next-on-fleek/package.json @@ -1,7 +1,8 @@ { "name": "@fleek-platform/next-on-fleek", - "version": "1.13.3", - "bin": "./bin/index.js", + "version": "1.14.0", + "main": "./dist/index.js", + "module": "./dist/index.js", "exports": { ".": { "import": "./dist/api/index.js", diff --git a/packages/next-on-fleek/src/cli.ts b/packages/next-on-fleek/src/cli.ts index 9bc29890f..f72c0a8e3 100644 --- a/packages/next-on-fleek/src/cli.ts +++ b/packages/next-on-fleek/src/cli.ts @@ -2,73 +2,12 @@ import os from 'os'; import dedent from 'dedent-tabs'; import type { ChalkInstance } from 'chalk'; import chalk from 'chalk'; -import { join, resolve } from 'path'; import { getPackageManager } from 'package-manager-manager'; import { getPackageVersionOrNull, nextOnPagesVersion, - normalizePath, } from './utils'; -import { program, Option } from 'commander'; - -program - .description(`@fleek-platform/next-on-fleek CLI v.${nextOnPagesVersion}`) - .allowExcessArguments(false) - .configureHelp({ - commandUsage: () => '@fleek-platform/next-on-fleek [options]', - }) - .helpOption(undefined, 'Shows this help message') - .addHelpText( - 'after', - '\n' + - 'GitHub: https://github.com/fleek-platform/next-on-fleek\n' + - 'Docs: https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site', - ) - .addOption( - new Option('-e, --experimental-minify') - // Old flag that we kept in order not to introduce a breaking change, it is a noop one and should be removed in v2 - .hideHelp(), - ) - .addOption( - new Option( - '-d, --disableChunksDedup', - 'Disables the chunks deduplication (this option is generally useful only for debugging purposes)', - ) - // We don't currently document the disable chunks flag since we may need to significantly change the deduplication strategy - // when turbopack is introduces (see https://github.com/cloudflare/next-on-pages/pull/208/files#r1192279816) - .hideHelp(), - ) - .option( - '-s, --skip-build', - 'Skips the application Vercel build process (only runs the @fleek-platform/next-on-fleek build logic)', - ) - .option( - '-m, --disable-worker-minification', - 'Disables the minification of the _worker.js script performed to reduce its javascript size (this option is generally useful only for debugging purposes)', - ) - .option('-w, --watch', 'Automatically rebuilds when the project is edited') - .option('-c, --no-color', 'Disables colored console outputs') - .option( - '-i, --info', - 'Prints relevant details about the current system which can be used to report bugs', - ) - .option( - '-o, --outdir ', - 'Sets the directory to output the worker and static assets to', - join('.vercel', 'output', 'static'), - ) - .option( - '--custom-entrypoint ', - 'Wrap the generated worker for your application in a custom worker entrypoint', - ) - .enablePositionalOptions(false) - .version( - nextOnPagesVersion, - '-v, --version', - 'Shows the version of the package', - ); - export type CliOptions = { skipBuild?: boolean; experimentalMinify?: boolean; @@ -81,13 +20,6 @@ export type CliOptions = { customEntrypoint?: string; }; -export function parseCliArgs(): CliOptions { - program.parse(); - const args = program.opts(); - args.outdir = normalizePath(resolve(args.outdir)); - return args; -} - type LogOptions = { fromVercelCli?: boolean; spaced?: boolean; diff --git a/packages/next-on-fleek/src/index.ts b/packages/next-on-fleek/src/index.ts index 3112e9d28..47179bc4a 100644 --- a/packages/next-on-fleek/src/index.ts +++ b/packages/next-on-fleek/src/index.ts @@ -1,17 +1,15 @@ import { watch } from 'chokidar'; import pLimit from 'p-limit'; import type { CliOptions } from './cli'; -import { parseCliArgs, cliLog, cliWarn, cliError, printEnvInfo } from './cli'; +import { cliLog, cliWarn, cliError, printEnvInfo } from './cli'; import { buildApplication } from './buildApplication'; import { isWindows, nextOnPagesVersion } from './utils'; const limit = pLimit(1); -void runNextOnPages(); - -async function runNextOnPages(): Promise { - const args = parseCliArgs(); +export type { CliOptions }; +export async function runNextOnPages(args: CliOptions): Promise { if (args.info) { await printEnvInfo(); return;