Skip to content

Commit

Permalink
Merge pull request #7 from patrickkabwe/refactor/cli
Browse files Browse the repository at this point in the history
Refactor/cli
  • Loading branch information
patrickkabwe authored Dec 1, 2024
2 parents 2a26a30 + 96e751f commit 81021fa
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 25 deletions.
7 changes: 7 additions & 0 deletions .changeset/shiny-lies-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'create-nitro-module': patch
---

- Fix bug where `bun create nitro-module [name]` was not working
- Minify the tsconfig file
- Update eslint rules to meet project needs
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"typescript": "bun --filter=\"**\" typescript",
"release": "release-it"
},
"workspaces": [],
"workspaces": [""],
"devDependencies": {
"@release-it/conventional-changelog": "^8.0.1",
"@release-it/bumper": "^6.0.1",
Expand Down
Binary file modified bun.lockb
Binary file not shown.
8 changes: 6 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default [
js.configs.recommended,
nodePlugin.configs['flat/recommended-script'],
{
files: ['src/**/*.ts'],
files: ['src/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
Expand All @@ -17,10 +17,14 @@ export default [
},
plugins: {
'@typescript-eslint': ts,
n: nodePlugin,
},
rules: {
...ts.configs.recommended.rules,
'n/hashbang': 'off',
},
ignores: ['lib/*', 'node_modules/*', 'src/assets/*'],
},
{
ignores: ['lib/', 'node_modules/', 'eslint.config.js'],
},
]
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
"nitro-modules",
"nitro-modules-cli"
],
"license": "MIT",
"bin": {
"create-nitro-module": "./lib/cli.js",
"nitro-module": "./lib/cli.js"
},
"scripts": {
"dev": "bun typecheck && tsx src/cli.ts",
"build": "bun typecheck && tsup src",
"build": "rm -rf lib && bun typecheck && tsup src",
"typecheck": "tsc --noEmit",
"changeset": "changeset",
"version": "changeset version",
"prerelease": "rm -rf ./lib/assets",
"release": "bun run build && bun version && changeset publish",
"lint": "eslint . --ignore-pattern 'eslint.config.js' --no-warn-ignored",
"lint": "eslint src/*.ts",
"format": "prettier --write src/*.ts"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

import { Command } from 'commander'
import packageJson from '../package.json' assert { type: 'json' }
import packageJson from '../package.json'
import { createModule, generateModule } from './create.js'

const program = new Command()
Expand All @@ -21,4 +23,4 @@ program
.description('generate a hybrid object into the package directory')
.action(generateModule)

program.parse()
program.allowUnknownOption().parse(process.argv)
2 changes: 1 addition & 1 deletion src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const createModule = async (name: string) => {
spinner.succeed(kleur.green('✨ Nitro Module created successfully!'))
} catch (error) {
spinner.fail(
kleur.red(`❌ Failed to create nitro module: ${error.message}`)
kleur.red(`❌ Failed to create nitro module: ${(error as Error).message}`)
)
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/generate-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from 'node:fs/promises'
import path from 'node:path'
import util from 'node:util'
import packageJsonFile from './assets/package.json' assert { type: 'json' }
import tsconfigFile from './assets/tsconfig.json' assert { type: 'json' }
import workspacePackageJsonFile from './assets/workspace-package.json' assert { type: 'json' }
import packageJsonFile from '../assets/package.json'
import tsconfigFile from '../assets/tsconfig.json'
import workspacePackageJsonFile from '../assets/workspace-package.json'
import { androidManifestCode, getKotlinCode } from './code.android.js'
import { getSwiftCode } from './code.ios.js'
import { appExampleCode, exportCode, specCode } from './code.js.js'
Expand Down Expand Up @@ -55,11 +55,11 @@ type PlatformLang = {
}

class FileGenerator {
private tmpDir: string
private tmpDir = ''
private cwd = process.cwd()
private packagePrefix = 'react-native-'
private moduleName: string
private androidPackageName: string
private moduleName = ''
private androidPackageName = ''

constructor() {}

Expand Down Expand Up @@ -199,7 +199,7 @@ class FileGenerator {

nitroJson = {
$schema:
'https://raw.githubusercontent.com/patrickkabwe/nitro-cli/refs/heads/main/src/assets/nitro-schema.json',
'https://raw.githubusercontent.com/patrickkabwe/nitro-cli/refs/heads/main/assets/nitro-schema.json',
...nitroJson,
autolinking: generateAutolinking(toPascalCase(this.moduleName), langs),
}
Expand Down
16 changes: 6 additions & 10 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"compilerOptions": {
"target": "es2021",
"module": "ESNext",
"outDir": "lib",
"noImplicitAny": true,
"diagnostics": false,
"noImplicitThis": true,
"noEmitOnError": true,
"moduleResolution": "bundler",
"strict": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"moduleResolution": "nodenext",
"lib": ["esnext", "es6", "dom"],
"target": "esnext",
"module": "NodeNext"
"skipLibCheck": false
},
"include": ["src"],
"exclude": ["node_modules", "assets"]
"exclude": ["node_modules", "lib"]
}

0 comments on commit 81021fa

Please sign in to comment.