Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/cli/bin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env node

import pkg from './package.json';
import { program } from 'commander';
import { add } from './commands/add.js';
import { create } from './commands/create.js';
import { helpConfig } from './common.js';

program.name(pkg.name).version(pkg.version, '-v').configureHelp(helpConfig);
program.addCommand(create).addCommand(add);
program.parse();
5 changes: 3 additions & 2 deletions packages/cli/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { exec } from 'tinyexec';
import * as p from '@svelte-cli/clack-prompts';
import { detect, AGENTS, type AgentName } from 'package-manager-detector';
import { COMMANDS, constructCommand } from 'package-manager-detector/commands';
import type { AdderWithoutExplicitArgs } from '@svelte-cli/core';
import type { AdderWithoutExplicitArgs, Precondition } from '@svelte-cli/core';
import type { Argument, HelpConfiguration, Option } from 'commander';

export const helpConfig: HelpConfiguration = {
Expand Down Expand Up @@ -114,11 +114,12 @@ async function installDependencies(command: string, args: string[], cwd: string)
}
}

type PreconditionCheck = { name: string; preconditions: Precondition[] };
export function getGlobalPreconditions(
cwd: string,
projectType: 'svelte' | 'kit',
adders: AdderWithoutExplicitArgs[]
) {
): PreconditionCheck {
return {
name: 'global checks',
preconditions: [
Expand Down
12 changes: 2 additions & 10 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#!/usr/bin/env node
import { create } from '@svelte-cli/create';

import pkg from './package.json';
import { program } from 'commander';
import { add } from './commands/add.js';
import { create } from './commands/create.js';
import { helpConfig } from './common.js';

program.name(pkg.name).version(pkg.version, '-v').configureHelp(helpConfig);
program.addCommand(create).addCommand(add);
program.parse();
export { create };
9 changes: 7 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
},
"license": "MIT",
"homepage": "https://kit.svelte.dev",
"bin": "./dist/index.js",
"main": "./dist/index.js",
"bin": "./dist/bin.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"dependencies": {
"@svelte-cli/core": "workspace:*"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"checkJs": false,
"isolatedDeclarations": true,
"declaration": true
},
// we'll only want to enforce `isolatedDeclarations` on the library portion of the CLI
"include": ["index.ts"]
}
4 changes: 3 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function getConfig(project) {
html: `${projectRoot}/tooling/html/index.ts`,
js: `${projectRoot}/tooling/js/index.ts`
};
} else if (project === 'cli') {
inputs = [`${projectRoot}/index.ts`, `${projectRoot}/bin.ts`];
} else {
inputs = [`${projectRoot}/index.ts`];
}
Expand Down Expand Up @@ -105,7 +107,7 @@ function getConfig(project) {
external,
plugins: [
preserveShebangs(),
'exports' in pkg && dts(),
'exports' in pkg && dts({ include: project === 'cli' ? [inputs[0]] : undefined }),
esbuild(),
nodeResolve({ preferBuiltins: true, rootDir: projectRoot }),
commonjs(),
Expand Down