@treelocator/init 0.1.3 → 0.1.5

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 (2) hide show
  1. package/dist/index.js +43 -10
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -95,6 +95,11 @@ function updateViteConfig(configFile, framework) {
95
95
  console.log(pc.yellow("TreeLocatorJS babel plugin already configured in vite.config"));
96
96
  return;
97
97
  }
98
+ const babelConfig = `babel: {
99
+ plugins: [
100
+ ["@locator/babel-jsx/dist", { env: "development" }],
101
+ ],
102
+ }`;
98
103
  if (framework === "react") {
99
104
  const reactPluginRegex = /react\(\s*\)/;
100
105
  const reactPluginWithOptionsRegex = /react\(\s*\{/;
@@ -102,22 +107,50 @@ function updateViteConfig(configFile, framework) {
102
107
  content = content.replace(
103
108
  reactPluginRegex,
104
109
  `react({
105
- babel: {
106
- plugins: [
107
- ["@locator/babel-jsx/dist", { env: "development" }],
108
- ],
109
- },
110
+ ${babelConfig},
110
111
  })`
111
112
  );
112
113
  } else if (reactPluginWithOptionsRegex.test(content)) {
113
114
  content = content.replace(
114
115
  /react\(\s*\{/,
115
116
  `react({
116
- babel: {
117
- plugins: [
118
- ["@locator/babel-jsx/dist", { env: "development" }],
119
- ],
120
- },`
117
+ ${babelConfig},`
118
+ );
119
+ }
120
+ }
121
+ if (framework === "solid") {
122
+ const solidPluginRegex = /solidPlugin\(\s*\)/;
123
+ const solidPluginWithOptionsRegex = /solidPlugin\(\s*\{/;
124
+ if (solidPluginRegex.test(content)) {
125
+ content = content.replace(
126
+ solidPluginRegex,
127
+ `solidPlugin({
128
+ ${babelConfig},
129
+ })`
130
+ );
131
+ } else if (solidPluginWithOptionsRegex.test(content)) {
132
+ content = content.replace(
133
+ /solidPlugin\(\s*\{/,
134
+ `solidPlugin({
135
+ ${babelConfig},`
136
+ );
137
+ }
138
+ }
139
+ if (framework === "preact") {
140
+ const preactPluginRegex = /preact\(\s*\)/;
141
+ const preactPluginWithOptionsRegex = /preact\(\s*\{/;
142
+ if (preactPluginRegex.test(content)) {
143
+ content = content.replace(
144
+ preactPluginRegex,
145
+ `preact({
146
+ ${babelConfig},
147
+ })`
148
+ );
149
+ } else if (preactPluginWithOptionsRegex.test(content)) {
150
+ content = content.replace(
151
+ /preact\(\s*\{/,
152
+ `preact({
153
+ ${babelConfig},`
121
154
  );
122
155
  }
123
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treelocator/init",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Setup wizard for TreeLocatorJS - auto-configure component ancestry tracking",
5
5
  "bin": {
6
6
  "treelocatorjs": "./dist/index.js",
@@ -48,5 +48,5 @@
48
48
  "component-ancestry"
49
49
  ],
50
50
  "license": "MIT",
51
- "gitHead": "17ecb45a2605c14823ac3436b10ac1a3ab9bc62f"
51
+ "gitHead": "a384b97c630945b9a12588a9ca234e525c4a5d34"
52
52
  }