-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide different package entrypoint (cli + lib)
- Loading branch information
Showing
9 changed files
with
740 additions
and
33 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2022. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import resolve from '@rollup/plugin-node-resolve'; | ||
import swc from '@rollup/plugin-swc'; | ||
import { builtinModules } from 'node:module'; | ||
import fs from "node:fs"; | ||
|
||
const extensions = [ | ||
'.js', '.mjs', '.cjs', '.ts', '.mts', '.cts' | ||
]; | ||
|
||
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), {encoding: 'utf-8'})); | ||
const external = Object.keys(pkg.dependencies || {}) | ||
.concat(Object.keys(pkg.peerDependencies || {})) | ||
.concat(builtinModules) | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
external, | ||
output: [ | ||
{ | ||
format: 'cjs', | ||
file: pkg.main, | ||
exports: 'named', | ||
sourcemap: true | ||
}, | ||
{ | ||
format: 'es', | ||
file: pkg.module, | ||
sourcemap: true | ||
} | ||
], | ||
plugins: [ | ||
// Allows node_modules resolution | ||
resolve({ extensions}), | ||
|
||
// Compile TypeScript/JavaScript files | ||
swc() | ||
] | ||
}, | ||
{ | ||
input: 'src/cli.ts', | ||
external, | ||
output: [ | ||
{ | ||
format: 'cjs', | ||
file: pkg.bin, | ||
exports: 'named', | ||
sourcemap: true | ||
} | ||
], | ||
plugins: [ | ||
// Allows node_modules resolution | ||
resolve({ extensions}), | ||
|
||
// Compile TypeScript/JavaScript files | ||
swc() | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Copyright (c) 2023. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import cac from 'cac'; | ||
import { registerCLIBuildCommand } from './commands/build'; | ||
import { registerCLIListCommand } from './commands/list'; | ||
import { registerCLIPushCommand } from './commands/push'; | ||
import { registerCLIWebhookCommand } from './commands/webhook'; | ||
|
||
const cli = cac('master-images'); | ||
|
||
registerCLIListCommand(cli); | ||
registerCLIBuildCommand(cli); | ||
registerCLIPushCommand(cli); | ||
registerCLIWebhookCommand(cli); | ||
|
||
cli.help(); | ||
cli.parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,4 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Copyright (c) 2023. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import cac from 'cac'; | ||
import { registerCLIBuildCommand } from './commands/build'; | ||
import { registerCLIListCommand } from './commands/list'; | ||
import { registerCLIPushCommand } from './commands/push'; | ||
import { registerCLIWebhookCommand } from './commands/webhook'; | ||
|
||
const cli = cac('master-images'); | ||
|
||
registerCLIListCommand(cli); | ||
registerCLIBuildCommand(cli); | ||
registerCLIPushCommand(cli); | ||
registerCLIWebhookCommand(cli); | ||
|
||
cli.help(); | ||
cli.parse(); | ||
export * from './constants'; | ||
export * from './config'; | ||
export * from './core'; | ||
export * from './utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters