Skip to content

Commit

Permalink
chore: adjust the package to be used through npx command
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Jul 30, 2024
1 parent cff055e commit 700bdfd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"access": "public"
},
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"bin": {
"figpot": "./dist/cli/index.js"
},
"types": "./dist/index.d.ts",
"scripts": {
"postinstall": "patch-package",
Expand Down
1 change: 1 addition & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import { program } from '@figpot/src/cli/program';
import { gracefulExit } from '@figpot/src/utils/system';

Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
import '@figpot/src/cli/index';
export * from '@figpot/src/features/document';

//
// This package is more intented to be used through the CLI directly `npx figpot ...` instead
// of imported to reuse functions, in the future we could add more exports
//
3 changes: 2 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import path from 'path';
import { defineConfig } from 'tsup';

const entryPattern = path.resolve(__dirname, 'src/index.ts');
const cliPattern = path.resolve(__dirname, 'src/cli/index.ts');

export default defineConfig((options) => {
return {
entry: [entryPattern],
entry: [entryPattern, cliPattern],
outDir: 'dist',
// Librairies like `change-case` are ESM-only and cannot be imported from a CJS package, so we decided to only package the ESM format
// It should be fine since `figpot` is intended to be used as a CLI, and not directly imported into third-party code
Expand Down

0 comments on commit 700bdfd

Please sign in to comment.