@olegkuibar/plunk 0.2.3 → 0.3.0-canary.0807dec

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.
Files changed (78) hide show
  1. package/dist/add-4LHIITHV.mjs +14 -0
  2. package/dist/chokidar-LVDD2IK4.mjs +4 -0
  3. package/dist/chunk-2VCW5RWI.mjs +3 -0
  4. package/dist/chunk-4QWBGXB5.mjs +15 -0
  5. package/dist/chunk-4TNTNSAB.mjs +4 -0
  6. package/dist/chunk-6YX2BGO2.mjs +3 -0
  7. package/dist/chunk-7JG555TZ.mjs +3 -0
  8. package/dist/chunk-AR7AKSKG.mjs +3 -0
  9. package/dist/chunk-HW7AEGI3.mjs +3 -0
  10. package/dist/chunk-KVVUZ6KL.mjs +4 -0
  11. package/dist/chunk-LI4HG26F.mjs +4 -0
  12. package/dist/chunk-MBKCCWSD.mjs +3 -0
  13. package/dist/chunk-OL7SNXMX.mjs +7 -0
  14. package/dist/chunk-QUI5JAIH.mjs +3 -0
  15. package/dist/chunk-RITKSDMP.mjs +3 -0
  16. package/dist/chunk-UAGG5WMD.mjs +3 -0
  17. package/dist/chunk-UDONDVIM.mjs +7 -0
  18. package/dist/chunk-ZAUWE3N7.mjs +12 -0
  19. package/dist/chunk-ZIXSXQRE.mjs +3 -0
  20. package/dist/chunk-ZJMZKJNW.mjs +3 -0
  21. package/dist/clean-EWBL6FW2.mjs +3 -0
  22. package/dist/cli.mjs +2 -56
  23. package/dist/dev-NCLIWE2E.mjs +3 -0
  24. package/dist/doctor-PXC45S34.mjs +4 -0
  25. package/dist/index.d.ts +19 -2
  26. package/dist/index.mjs +572 -244
  27. package/dist/init-TZ76GAWN.mjs +7 -0
  28. package/dist/list-CCR7QD7N.mjs +5 -0
  29. package/dist/migrate-6RZ3SEU5.mjs +8 -0
  30. package/dist/publish-4TDT6TTS.mjs +3 -0
  31. package/dist/push-M4RSFETI.mjs +3 -0
  32. package/dist/remove-R55FIXPL.mjs +3 -0
  33. package/dist/restore-XBFOHISI.mjs +11 -0
  34. package/dist/status-GCATYK2I.mjs +4 -0
  35. package/dist/tailwind-source-VPNLLSRJ.mjs +5 -0
  36. package/dist/update-6PLGM37S.mjs +3 -0
  37. package/dist/vite-config-ZMDIOTXC.mjs +10 -0
  38. package/dist/vite-plugin.mjs +2 -1
  39. package/dist/workspace-VREEJZ76.mjs +3 -0
  40. package/package.json +2 -8
  41. package/dist/add-5ZRFUL6Z.mjs +0 -258
  42. package/dist/chokidar-XGAEDN45.mjs +0 -1746
  43. package/dist/chunk-34UXZ622.mjs +0 -98
  44. package/dist/chunk-4O2QOKVO.mjs +0 -1958
  45. package/dist/chunk-CSMZ6DZA.mjs +0 -367
  46. package/dist/chunk-CZM4TNAI.mjs +0 -292
  47. package/dist/chunk-EDUXIQ5W.mjs +0 -1729
  48. package/dist/chunk-GAAB2TLH.mjs +0 -160
  49. package/dist/chunk-HKNM3UWU.mjs +0 -496
  50. package/dist/chunk-I6SN7BBN.mjs +0 -1131
  51. package/dist/chunk-KYDBD2KQ.mjs +0 -39
  52. package/dist/chunk-LKQINKH4.mjs +0 -130
  53. package/dist/chunk-PUSXMPOF.mjs +0 -82
  54. package/dist/chunk-S4HJSJ32.mjs +0 -69
  55. package/dist/chunk-W3C72UKC.mjs +0 -113
  56. package/dist/chunk-WSECI6M7.mjs +0 -85
  57. package/dist/chunk-XMIZ7OUZ.mjs +0 -26
  58. package/dist/chunk-XZK5T4GK.mjs +0 -23
  59. package/dist/chunk-ZOYNYK5Y.mjs +0 -23
  60. package/dist/chunk-ZQCGJUBJ.mjs +0 -92
  61. package/dist/clean-LTR5MZTY.mjs +0 -84
  62. package/dist/dev-LFXQP6SA.mjs +0 -194
  63. package/dist/dist-DUFCZSIL.mjs +0 -813
  64. package/dist/doctor-R7ZVR7PY.mjs +0 -230
  65. package/dist/hash-worker.mjs +0 -65
  66. package/dist/init-SWCNRISY.mjs +0 -310
  67. package/dist/list-B77L2F34.mjs +0 -119
  68. package/dist/migrate-X5TIC5SS.mjs +0 -124
  69. package/dist/prompt-HTPH6HQ7.mjs +0 -756
  70. package/dist/publish-UXCLPNM6.mjs +0 -63
  71. package/dist/push-JI6HGCFG.mjs +0 -197
  72. package/dist/remove-DCR7KKD5.mjs +0 -149
  73. package/dist/restore-SUN3WGSW.mjs +0 -124
  74. package/dist/status-MESRBH54.mjs +0 -103
  75. package/dist/tailwind-source-JBBEIXIJ.mjs +0 -89
  76. package/dist/update-SKDSA673.mjs +0 -100
  77. package/dist/vite-config-BAK67JHB.mjs +0 -128
  78. package/dist/workspace-76HJPAK2.mjs +0 -97
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import "./chunk-KYDBD2KQ.mjs";
4
-
5
- // src/utils/tailwind-source.ts
6
- import { readFile, readdir, writeFile } from "fs/promises";
7
- import { join, dirname, relative } from "path";
8
- var IGNORED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".plunk", "dist", ".git"]);
9
- async function findTailwindCss(projectRoot) {
10
- let entries;
11
- try {
12
- entries = await readdir(projectRoot, { recursive: true, encoding: "utf-8" });
13
- } catch {
14
- return null;
15
- }
16
- const cssFiles = entries.filter((entry) => {
17
- if (!entry.endsWith(".css")) return false;
18
- const parts = entry.replace(/\\/g, "/").split("/");
19
- return !parts.some((p) => IGNORED_DIRS.has(p));
20
- }).map((entry) => join(projectRoot, entry));
21
- for (const file of cssFiles) {
22
- let content;
23
- try {
24
- content = await readFile(file, "utf-8");
25
- } catch {
26
- continue;
27
- }
28
- if (content.includes('@import "tailwindcss"') || content.includes("@import 'tailwindcss'")) {
29
- return file;
30
- }
31
- }
32
- return null;
33
- }
34
- async function addTailwindSource(cssPath, packageName, projectRoot) {
35
- let content;
36
- try {
37
- content = await readFile(cssPath, "utf-8");
38
- } catch {
39
- return { modified: false, error: "could not read CSS file" };
40
- }
41
- if (content.includes(`node_modules/${packageName}`)) {
42
- return { modified: false };
43
- }
44
- const sourcePath = computeSourcePath(cssPath, packageName, projectRoot);
45
- const directiveRegex = /^@(import|source|plugin|theme)\s.+$/gm;
46
- let lastMatch = null;
47
- let match;
48
- while ((match = directiveRegex.exec(content)) !== null) {
49
- lastMatch = match;
50
- }
51
- const sourceLine = `@source "${sourcePath}";`;
52
- if (lastMatch) {
53
- const insertPos = lastMatch.index + lastMatch[0].length;
54
- content = content.slice(0, insertPos) + "\n" + sourceLine + content.slice(insertPos);
55
- } else {
56
- content = sourceLine + "\n" + content;
57
- }
58
- await writeFile(cssPath, content);
59
- return { modified: true };
60
- }
61
- async function removeTailwindSource(cssPath, packageName) {
62
- let content;
63
- try {
64
- content = await readFile(cssPath, "utf-8");
65
- } catch {
66
- return { modified: false };
67
- }
68
- const escaped = packageName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
69
- const sourceRegex = new RegExp(
70
- `^@source\\s+["'][^"']*node_modules/${escaped}["'];?\\s*\\n?`,
71
- "m"
72
- );
73
- if (!sourceRegex.test(content)) {
74
- return { modified: false };
75
- }
76
- content = content.replace(sourceRegex, "");
77
- await writeFile(cssPath, content);
78
- return { modified: true };
79
- }
80
- function computeSourcePath(cssPath, packageName, projectRoot) {
81
- const cssDir = dirname(cssPath);
82
- const targetPath = join(projectRoot, "node_modules", packageName);
83
- return relative(cssDir, targetPath).replace(/\\/g, "/");
84
- }
85
- export {
86
- addTailwindSource,
87
- findTailwindCss,
88
- removeTailwindSource
89
- };
@@ -1,100 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import {
4
- inject
5
- } from "./chunk-CZM4TNAI.mjs";
6
- import "./chunk-34UXZ622.mjs";
7
- import {
8
- addLink,
9
- readConsumerState
10
- } from "./chunk-GAAB2TLH.mjs";
11
- import {
12
- errorWithSuggestion
13
- } from "./chunk-S4HJSJ32.mjs";
14
- import {
15
- findStoreEntry
16
- } from "./chunk-W3C72UKC.mjs";
17
- import {
18
- Timer
19
- } from "./chunk-XZK5T4GK.mjs";
20
- import "./chunk-PUSXMPOF.mjs";
21
- import "./chunk-EDUXIQ5W.mjs";
22
- import {
23
- output,
24
- suppressHumanOutput
25
- } from "./chunk-ZOYNYK5Y.mjs";
26
- import {
27
- defineCommand
28
- } from "./chunk-CSMZ6DZA.mjs";
29
- import "./chunk-HKNM3UWU.mjs";
30
- import {
31
- consola,
32
- verbose
33
- } from "./chunk-I6SN7BBN.mjs";
34
- import "./chunk-KYDBD2KQ.mjs";
35
-
36
- // src/commands/update.ts
37
- import { resolve } from "path";
38
- var update_default = defineCommand({
39
- meta: {
40
- name: "update",
41
- description: "Pull latest versions from the store for linked packages"
42
- },
43
- args: {
44
- package: {
45
- type: "positional",
46
- description: "Package name to update (default: all linked)",
47
- required: false
48
- }
49
- },
50
- async run({ args }) {
51
- suppressHumanOutput();
52
- const timer = new Timer();
53
- const consumerPath = resolve(".");
54
- const state = await readConsumerState(consumerPath);
55
- const links = Object.entries(state.links);
56
- if (links.length === 0) {
57
- consola.info("No linked packages in this project");
58
- output({ updated: 0, skipped: 0 });
59
- return;
60
- }
61
- const toUpdate = args.package ? links.filter(([name]) => name === args.package) : links;
62
- if (args.package && toUpdate.length === 0) {
63
- errorWithSuggestion(`Package "${args.package}" is not linked in this project`);
64
- process.exit(1);
65
- }
66
- let updated = 0;
67
- let skipped = 0;
68
- for (const [packageName, link] of toUpdate) {
69
- const entry = await findStoreEntry(packageName);
70
- if (!entry) {
71
- consola.warn(`Store entry missing for ${packageName}. Re-publish it.`);
72
- continue;
73
- }
74
- if (entry.meta.contentHash === link.contentHash) {
75
- verbose(`[update] ${packageName}@${entry.version} already up to date`);
76
- skipped++;
77
- continue;
78
- }
79
- const result = await inject(entry, consumerPath, link.packageManager);
80
- const updatedLink = {
81
- ...link,
82
- version: entry.version,
83
- contentHash: entry.meta.contentHash,
84
- linkedAt: (/* @__PURE__ */ new Date()).toISOString()
85
- };
86
- await addLink(consumerPath, packageName, updatedLink);
87
- consola.success(
88
- `Updated ${packageName}@${entry.version} (${result.copied} files changed)`
89
- );
90
- updated++;
91
- }
92
- consola.info(
93
- `Update complete: ${updated} updated, ${skipped} unchanged in ${timer.elapsed()}`
94
- );
95
- output({ updated, skipped, elapsed: timer.elapsedMs() });
96
- }
97
- });
98
- export {
99
- update_default as default
100
- };
@@ -1,128 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import "./chunk-KYDBD2KQ.mjs";
4
-
5
- // src/utils/vite-config.ts
6
- import { readFile, writeFile } from "fs/promises";
7
- function detectIndent(content) {
8
- const match = content.match(/^(\s+)\S/m);
9
- return match?.[1] || " ";
10
- }
11
- function hasPlunkPlugin(content) {
12
- return content.includes("@olegkuibar/plunk/vite") || content.includes("vite-plugin-plunk");
13
- }
14
- function parsePluginItems(str) {
15
- const items = [];
16
- let current = "";
17
- let depth = 0;
18
- for (const ch of str) {
19
- if (ch === "(") depth++;
20
- if (ch === ")") depth--;
21
- if (ch === "," && depth === 0) {
22
- const trimmed2 = current.trim();
23
- if (trimmed2) items.push(trimmed2);
24
- current = "";
25
- } else {
26
- current += ch;
27
- }
28
- }
29
- const trimmed = current.trim();
30
- if (trimmed) items.push(trimmed);
31
- return items;
32
- }
33
- function formatPlugins(items, indent) {
34
- if (items.length === 0) return "[]";
35
- if (items.length === 1) return `[${items[0]}]`;
36
- const inner = items.map((i) => `${indent}${indent}${i},`).join("\n");
37
- return `[
38
- ${inner}
39
- ${indent}]`;
40
- }
41
- async function addPlunkVitePlugin(configPath) {
42
- let content;
43
- try {
44
- content = await readFile(configPath, "utf-8");
45
- } catch {
46
- return { modified: false, error: "could not read config file" };
47
- }
48
- if (hasPlunkPlugin(content)) {
49
- return { modified: false };
50
- }
51
- const indent = detectIndent(content);
52
- const pluginsRegex = /plugins\s*:\s*\[([\s\S]*?)\]/;
53
- const pluginsMatch = pluginsRegex.exec(content);
54
- if (pluginsMatch) {
55
- const items = parsePluginItems(pluginsMatch[1]);
56
- items.push("plunk()");
57
- const newPlugins = formatPlugins(items, indent);
58
- content = content.replace(pluginsRegex, `plugins: ${newPlugins}`);
59
- } else {
60
- const configObjRegex = /(?:defineConfig\s*\(\s*\{|export\s+default\s+\{)/;
61
- const configObjMatch = configObjRegex.exec(content);
62
- if (configObjMatch) {
63
- const insertPos = configObjMatch.index + configObjMatch[0].length;
64
- const newSection = `
65
- ${indent}plugins: [plunk()],`;
66
- content = content.slice(0, insertPos) + newSection + content.slice(insertPos);
67
- } else {
68
- return {
69
- modified: false,
70
- error: "unrecognized Vite config pattern"
71
- };
72
- }
73
- }
74
- const importLine = `import plunk from "@olegkuibar/plunk/vite";
75
- `;
76
- const lastImportRegex = /^import\s.+$/gm;
77
- let lastImportEnd = 0;
78
- let match;
79
- while ((match = lastImportRegex.exec(content)) !== null) {
80
- lastImportEnd = match.index + match[0].length;
81
- }
82
- if (lastImportEnd > 0) {
83
- content = content.slice(0, lastImportEnd) + "\n" + importLine + content.slice(lastImportEnd + 1);
84
- } else {
85
- content = importLine + "\n" + content;
86
- }
87
- await writeFile(configPath, content);
88
- return { modified: true };
89
- }
90
- async function removeFromViteConfig(configPath) {
91
- let content;
92
- try {
93
- content = await readFile(configPath, "utf-8");
94
- } catch {
95
- return { modified: false };
96
- }
97
- if (!hasPlunkPlugin(content)) {
98
- return { modified: false };
99
- }
100
- let modified = false;
101
- const importRegex = /^import\s+\w+\s+from\s+["']@olegkuibar\/plunk\/vite["'];?\s*\n?/m;
102
- if (importRegex.test(content)) {
103
- content = content.replace(importRegex, "");
104
- modified = true;
105
- }
106
- const pluginsRegex = /plugins\s*:\s*\[([\s\S]*?)\]/;
107
- const pluginsMatch = pluginsRegex.exec(content);
108
- if (pluginsMatch) {
109
- const items = parsePluginItems(pluginsMatch[1]);
110
- const filtered = items.filter(
111
- (item) => !item.startsWith("plunk(")
112
- );
113
- if (filtered.length !== items.length) {
114
- const indent = detectIndent(content);
115
- const newPlugins = formatPlugins(filtered, indent);
116
- content = content.replace(pluginsRegex, `plugins: ${newPlugins}`);
117
- modified = true;
118
- }
119
- }
120
- if (modified) {
121
- await writeFile(configPath, content);
122
- }
123
- return { modified };
124
- }
125
- export {
126
- addPlunkVitePlugin,
127
- removeFromViteConfig
128
- };
@@ -1,97 +0,0 @@
1
- #!/usr/bin/env node
2
- import{createRequire as __cr}from"node:module";globalThis.require=__cr(import.meta.url);
3
- import {
4
- exists
5
- } from "./chunk-HKNM3UWU.mjs";
6
- import "./chunk-I6SN7BBN.mjs";
7
- import "./chunk-KYDBD2KQ.mjs";
8
-
9
- // src/utils/workspace.ts
10
- import { readFile } from "fs/promises";
11
- import { join, dirname } from "path";
12
- async function findWorkspaceRoot(startDir) {
13
- let dir = startDir;
14
- for (; ; ) {
15
- if (await exists(join(dir, "pnpm-workspace.yaml"))) {
16
- return dir;
17
- }
18
- const parent = dirname(dir);
19
- if (parent === dir) return null;
20
- dir = parent;
21
- }
22
- }
23
- async function parseCatalogs(workspaceRoot) {
24
- const result = { default: {}, named: {} };
25
- const filePath = join(workspaceRoot, "pnpm-workspace.yaml");
26
- let content;
27
- try {
28
- content = await readFile(filePath, "utf-8");
29
- } catch {
30
- return result;
31
- }
32
- const lines = content.split(/\r?\n/);
33
- let state = "top";
34
- let currentNamedCatalog = "";
35
- for (const line of lines) {
36
- if (line.trim() === "" || line.trim().startsWith("#")) continue;
37
- const indent = line.length - line.trimStart().length;
38
- if (indent === 0) {
39
- if (line.startsWith("catalog:")) {
40
- state = "default-catalog";
41
- continue;
42
- }
43
- if (line.startsWith("catalogs:")) {
44
- state = "named-catalogs";
45
- continue;
46
- }
47
- state = "top";
48
- continue;
49
- }
50
- if (state === "default-catalog" && indent >= 2) {
51
- const kv = parseKeyValue(line);
52
- if (kv) result.default[kv[0]] = kv[1];
53
- continue;
54
- }
55
- if (state === "named-catalogs" && indent >= 2 && indent < 4) {
56
- const trimmed = line.trim();
57
- if (trimmed.endsWith(":")) {
58
- currentNamedCatalog = trimmed.slice(0, -1);
59
- result.named[currentNamedCatalog] = {};
60
- state = "named-catalog-entries";
61
- }
62
- continue;
63
- }
64
- if (state === "named-catalog-entries" && indent >= 4) {
65
- const kv = parseKeyValue(line);
66
- if (kv && currentNamedCatalog) {
67
- result.named[currentNamedCatalog][kv[0]] = kv[1];
68
- }
69
- continue;
70
- }
71
- if (state === "named-catalog-entries" && indent >= 2 && indent < 4) {
72
- const trimmed = line.trim();
73
- if (trimmed.endsWith(":")) {
74
- currentNamedCatalog = trimmed.slice(0, -1);
75
- result.named[currentNamedCatalog] = {};
76
- } else {
77
- state = "named-catalogs";
78
- }
79
- continue;
80
- }
81
- }
82
- return result;
83
- }
84
- function parseKeyValue(line) {
85
- const trimmed = line.trim();
86
- const colonIdx = trimmed.indexOf(":");
87
- if (colonIdx <= 0) return null;
88
- const key = trimmed.slice(0, colonIdx).trim();
89
- const value = trimmed.slice(colonIdx + 1).trim();
90
- if (!key || !value) return null;
91
- const unquoted = value.replace(/^["']|["']$/g, "");
92
- return [key, unquoted];
93
- }
94
- export {
95
- findWorkspaceRoot,
96
- parseCatalogs
97
- };