Skip to content

Commit

Permalink
chore: remove cli and expose entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmpinto committed Oct 4, 2024
1 parent 9d65518 commit 23a22eb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 80 deletions.
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/next-on-fleek/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
68 changes: 0 additions & 68 deletions packages/next-on-fleek/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <path>',
'Sets the directory to output the worker and static assets to',
join('.vercel', 'output', 'static'),
)
.option(
'--custom-entrypoint <path>',
'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;
Expand All @@ -81,13 +20,6 @@ export type CliOptions = {
customEntrypoint?: string;
};

export function parseCliArgs(): CliOptions {
program.parse();
const args = program.opts<CliOptions>();
args.outdir = normalizePath(resolve(args.outdir));
return args;
}

type LogOptions = {
fromVercelCli?: boolean;
spaced?: boolean;
Expand Down
8 changes: 3 additions & 5 deletions packages/next-on-fleek/src/index.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
const args = parseCliArgs();
export type { CliOptions };

export async function runNextOnPages(args: CliOptions): Promise<void> {
if (args.info) {
await printEnvInfo();
return;
Expand Down

0 comments on commit 23a22eb

Please sign in to comment.