-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
2,741 additions
and
6 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -13,4 +13,6 @@ debug.log | |
tempest.log | ||
public/static | ||
tests/Unit/Log | ||
log/ | ||
log/ | ||
node_modules | ||
dist |
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,3 @@ | ||
import defineEslintConfig from '@innocenzi/eslint-config' | ||
|
||
export default defineEslintConfig() |
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 @@ | ||
{ | ||
"private": true, | ||
"workspaces": ["packages/*"], | ||
"scripts": { | ||
"qa": "bun lint:fix && bun run test run && bun run build", | ||
"lint": "eslint packages", | ||
"lint:fix": "eslint --fix packages", | ||
"build": "bun --filter '*' build", | ||
"dev": "bun --filter '*' build:stub", | ||
"test": "vitest", | ||
"release": "bumpp package.json --push --tag --commit \"release: v\"" | ||
}, | ||
"devDependencies": { | ||
"@innocenzi/eslint-config": "^0.22.4", | ||
"@types/bun": "latest", | ||
"bumpp": "^9.9.0", | ||
"eslint": "^9.16.0", | ||
"typescript": "^5.7.2", | ||
"unbuild": "^2.0.0", | ||
"vite-plugin-tempest": "workspace:*", | ||
"vitest": "^2.1.8" | ||
} | ||
} |
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,9 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
|
||
export default defineBuildConfig({ | ||
entries: [ | ||
'src/index', | ||
], | ||
clean: true, | ||
declaration: true, | ||
}) |
Binary file not shown.
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,34 @@ | ||
{ | ||
"name": "vite-plugin-tempest", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"author": "Enzo Innocenzi", | ||
"license": "MIT", | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs" | ||
} | ||
}, | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"*.d.ts", | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "unbuild", | ||
"build:stub": "unbuild --stub", | ||
"test": "vitest" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0", | ||
"vite": "^6.0.3" | ||
}, | ||
"dependencies": { | ||
"@innocenzi/utils": "^0.3.0", | ||
"picocolors": "^1.1.1" | ||
} | ||
} |
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,14 @@ | ||
import { expect, test } from 'vitest' | ||
import { loadTempestConfiguration } from './config' | ||
import { mockTempestConfiguration } from './test-utils' | ||
|
||
test('the configuration can be loaded', async () => { | ||
mockTempestConfiguration() | ||
|
||
const config = await loadTempestConfiguration() | ||
|
||
expect(config).toHaveProperty('build_directory') | ||
expect(config).toHaveProperty('bridge_file_name') | ||
expect(config).toHaveProperty('manifest') | ||
expect(config).toHaveProperty('entrypoints') | ||
}) |
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,22 @@ | ||
import type { TempestViteConfiguration } from './types' | ||
import { exec, php } from './utils' | ||
|
||
const TEMPEST_BIN = 'tempest' | ||
const VITE_CONFIG_COMMAND = 'vite:config' | ||
|
||
export async function loadTempestConfiguration(): Promise<TempestViteConfiguration> { | ||
try { | ||
const { stdout } = await exec(`${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}`) | ||
const json = stdout.match(/\{.*\}/s) | ||
|
||
return JSON.parse(json?.[0] as string) | ||
} catch (e) { | ||
console.error(`Could not load configuration from [${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}].`) | ||
|
||
if ((e as any).stdout) { | ||
console.error((e as any).stdout) | ||
} | ||
|
||
throw e | ||
} | ||
} |
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,3 @@ | ||
export { default as tempest } from './plugin' | ||
export { default } from './plugin' | ||
export { type TempestViteConfiguration } from './types' |
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,37 @@ | ||
import { afterEach, describe, expect, it, vi } from 'vitest' | ||
import tempest from './plugin' | ||
import { mockTempestConfiguration } from './test-utils' | ||
|
||
describe('tempest', () => { | ||
afterEach(() => { | ||
vi.restoreAllMocks() | ||
}) | ||
|
||
it('it returns a Vite plugin', () => { | ||
mockTempestConfiguration() | ||
|
||
const plugin = tempest() | ||
|
||
expect(plugin).not.toBeNull() | ||
}) | ||
|
||
it('it outputs a config', async () => { | ||
mockTempestConfiguration({ | ||
build_directory: 'build/custom', | ||
bridge_file_name: 'custom-bridge', | ||
manifest: 'custom-manifest.json', | ||
entrypoints: ['src/main.ts'], | ||
}) | ||
|
||
const plugin = tempest() | ||
|
||
// @ts-expect-error typing | ||
const config = await plugin.config({}, { command: 'build' }) | ||
|
||
expect(config.base).toBe('/build/custom/') | ||
expect(config.build.manifest).toBe('custom-manifest.json') | ||
expect(config.build.rollupOptions).toEqual({ input: [ | ||
'src/main.ts', | ||
] }) | ||
}) | ||
}) |
Oops, something went wrong.