bestax-migrate 2.1.1 → 2.1.3
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/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/sources/react-bulma-components/specials.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/specials.js +50 -6
- package/dist/sources/react-bulma-components/styles.d.ts.map +1 -1
- package/dist/sources/react-bulma-components/styles.js +139 -31
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAqBxE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,MAAM,EAAE,GACnB,MAAM,EAAE,CAkBV;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAkB5D;AAED,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAqBxE,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,MAAM,EAAE,GACnB,MAAM,EAAE,CAkBV;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAkB5D;AAED,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AA4ID;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,KAAK,EACT,KAAK,GAAE,QAAwB,EAC/B,MAAM,GAAE,QAAyB,EAGjC,aAAa,GAAE,OAAO,eAAiC,GACtD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAyBzB;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,EAAE,EAAE,KAAK,EACT,aAAa,GAAE,CAAC,EAAE,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAA0B,GAC7E,OAAO,CAAC,IAAI,CAAC,CAqBf;AAYD,wBAAgB,SAAS,CACvB,EAAE,GAAE,KAAkD,GACrD,OAAO,CAkHT"}
|
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"specials.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/specials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAUL,KAAK,gBAAgB,EACtB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AA21BD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,EAClB,OAAO,EAAE,GAAG,GACX,aAAa,CAIf;AAED,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,QAAQ,CAGjE,CAAC"}
|
|
@@ -153,24 +153,68 @@ const SPECIALS = {
|
|
|
153
153
|
addTodo(ctx, path, 'prop:remove', '`remove` has a dynamic value; this can render as either a Button or a Delete cross — split the branch by hand');
|
|
154
154
|
return {};
|
|
155
155
|
},
|
|
156
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* Heading → Title / SubTitle / plain `.heading` paragraph, matching RBC's
|
|
158
|
+
* `title: !subtitle && !heading` / `subtitle: subtitle` — the *value* of
|
|
159
|
+
* each prop picks the target, not merely whether it was passed. Any
|
|
160
|
+
* statically-known literal resolves to a fixed truthiness at codemod time
|
|
161
|
+
* (a bare prop and `heading={true}`/`heading="heading"` are all truthy;
|
|
162
|
+
* `heading={false}`/`heading=""`/`heading={0}` are falsy and equivalent to
|
|
163
|
+
* the prop being absent), exactly as RBC evaluates the prop at runtime —
|
|
164
|
+
* this mirrors the Button `remove` handler so the two don't contradict each
|
|
165
|
+
* other on string/number literals. Only a genuine expression can't be
|
|
166
|
+
* resolved: it's left in place with a TODO and a conservative
|
|
167
|
+
* (Title/SubTitle, never the structural plain-element rewrite) fallback so
|
|
168
|
+
* the branch can be split by hand. The subtitle class is applied
|
|
169
|
+
* independently of heading in RBC, so a dynamic `subtitle` blocks the
|
|
170
|
+
* structural `heading` collapse — collapsing would silently drop it.
|
|
171
|
+
*/
|
|
157
172
|
heading(ctx, path, element) {
|
|
158
173
|
const headingAttr = findAttr(element, 'heading');
|
|
159
|
-
|
|
174
|
+
const subtitleAttr = findAttr(element, 'subtitle');
|
|
175
|
+
const headingLit = headingAttr ? literalValueOf(headingAttr) : undefined;
|
|
176
|
+
const subtitleLit = subtitleAttr ? literalValueOf(subtitleAttr) : undefined;
|
|
177
|
+
const headingDynamic = headingLit?.kind === 'expression';
|
|
178
|
+
const subtitleDynamic = subtitleLit?.kind === 'expression';
|
|
179
|
+
// A resolvable literal (boolean/string/number) collapses to its runtime
|
|
180
|
+
// truthiness; an expression stays dynamic.
|
|
181
|
+
const headingTruthy = !!headingLit && headingLit.kind !== 'expression' && !!headingLit.value;
|
|
182
|
+
const subtitleTruthy = !!subtitleLit && subtitleLit.kind !== 'expression' && !!subtitleLit.value;
|
|
183
|
+
// Dynamic values can't be resolved to a target: leave the prop on the
|
|
184
|
+
// element (so its expression survives for hand-splitting) plus a TODO.
|
|
185
|
+
if (subtitleDynamic) {
|
|
186
|
+
addTodo(ctx, path, 'prop:subtitle', '`subtitle` has a dynamic value; pick between Title / SubTitle by hand');
|
|
187
|
+
}
|
|
188
|
+
if (headingDynamic) {
|
|
189
|
+
addTodo(ctx, path, 'prop:heading', '`heading` has a dynamic value; when truthy it renders a plain `<p className="heading">` instead of Title/SubTitle — resolve by hand');
|
|
190
|
+
}
|
|
191
|
+
// A truthy literal `heading` collapses to a plain `.heading` paragraph —
|
|
192
|
+
// but only when `subtitle` isn't a dynamic value the collapse would drop.
|
|
193
|
+
// A truthy *literal* `subtitle` is safe to collapse: RBC applies its class
|
|
194
|
+
// independently, so it rides along on the paragraph as `heading subtitle`
|
|
195
|
+
// (dropping it would be the same silent loss the dynamic guard prevents).
|
|
196
|
+
if (headingTruthy && !subtitleDynamic) {
|
|
160
197
|
removeAttr(element, headingAttr);
|
|
161
|
-
const className = mergeClassName(ctx, path, element, 'heading', 'Heading');
|
|
198
|
+
const className = mergeClassName(ctx, path, element, subtitleTruthy ? 'heading subtitle' : 'heading', 'Heading');
|
|
162
199
|
const rest = stripModifierProps(ctx, path, attributesOf(element).filter(a => !['size', 'weight', 'spaced', 'subtitle'].includes(a.name.name)), 'Heading');
|
|
163
200
|
const replacement = plainElement(ctx.j, 'p', className, rest, element.children ?? []);
|
|
164
201
|
path.replace(replacement);
|
|
165
202
|
ctx.dirty = true;
|
|
166
203
|
return { replaced: true };
|
|
167
204
|
}
|
|
168
|
-
|
|
169
|
-
|
|
205
|
+
// A resolvable literal `heading` that didn't collapse (falsy, or truthy
|
|
206
|
+
// but blocked by a dynamic subtitle) behaves as if the prop were absent —
|
|
207
|
+
// drop it. A dynamic `heading` stays put (its TODO is already filed above).
|
|
208
|
+
if (headingLit && !headingDynamic) {
|
|
209
|
+
removeAttr(element, headingAttr);
|
|
210
|
+
ctx.dirty = true;
|
|
211
|
+
}
|
|
212
|
+
if (subtitleLit && !subtitleDynamic) {
|
|
170
213
|
removeAttr(element, subtitleAttr);
|
|
171
214
|
ctx.dirty = true;
|
|
172
|
-
return { target: 'SubTitle' };
|
|
215
|
+
return { target: subtitleTruthy ? 'SubTitle' : 'Title' };
|
|
173
216
|
}
|
|
217
|
+
// Dynamic subtitle (attr kept) or no subtitle → conservative Title.
|
|
174
218
|
return { target: 'Title' };
|
|
175
219
|
},
|
|
176
220
|
'level-side'(ctx, path, element) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/sources/react-bulma-components/styles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,gBAAgB,CAAC;AA+MrE,eAAO,MAAM,eAAe,EAAE,eA2R7B,CAAC"}
|
|
@@ -55,9 +55,43 @@ const OTHER_BULMA_IMPORT = /^\s*@import\s+['"][^'"]*bulma[^'"]*['"]/;
|
|
|
55
55
|
/**
|
|
56
56
|
* Third-party Bulma extension packages (`bulma-checkradio`, `bulma-switch`,
|
|
57
57
|
* …) — 0.9-era add-ons whose v1 compatibility varies; several are covered
|
|
58
|
-
* by the bestax extras.
|
|
58
|
+
* by the bestax extras. The `bulma-` package name must start at a specifier
|
|
59
|
+
* segment boundary (right after the quote/`~`, or after a `/`) so this does
|
|
60
|
+
* not also match a name that merely *contains* `bulma-`, like
|
|
61
|
+
* `react-bulma-components` (see EXTENSION_IMPORT's own regression test).
|
|
59
62
|
*/
|
|
60
|
-
const EXTENSION_IMPORT = /^\s*@import\s+['"][^'"]
|
|
63
|
+
const EXTENSION_IMPORT = /^\s*@import\s+['"](?:~|[^'"]*\/)?bulma-([\w-]+?)(?:\/|\.|['"])/;
|
|
64
|
+
/**
|
|
65
|
+
* The source library's own stylesheet. This is not a third-party extension:
|
|
66
|
+
* it is the library being migrated away from, and `deps.ts` removes its
|
|
67
|
+
* package.json entry in the same run, so leaving the import in place breaks
|
|
68
|
+
* the Sass build. Any `react-bulma-components/…` specifier is dead the same
|
|
69
|
+
* way — the documented v3 setup paths (the bundled CSS, the "advanced" Sass
|
|
70
|
+
* entry point), but also deep partials and extensionless forms — so, like
|
|
71
|
+
* `transform.ts`, we match on the package prefix rather than enumerating
|
|
72
|
+
* shapes. The prefix may be bare, `~`-prefixed, or a relative node_modules
|
|
73
|
+
* path (the Parcel form `ROOT_IMPORT` also supports).
|
|
74
|
+
*/
|
|
75
|
+
const RBC_STYLE_IMPORT = /^(\s*)@import\s+(['"])((?:\.\.?\/)+node_modules\/|~)?react-bulma-components\/[^'"]*\2\s*;?\s*$/;
|
|
76
|
+
/**
|
|
77
|
+
* The subset of RBC stylesheet imports that are the library's own *root*: the
|
|
78
|
+
* bare package specifier, the documented Sass entry point (`src/index`), and
|
|
79
|
+
* the bundled v3 CSS (`dist/react-bulma-components(.min).css`). These pull in
|
|
80
|
+
* the whole library, which `bulma/sass` supersedes — so when the file already
|
|
81
|
+
* has a Bulma root, dropping one of these loses nothing. A deep RBC partial
|
|
82
|
+
* (`src/components/navbar.sass`) is NOT a root: `bulma/sass` doesn't carry a
|
|
83
|
+
* given partial's styles, so removing one silently would drop CSS. We flag
|
|
84
|
+
* those instead (the package's "never a silent skip" rule).
|
|
85
|
+
*/
|
|
86
|
+
const RBC_ROOT_STYLESHEET = /^\s*@import\s+(['"])(?:(?:\.\.?\/)+node_modules\/|~)?react-bulma-components(?:\/src\/index(?:\.s[ac]ss)?|\/dist\/react-bulma-components(?:\.min)?\.css)?\1\s*;?\s*$/;
|
|
87
|
+
/**
|
|
88
|
+
* A Bulma module root already pulled in via `@use` — the file's own
|
|
89
|
+
* `@use 'bulma/sass'` (any prefix, configured or not) or the bestax bundle
|
|
90
|
+
* (`scss/bestax`, which itself loads `bulma/sass with (…)`). When one is
|
|
91
|
+
* present we must not emit a second root: a duplicate `bulma/sass` namespace,
|
|
92
|
+
* or reconfiguring an already-loaded module, is a hard Sass error.
|
|
93
|
+
*/
|
|
94
|
+
const USE_BULMA_ROOT = /^\s*@use\s+(['"])(?:~|(?:\.\.?\/)+node_modules\/)?(?:bulma\/sass|@allxsmith\/bestax-bulma\/(?:src\/)?scss\/bestax)\1/;
|
|
61
95
|
/** Any `$name: value;` declaration (with or without `!default`). */
|
|
62
96
|
const VAR_DECL = /^\s*\$([\w-]+)\s*:\s*(.+?)\s*(!default)?\s*;\s*$/;
|
|
63
97
|
/**
|
|
@@ -171,12 +205,23 @@ export const transformStyles = (filePath, source, collector, options) => {
|
|
|
171
205
|
const out = [];
|
|
172
206
|
let changed = false;
|
|
173
207
|
let extrasAdded = source.includes('@allxsmith/bestax-bulma/scss');
|
|
174
|
-
// Pass 1:
|
|
208
|
+
// Pass 1: locate the file's Bulma root and the safe leading variable
|
|
209
|
+
// overrides that fold into it. A real `bulma/…` @import root wins; otherwise
|
|
210
|
+
// the RBC stylesheet, which we rewrite into a root the same way — so a file
|
|
211
|
+
// that starts from RBC and one that starts from a bulma @import converge on
|
|
212
|
+
// the identical shape. A pre-existing `@use` root means we create no new one.
|
|
175
213
|
const rootImportIndex = lines.findIndex(line => ROOT_IMPORT.test(line));
|
|
214
|
+
const rbcRootIndex = lines.findIndex(line => RBC_STYLE_IMPORT.test(line) && !line.includes(TODO));
|
|
215
|
+
const hasUseBulmaRoot = lines.some(line => USE_BULMA_ROOT.test(line));
|
|
216
|
+
const foldTargetIndex = hasUseBulmaRoot
|
|
217
|
+
? -1
|
|
218
|
+
: rootImportIndex !== -1
|
|
219
|
+
? rootImportIndex
|
|
220
|
+
: rbcRootIndex;
|
|
176
221
|
const foldableVars = [];
|
|
177
222
|
const unsafeVarLines = [];
|
|
178
|
-
if (
|
|
179
|
-
for (let i = 0; i <
|
|
223
|
+
if (foldTargetIndex !== -1) {
|
|
224
|
+
for (let i = 0; i < foldTargetIndex; i += 1) {
|
|
180
225
|
const line = lines[i];
|
|
181
226
|
const match = line.match(VAR_DECL);
|
|
182
227
|
if (match && isFoldableValue(match[2])) {
|
|
@@ -188,36 +233,43 @@ export const transformStyles = (filePath, source, collector, options) => {
|
|
|
188
233
|
}
|
|
189
234
|
}
|
|
190
235
|
const folded = new Set(foldableVars.map(v => v.index));
|
|
236
|
+
/**
|
|
237
|
+
* Emit a Bulma module root at `indent` (folding the leading var overrides
|
|
238
|
+
* gathered above into `with (…)`, flagging any unsafe ones), then, in
|
|
239
|
+
* bestax mode, the extras. `prefix` is a preserved relative-path prefix
|
|
240
|
+
* (raw-file toolchains resolve paths, not package specifiers) or ''.
|
|
241
|
+
*/
|
|
242
|
+
const emitBulmaRoot = (indent, prefix, lineNo) => {
|
|
243
|
+
const bulmaSass = `${prefix}bulma/sass`;
|
|
244
|
+
if (foldableVars.length > 0) {
|
|
245
|
+
out.push(`${indent}@use '${bulmaSass}' with (`);
|
|
246
|
+
foldableVars.forEach(({ name, value }, index) => {
|
|
247
|
+
const comma = index < foldableVars.length - 1 ? ',' : '';
|
|
248
|
+
out.push(`${indent} $${name}: ${formatFoldedValue(value)}${comma}`);
|
|
249
|
+
});
|
|
250
|
+
out.push(`${indent});`);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
out.push(`${indent}@use '${bulmaSass}';`);
|
|
254
|
+
}
|
|
255
|
+
if (unsafeVarLines.length > 0) {
|
|
256
|
+
out.push(`${indent}// ${TODO}: the variable override(s) above use computed values; move them into the @use "bulma/sass" with (…) configuration by hand`);
|
|
257
|
+
report(collector, filePath, lineNo, 'sass', 'variable overrides with computed values could not be folded into `with (…)`');
|
|
258
|
+
}
|
|
259
|
+
if (cssMode === 'bestax' && !extrasAdded) {
|
|
260
|
+
out.push(prefix
|
|
261
|
+
? `${indent}@use '${prefix}@allxsmith/bestax-bulma/src/scss/extras';`
|
|
262
|
+
: `${indent}${EXTRAS_USE}`);
|
|
263
|
+
extrasAdded = true;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
191
266
|
for (let i = 0; i < lines.length; i += 1) {
|
|
192
267
|
const line = lines[i];
|
|
193
268
|
if (i === rootImportIndex) {
|
|
194
269
|
const rootMatch = line.match(ROOT_IMPORT);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
out.push(`${indent}@use '${bulmaSass}' with (`);
|
|
199
|
-
foldableVars.forEach(({ name, value }, index) => {
|
|
200
|
-
const comma = index < foldableVars.length - 1 ? ',' : '';
|
|
201
|
-
out.push(`${indent} $${name}: ${formatFoldedValue(value)}${comma}`);
|
|
202
|
-
});
|
|
203
|
-
out.push(`${indent});`);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
out.push(`${indent}@use '${bulmaSass}';`);
|
|
207
|
-
}
|
|
208
|
-
if (unsafeVarLines.length > 0) {
|
|
209
|
-
out.push(`${indent}// ${TODO}: the variable override(s) above use computed values; move them into the @use "bulma/sass" with (…) configuration by hand`);
|
|
210
|
-
report(collector, filePath, i + 1, 'sass', 'variable overrides with computed values could not be folded into `with (…)`');
|
|
211
|
-
}
|
|
212
|
-
if (cssMode === 'bestax' && !extrasAdded) {
|
|
213
|
-
// A path-prefixed root import means the toolchain resolves raw file
|
|
214
|
-
// paths, not package specifiers — point at the shipped file directly.
|
|
215
|
-
const extrasPrefix = keptPrefix(rootMatch?.[3]);
|
|
216
|
-
out.push(extrasPrefix
|
|
217
|
-
? `${indent}@use '${extrasPrefix}@allxsmith/bestax-bulma/src/scss/extras';`
|
|
218
|
-
: `${indent}${EXTRAS_USE}`);
|
|
219
|
-
extrasAdded = true;
|
|
220
|
-
}
|
|
270
|
+
// A path-prefixed root import means the toolchain resolves raw file
|
|
271
|
+
// paths, not package specifiers — point at the shipped files directly.
|
|
272
|
+
emitBulmaRoot(rootMatch?.[1] ?? '', keptPrefix(rootMatch?.[3]), i + 1);
|
|
221
273
|
changed = true;
|
|
222
274
|
continue;
|
|
223
275
|
}
|
|
@@ -263,6 +315,62 @@ export const transformStyles = (filePath, source, collector, options) => {
|
|
|
263
315
|
changed = true;
|
|
264
316
|
continue;
|
|
265
317
|
}
|
|
318
|
+
const rbcStyle = line.match(RBC_STYLE_IMPORT);
|
|
319
|
+
if (rbcStyle && !line.includes(TODO)) {
|
|
320
|
+
const indent = rbcStyle[1];
|
|
321
|
+
const prefix = keptPrefix(rbcStyle[3]);
|
|
322
|
+
if (i === rbcRootIndex && rootImportIndex === -1 && !hasUseBulmaRoot) {
|
|
323
|
+
// The library's own stylesheet never resolves post-migration (deps.ts
|
|
324
|
+
// removes react-bulma-components in the same run), and it is this
|
|
325
|
+
// file's only Bulma root, so rewrite it into one — the same shape the
|
|
326
|
+
// @import root path emits, folding any leading var overrides. Emitting
|
|
327
|
+
// a real `bulma/sass` (+ extras) rather than the hard-configured
|
|
328
|
+
// bestax bundle keeps this convergent with the @import path and avoids
|
|
329
|
+
// reconfiguring `bulma/sass` if a themed root exists elsewhere.
|
|
330
|
+
emitBulmaRoot(indent, prefix, i + 1);
|
|
331
|
+
if (cssMode === 'keep') {
|
|
332
|
+
// The replacement is unavoidable even in keep mode: RBC's own
|
|
333
|
+
// stylesheet is a v3 (Bulma 0.9) asset the migrated v1 components
|
|
334
|
+
// can't use. What changed depends on whether the manifest step ran.
|
|
335
|
+
const depsRan = options.deps !== false;
|
|
336
|
+
const detail = depsRan
|
|
337
|
+
? 'its package.json entry is removed, so the old import no longer resolves; install bulma@^1'
|
|
338
|
+
: 'it targets Bulma 0.9, not the v1 your components now use; --no-deps kept the dependency, so install bulma@^1 alongside it';
|
|
339
|
+
out.push(`${indent}// ${TODO}: replaced react-bulma-components's own stylesheet with @use 'bulma/sass' — ${detail} — see ${GUIDE}`);
|
|
340
|
+
report(collector, filePath, i + 1, 'sass', depsRan
|
|
341
|
+
? "replaced react-bulma-components's stylesheet import with bulma/sass; the package is removed from dependencies, so the old import would not resolve"
|
|
342
|
+
: "replaced react-bulma-components's stylesheet import with bulma/sass; it is a Bulma 0.9 asset the migrated v1 components can't use (--no-deps left the package in place)");
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
// bestax/bulma modes rewrite the file's root without a TODO — still
|
|
346
|
+
// report it so the migration summary reflects the restructured root.
|
|
347
|
+
report(collector, filePath, i + 1, 'sass', "replaced react-bulma-components's stylesheet import with a Bulma v1 @use root");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
// A Bulma root already covers this file (a `bulma/…` @import we
|
|
352
|
+
// convert, the file's own `@use` root, or an earlier RBC line we
|
|
353
|
+
// rewrote). In bestax mode keep that root and add only the extras —
|
|
354
|
+
// never a second root, never the configured bundle that would
|
|
355
|
+
// reconfigure an already-loaded module.
|
|
356
|
+
if (cssMode === 'bestax' && !extrasAdded) {
|
|
357
|
+
out.push(prefix
|
|
358
|
+
? `${indent}@use '${prefix}@allxsmith/bestax-bulma/src/scss/extras';`
|
|
359
|
+
: `${indent}${EXTRAS_USE}`);
|
|
360
|
+
extrasAdded = true;
|
|
361
|
+
}
|
|
362
|
+
// Dropping the RBC line is only safe for its root/index stylesheet,
|
|
363
|
+
// which `bulma/sass` supersedes. A deep RBC partial can carry styles
|
|
364
|
+
// `bulma/sass` doesn't, so removing it silently would lose CSS — flag
|
|
365
|
+
// it with a TODO + report entry instead (never a silent skip).
|
|
366
|
+
if (!RBC_ROOT_STYLESHEET.test(line)) {
|
|
367
|
+
out.push(`${indent}// ${TODO}: dropped a react-bulma-components stylesheet partial that has no Bulma v1 root equivalent; port any styles it carried beyond Bulma's own by hand — see ${GUIDE}`);
|
|
368
|
+
report(collector, filePath, i + 1, 'sass', 'react-bulma-components stylesheet partial dropped; port any styles it carried beyond Bulma’s own by hand');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
changed = true;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
266
374
|
if (OTHER_BULMA_IMPORT.test(line) && !line.includes(TODO)) {
|
|
267
375
|
const extension = line.match(EXTENSION_IMPORT);
|
|
268
376
|
if (extension) {
|
package/dist/types.d.ts
CHANGED
|
@@ -95,6 +95,13 @@ export type CssMode = 'bestax' | 'bulma' | 'keep';
|
|
|
95
95
|
export interface TransformOptions {
|
|
96
96
|
collector?: TodoCollector;
|
|
97
97
|
cssMode?: CssMode;
|
|
98
|
+
/**
|
|
99
|
+
* Whether the run also updates package.json (false under `--no-deps`).
|
|
100
|
+
* The stylesheet transform's messaging depends on it: it may only claim a
|
|
101
|
+
* dependency was removed when the manifest step actually runs. Undefined is
|
|
102
|
+
* treated as the CLI default (deps on).
|
|
103
|
+
*/
|
|
104
|
+
deps?: boolean;
|
|
98
105
|
[key: string]: unknown;
|
|
99
106
|
}
|
|
100
107
|
/** Options for the package.json dependency updater. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sEAAsE;IACtE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EA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