kapi-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/setup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import prompts from 'prompts';
3
- import { installKapi, injectVitePlugin } from './utils.js';
3
+ import { installKapi, injectVitePlugin, KAPI_PACKAGE_NAME } from './utils.js';
4
4
  async function setup() {
5
5
  console.log(`
6
6
  ██ ██ █████ ██████ ██
@@ -33,7 +33,7 @@ async function setup() {
33
33
  console.log(`
34
34
  Add this manually to your vite.config:
35
35
 
36
- import kapi from 'kapi/vite-plugin'
36
+ import kapi from '${KAPI_PACKAGE_NAME}/vite-plugin'
37
37
 
38
38
  export default defineConfig({
39
39
  plugins: [kapi()],
package/dist/utils.js CHANGED
@@ -6,20 +6,11 @@ import { fileURLToPath } from 'url';
6
6
  import { execSync } from 'child_process';
7
7
  // dist/utils.js -> package root (one level up from dist/)
8
8
  const kapiRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
9
- // kapi isn't published yet, so pack it into a tarball and install that
10
- // directly -- avoids the npm-link global-registration bootstrap problem
11
- // entirely, and installs like a real package (copied, not symlinked).
12
- function packKapi() {
13
- const pkg = JSON.parse(readFileSync(path.join(kapiRoot, 'package.json'), 'utf-8'));
14
- const tarballName = `${pkg.name}-${pkg.version}.tgz`;
15
- console.log('Packing kapi...');
16
- execSync('npm pack', { cwd: kapiRoot, stdio: 'inherit' });
17
- return path.join(kapiRoot, tarballName);
18
- }
9
+ const kapiPkg = JSON.parse(readFileSync(path.join(kapiRoot, 'package.json'), 'utf-8'));
10
+ export const KAPI_PACKAGE_NAME = kapiPkg.name;
19
11
  export function installKapi(cwd) {
20
- const tarballPath = packKapi();
21
- console.log('Installing kapi...');
22
- execSync(`npm install ${JSON.stringify(tarballPath)} -D`, { cwd, stdio: 'inherit' });
12
+ console.log(`Installing ${KAPI_PACKAGE_NAME}...`);
13
+ execSync(`npm install ${KAPI_PACKAGE_NAME} -D`, { cwd, stdio: 'inherit' });
23
14
  }
24
15
  export async function injectVitePlugin(cwd) {
25
16
  const candidates = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];
@@ -28,14 +19,15 @@ export async function injectVitePlugin(cwd) {
28
19
  throw new Error('No vite.config found.');
29
20
  }
30
21
  const configPath = path.join(cwd, configFile);
22
+ const importSpecifier = `${KAPI_PACKAGE_NAME}/vite-plugin`;
31
23
  const existingSource = readFileSync(configPath, 'utf-8');
32
- if (existingSource.includes('kapi/vite-plugin')) {
24
+ if (existingSource.includes(importSpecifier)) {
33
25
  console.log(`✔ kapi plugin already configured in ${configFile}`);
34
26
  return;
35
27
  }
36
28
  const mod = await loadFile(configPath);
37
29
  addVitePlugin(mod, {
38
- from: 'kapi/vite-plugin',
30
+ from: importSpecifier,
39
31
  imported: 'default',
40
32
  constructor: 'kapi'
41
33
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kapi-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Visually prompt your UI",
5
5
  "scripts": {
6
6
  "build": "tsc",