Skip to content

Commit

Permalink
fix(package): use Bun if available and update workflow
Browse files Browse the repository at this point in the history
release-npm
  • Loading branch information
tobua committed Feb 11, 2024
1 parent ec5d313 commit cf6595e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 24 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ jobs:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- run: npm install
- name: 🧪 Test
run: npm test
- run: npm install -g npm@latest
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run test
- name: 📢 Release
uses: tobua/release-npm-action@v2
uses: tobua/release-npm-action@v3
with:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
package-lock.json
bun.lockb
jsconfig.json
test/download
.create-now-temporary
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Install template for compatible packages like this:
npm init --yes now papua
# or the same thing with npx
npx --yes create-now papua
# using Bun
bun create now papua
```

`--yes` avoids the prompt by `npm` to install this package.
Expand Down
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"ejs": "^3.1.9",
"find-cache-dir": "^5.0.0",
"isbinaryfile": "^5.0.0",
"logua": "^3.0.2",
"logua": "^3.0.3",
"node-fetch": "^3.3.2",
"prompts": "^2.4.2",
"temp-dir": "^3.0.0",
Expand All @@ -26,19 +26,22 @@
"is-png": "^3.0.1",
"jest-fixture": "^4.1.0",
"mock-stdin": "^1.0.0",
"padua": "^2.0.7",
"read-chunk": "^4.0.3",
"vitest": "^0.34.6"
"vitest": "^0.34.6",
"padua": "^2.0.9",
"read-chunk": "^4.0.3"
},
"type": "module",
"sideEffects": true,
"main": "index.js",
"main": "./index.js",
"exports": {
"default": "./index.js"
".": {
"types": "./index.d.ts",
"default": "./index.js"
}
},
"bin": "cli.js",
"source": "index.js",
"types": "index.d.ts",
"bin": "./cli.js",
"source": "./index.js",
"types": "./index.d.ts",
"files": [
"utility",
"*.js",
Expand Down
4 changes: 2 additions & 2 deletions test/install.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test('Dependencies are installed if there are any.', async () => {
const templateDirectory = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/dependencies')
join(process.cwd(), 'test/fixture/dependencies'),
)
const config = getConfig(templateDirectory)
writeFiles(destination, {}, templateDirectory)
Expand All @@ -29,7 +29,7 @@ test('Nothing installed if noInstall option is truthy.', async () => {
const templateDirectory = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/no-install')
join(process.cwd(), 'test/fixture/no-install'),
)
const config = getConfig(templateDirectory)
writeFiles(destination, {}, templateDirectory)
Expand Down
12 changes: 6 additions & 6 deletions test/template.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('Locates template in main directory.', async () => {
let templatePath = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/basic')
join(process.cwd(), 'test/fixture/basic'),
)

expect(templatePath).toEqual(join(process.cwd(), 'test/fixture/basic'))
Expand All @@ -48,7 +48,7 @@ test('Locates template in main directory.', async () => {
templatePath = await getTemplateDirectory(
'default',
undefined,
join(process.cwd(), 'test/fixture/basic')
join(process.cwd(), 'test/fixture/basic'),
)

expect(templatePath).toEqual(join(process.cwd(), 'test/fixture/basic'))
Expand All @@ -66,7 +66,7 @@ test('Recoginizes several templates are available.', async () => {
const templatePath = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/nested')
join(process.cwd(), 'test/fixture/nested'),
)

expect(templatePath).toEqual(join(process.cwd(), 'test/fixture/nested/second'))
Expand All @@ -79,7 +79,7 @@ test('Fails when given template not available.', async () => {
})

expect(
getTemplateDirectory('fourth', undefined, join(process.cwd(), 'test/fixture/nested'))
getTemplateDirectory('fourth', undefined, join(process.cwd(), 'test/fixture/nested')),
).rejects.toEqual(new Error('Exit'))

expect(mockProcessExit).toHaveBeenCalledWith(0)
Expand All @@ -89,7 +89,7 @@ test('Automatically selects first template if only one is available.', async ()
const templatePath = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/single')
join(process.cwd(), 'test/fixture/single'),
)

expect(templatePath).toEqual(join(process.cwd(), 'test/fixture/single/first'))
Expand All @@ -99,7 +99,7 @@ test('Automatically selects default template if no selection provided.', async (
const templatePath = await getTemplateDirectory(
undefined,
undefined,
join(process.cwd(), 'test/fixture/default')
join(process.cwd(), 'test/fixture/default'),
)
expect(templatePath).toEqual(join(process.cwd(), 'test/fixture/default/default'))
})
Expand Down
6 changes: 5 additions & 1 deletion utility/install-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export const installDependencies = (config, destination) => {

log('installing dependencies')

execSync('npm install --legacy-peer-deps', { stdio: 'inherit', cwd: destination })
if (typeof Bun !== 'undefined') {
execSync('bun install', { stdio: 'inherit', cwd: destination })
} else {
execSync('npm install', { stdio: 'inherit', cwd: destination })
}

log('dependencies installed')
}

0 comments on commit cf6595e

Please sign in to comment.