@sps-woodland/codemods 7.1.4 → 7.2.0
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/transform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function L(l,e){l.find(e.JSXOpeningElement).filter(s=>s.node.name.name==="KeyValueSetItem").forEach(s=>{const{itemKeyProp:a,titleColorProp:n,otherAttrs:r}=s.node.attributes.reduce((c,i)=>{switch(i.name.name){case"itemKey":c.itemKeyProp=i;break;case"titleColor":c.titleColorProp=i;break;default:c.otherAttrs.push(i)}return c},{itemKeyProp:null,titleColorProp:null,otherAttrs:[]});if(!n)return;const t=n.value.expression.property.name==="DARK"?e.jsxAttribute(e.jsxIdentifier("itemKey"),e.jsxExpressionContainer(e.arrowFunctionExpression([],e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("Box"),[e.jsxAttribute(e.jsxIdentifier("color"),e.literal("grey-dark"))],!1),e.jsxClosingElement(e.jsxIdentifier("Box")),[a.value.type==="JSXExpressionContainer"?a.value.expression.body:e.jsxText(a.value.value)])))):a;e(s).replaceWith(e.jsxOpeningElement(s.node.name,[t,...r],s.node.selfClosing))})}function g(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsMicroBlock").forEach(s=>{const{messageProp:a,otherAttrs:n}=s.value.openingElement.attributes.reduce((r,t)=>{switch(t.name.name){case"message":r.messageProp=t;break;default:r.otherAttrs.push(t)}return r},{messageProp:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsMicroBlock"),[e.jsxAttribute(e.jsxIdentifier("micro"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("SpsMicroBlock")),[e.jsxText(a.value.value)]))})}function O(l,e,o){const s=l.find(e.ImportDeclaration),a=new Map;for(const n of Object.keys(o.byOldPackage)){const r=o.byOldPackage[n];s.filter(t=>{var c;return((c=t.value)==null?void 0:c.type)==="ImportDeclaration"&&t.node.source.value===n}).forEach(t=>{const c=new Set,i=t.node.specifiers.filter(p=>r.hasOwnProperty(p.imported.name)?(c.add(p.imported.name),!1):!0),d=i.length===0,S=e(t);d||S.replaceWith(e.importDeclaration(i,t.node.source));const I=Array.from(c).reduce((p,u)=>{const{newName:m,newPackage:E}=r[u];return p.hasOwnProperty(E)||(p[E]=[]),p[E].push(m),p},{});for(const p of Object.keys(I)){const u=I[p];if(a.has(p)){const m=a.get(p),E=u.map(f=>e.importSpecifier(e.identifier(f))),T=e.importDeclaration([...m.node.specifiers,...E],m.node.source);a.set(p,T),e(m).replaceWith(T)}else{const m=e.importDeclaration(u.map(E=>e.importSpecifier(e.identifier(E))),e.literal(p));a.set(p,m),S.insertAfter(m)}}d&&S.remove()})}}function h(l,e,o){const s=l.find(e.JSXOpeningElement),a=l.find(e.JSXClosingElement);for(const[n,,r]of o.list)s.filter(t=>t.node.name.name===n).forEach(t=>{let{attributes:c}=t.node;if(o.props.hasOwnProperty(r)){const i=o.props[r];c=c.map(d=>i.hasOwnProperty(d.name.name)?e.jsxAttribute(e.jsxIdentifier(d.name.name),e.literal(i[d.name.name][d.value.expression.property.name])):d)}e(t).replaceWith(e.jsxOpeningElement(e.jsxIdentifier(r),c,t.node.selfClosing))}),a.filter(t=>t.node.name.name===n).forEach(t=>{e(t).replaceWith(e.jsxClosingElement(e.jsxIdentifier(r),t.node.attributes,t.node.selfClosing))})}const R=[["SpsCardV2","@spscommerce/ds-react","Card","@sps-woodland/cards"],["SpsCardV2Header","@spscommerce/ds-react","CardHeader","@sps-woodland/cards"],["SpsCardV2Title","@spscommerce/ds-react","CardTitle","@sps-woodland/cards"],["SpsCardV2Footer","@spscommerce/ds-react","CardFooter","@sps-woodland/cards"],["SpsClickableTag","@spscommerce/ds-react","ClickableTag","@sps-woodland/tags"],["SpsContentRow","@spscommerce/ds-react","ContentRow","@sps-woodland/content-row"],["SpsContentRowCol","@spscommerce/ds-react","ContentRowCol","@sps-woodland/content-row"],["SpsContentRowExpansion","@spscommerce/ds-react","ContentRowExpansion","@sps-woodland/content-row"],["SpsInsights","@spscommerce/ds-react","InsightCardSet","@sps-woodland/cards"],["SpsInsightTile","@spscommerce/ds-react","InsightCard","@sps-woodland/cards"],["SpsScrollableContainer","@spscommerce/ds-react","ScrollableContainer","@sps-woodland/cards"],["SpsApp","@spscommerce/ds-react","AppRoot","@sps-woodland/core"],["SpsI","@spscommerce/ds-react","Icon","@sps-woodland/core"],["SpsSpinner","@spscommerce/ds-react","Spinner","@sps-woodland/core"],["SpsVerticalRule","@spscommerce/ds-react","VerticalRule","@sps-woodland/core"],["SpsVr","@spscommerce/ds-react","Vr","@sps-woodland/core"],["I18nContext","@spscommerce/ds-react","I18nContext","@sps-woodland/core"],["bindProps","@spscommerce/ds-react","bindProps","@sps-woodland/core"],["contentOf","@spscommerce/ds-react","contentOf","@sps-woodland/core"],["Provide","@spscommerce/ds-react","Provide","@sps-woodland/core"],["selectChildren","@spscommerce/ds-react","selectChildren","@sps-woodland/core"],["usePatchReducer","@spscommerce/ds-react","usePatchReducer","@sps-woodland/core"],["SpsFeedbackBlock","@spscommerce/ds-react","FeedbackBlock","@sps-woodland/feedback-block"],["SpsMicroBlock","@spscommerce/ds-react","FeedbackBlock","@sps-woodland/feedback-block"],["SpsKeyValueList","@spscommerce/ds-react","KeyValueSet","@sps-woodland/key-value-set"],["SpsKeyValueListItem","@spscommerce/ds-react","KeyValueSetItem","@sps-woodland/key-value-set"],["SpsKeyValueTag","@spscommerce/ds-react","KeyValueTag","@sps-woodland/tags"],["SpsPageTitle","@spscommerce/ds-react","PageTitle","@sps-woodland/page-title"],["SpsPageSubtitle","@spscommerce/ds-react","PageSubtitle","@sps-woodland/page-title"],["SpsProductBar","@spscommerce/ds-react","ProductBar","@sps-woodland/product-bar"],["SpsProductBarTab","@spscommerce/ds-react","ProductBarTab","@sps-woodland/product-bar"],["SpsSlackLink","@spscommerce/ds-react","SlackLink","@sps-woodland/slack-link"],["SpsTabsV2","@spscommerce/ds-react","Tabs","@sps-woodland/tabs"],["SpsTileList","@spscommerce/ds-react","ContentTileList","@sps-woodland/content-tiles"],["SpsTile","@spscommerce/ds-react","ContentTile","@sps-woodland/content-tiles"],["SpsFilterTile","@spscommerce/ds-react","FilterTile","@sps-woodland/filter-tiles"],["SpsFilterTileList","@spscommerce/ds-react","FilterTileSet","@sps-woodland/filter-tiles"],["SpsSortingHeader","@spscommerce/ds-react","SortingHeader","@sps-woodland/sorting-header"],["SpsSortingHeaderCell","@spscommerce/ds-react","SortingHeaderCell","@sps-woodland/sorting-header"],["SpsTag","@spscommerce/ds-react","Tag","@sps-woodland/tags"],["SpsIllustrations","@spscommerce/ds-illustrations","Illustrations","@sps-woodland/illustrations"],["SpsZeroState","@spscommerce/ds-react","ZeroState","@sps-woodland/zero-state"],["SpsMicroZeroState","@spscommerce/ds-react","ZeroState","@sps-woodland/zero-state"],["rem","@spscommerce/ds-tokens","rem","@sps-woodland/tokens"],["border","@spscommerce/ds-tokens","border","@sps-woodland/tokens"],["grid","@spscommerce/ds-tokens","grid","@sps-woodland/tokens"],["sprinkles","@spscommerce/ds-tokens","sprinkles","@sps-woodland/tokens"],["Sprinkles","@spscommerce/ds-tokens","Sprinkles","@sps-woodland/tokens"],["Tokens","@spscommerce/ds-tokens","Tokens","@sps-woodland/tokens"]],C={ANGLE_LEFT:"angle-left",ANGLE_RIGHT:"angle-right",ARCHIVE:"archive",ARCHIVE_CIRCLE:"archive-circle",ARROW_DOWN:"arrow-down",ARROW_LEFT:"arrow-left",ARROW_LEFT_CIRCLE:"arrow-left-circle",ARROW_RIGHT:"arrow-right",ARROW_RIGHT_CIRCLE:"arrow-right-circle",ARROW_UP:"arrow-up",ASTERISK:"asterisk",ASTERISK_CIRCLE:"asterisk-circle",BAN:"ban",BAN_CIRCLE:"ban-circle",BARCODE:"barcode",BELL:"bell",BELL_FILLED:"bell-filled",BOLT:"bolt",BOOK:"book",BUILDING:"building",BURST:"burst",BURST_BOLT:"burst-bolt",CALENDAR:"calendar",CALENDAR_BLANK:"calendar-blank",CALENDAR_BLANK_CIRCLE:"calendar-blank-circle",CALENDAR_SELECT:"calendar-select",CAMERA:"camera",CHART_AREA:"chart-area",CHART_BAR:"chart-bar",CHART_LINE:"chart-line",CHART_PIE:"chart-pie",CHECKMARK:"checkmark",CHECKMARK_CIRCLE:"checkmark-circle",CHEVRON_DOWN:"chevron-down",CHEVRON_LEFT:"chevron-left",CHEVRON_RIGHT:"chevron-right",CHEVRON_UP:"chevron-up",CIRCLE_OUTLINE:"circle-outline",CLOCK:"clock",CLOCK_CIRCLE:"clock-circle",CODE_FORK:"code-fork",COLUMN_SWITCHER:"column-switcher",COMMENT_BUBBLE:"comment-bubble",COMMENT_BUBBLE_QUESTION:"comment-bubble-question",CONVERSATION:"conversation",CREDIT_CARD:"credit-card",DASHBOARD:"dashboard",DATABASE:"database",DESCENDING_ELLIPSES_CIRCLE:"descending-ellipses-circle",DISK:"disk",DISK_CIRCLE:"disk-circle",DOLLAR_SIGN:"dollar-sign",DOUBLE_ANGLE_LEFT:"double-angle-left",DOUBLE_ANGLE_RIGHT:"double-angle-right",DOWNLOAD_CLOUD:"download-cloud",DRILL:"drill",DUPLICATE:"duplicate",ELLIPSES:"ellipses",ENVELOPE:"envelope",EXCHANGE:"exchange",EXCLAMATION_CIRCLE:"exclamation-circle",EXCLAMATION_TRIANGLE:"exclamation-triangle",EXPAND_COLLAPSE:"expand-collapse",EYE:"eye",EYE_SLASH:"eye-slash",FILE:"file",FILE_DUPLICATE:"file-duplicate",FILE_PDF:"file-pdf",FILE_PRESENTATION:"file-presentation",FILE_SIZE:"file-size",FILE_SOLID:"file-solid",FILE_SOLID_TEXT:"file-solid-text",FILE_SPREADSHEET:"file-spreadsheet",FILE_TEXT:"file-text",FILTER:"filter",FLAG:"flag",FOLDER:"folder",FOLDER_OPEN:"folder-open",FOLDER_SOLID:"folder-solid",FOLDER_SOLID_OPEN:"folder-solid-open",GEAR:"gear",GLOBE:"globe",GRID:"grid",GROUP:"group",HAND_STOP:"hand-stop",HANDSHAKE:"handshake",HAT:"hat",HEART:"heart",HISTORY:"history",INBOX:"inbox",INCOMING:"incoming",INFO_CIRCLE:"info-circle",INTERCOM:"intercom",ITEM_TAG:"item-tag",KEY:"key",LIFE_PRESERVER:"life-preserver",LIGHTBULB:"lightbulb",LINK:"link",LINKEDIN:"linkedin",LIST:"list",LIST_CARDS:"list-cards",LIST_COLUMNS:"list-columns",LIST_SUMMARY:"list-summary",LIST_TABLE:"list-table",LOCATION:"location",LOCKED:"locked",LOCKED_CIRCLE:"locked-circle",MAP:"map",MAP_MARKER:"map-marker",MAXIMIZE:"maximize",MINIMIZE:"minimize",MINUS:"minus",MINUS_CIRCLE:"minus-circle",NEW_FILE:"new-file",NEW_SCREEN:"new-screen",OUTGOING:"outgoing",PAPER_PLANE:"paper-plane",PENCIL:"pencil",PHOTO:"photo",PIN:"pin",PINTEREST:"pinterest",PLAY:"play",PLUS_CIRCLE:"plus-circle",PLUS_SIGN:"plus-sign",PRESENTATION:"presentation",PRINTER:"printer",QR_CODE:"qr-code",QUESTION_CIRCLE:"question-circle",QUOTE_LEFT:"quote-left",QUOTE_RIGHT:"quote-right",RANDOM:"random",REFRESH:"refresh",RIGHT_CIRCLE:"right-circle",ROCKET:"rocket",SEARCH:"search",SEARCH_PLUS:"search-plus",SHARE:"share",SHOPPING_CART:"shopping-cart",SORT_ALPHA_ASC:"sort-alpha-asc",SORT_ALPHA_DESC:"sort-alpha-desc",SORT_NUM_ASC:"sort-num-asc",SORT_NUM_DESC:"sort-num-desc",STAR:"star",STAR_OUTLINE:"star-outline",STATUS_ARCHIVED:"status-archived",STATUS_CANCELLED:"status-cancelled",STATUS_ERROR:"status-error",STATUS_IN_PROCESS:"status-in-process",STATUS_IN_TRANSIT:"status-in-transit",STATUS_LOCKED:"status-locked",STATUS_NEW:"status-new",STATUS_OK:"status-ok",STATUS_ON_HOLD:"status-on-hold",STATUS_OUTDATED:"status-outdated",STATUS_REJECTED:"status-rejected",STATUS_SAVED:"status-saved",STATUS_SAVING:"status-saving",STATUS_TEMPLATE:"status-template",STATUS_WARNING:"status-warning",TABLE:"table",TABS:"tabs",TAG:"tag",TEMPLATE_CIRCLE:"template-circle",THUMBS_DOWN:"thumbs-down",THUMBS_DOWN_OUTLINE:"thumbs-down-outline",THUMBS_UP:"thumbs-up",THUMBS_UP_OUTLINE:"thumbs-up-outline",TRASH:"trash",TRUCK_SHIPPING:"truck-shipping",TWITTER:"twitter",UNDO:"undo",UNLOCKED:"unlocked",UPLOAD_CLOUD:"upload-cloud",USER:"user",USER_IMPERSONATION:"user-impersonation",WRENCH:"wrench",X:"x",X_CIRCLE:"x-circle"},_={Icon:{icon:C,size:{EXTRA_SMALL:"xs",SMALL:"sm",MEDIUM:"md",LARGE:"lg",EXTRA_LARGE:"lg"}},InsightCard:{icon:C,kind:{GENERAL:"general",SUCCESS:"success",ERROR:"error",WARNING:"warning",PROCESSING:"processing"}},Spinner:{size:{SMALL:"sm",MEDIUM:"md",LARGE:"lg"}},FeedbackBlock:{kind:{TIP:"tip",SUCCESS:"success",WARNING:"warning",ERROR:"error",INFO:"info"}},Tag:{kind:{DEFAULT:"default",KEY:"key",WARNING:"warning",ERROR:"error",PENDING:"pending",SUCCESS:"success",INFO:"info"}},ClickableTag:{kind:{BLUE:"blue",GRAY:"gray"}}};function k(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="Tag").forEach(s=>{const{iconProp:a,otherAttrs:n}=s.value.openingElement.attributes.reduce((r,t)=>{switch(t.name.name){case"icon":r.iconProp=t;break;default:r.otherAttrs.push(t)}return r},{iconProp:null,otherAttrs:[]});a&&e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("Tag"),[e.jsxAttribute(e.jsxIdentifier("icon"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("Tag"))))})}function N(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="KeyValueTag").forEach(s=>{const{iconProp:a,otherAttrs:n}=s.value.openingElement.attributes.reduce((r,t)=>{switch(t.name.name){case"icon":r.iconProp=t;break;default:r.otherAttrs.push(t)}return r},{iconProp:null,otherAttrs:[]});a&&e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("KeyValueTag"),[e.jsxAttribute(e.jsxIdentifier("icon"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("KeyValueTag"))))})}function b(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsMicroZeroState").forEach(s=>{const{attrs:a}=s.value.openingElement.attributes.reduce((n,r)=>(n.attrs.push(r),n),{attrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsMicroZeroState"),[e.jsxAttribute(e.jsxIdentifier("micro"),null),...a],!0)))})}function w(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsProductBar").forEach(s=>{const{productName:a,nameClick:n,logoSrc:r,productLink:t,otherAttrs:c}=s.value.openingElement.attributes.reduce((i,d)=>{switch(d.name.name){case"productName":i.productName=d;break;case"onProductNameClick":i.nameClick=d;break;case"productLogoSrc":i.logoSrc=d;break;case"productNameHref":i.productLink=d;break;case"tabs":break;case"activeTabs":break;case"onTabChange":break;default:i.otherAttrs.push(d)}return i},{productName:null,nameClick:null,logoSrc:null,productLink:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsProductBar"),[...c],!1),e.jsxClosingElement(e.jsxIdentifier("SpsProductBar")),[e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("ProductBarName"),[e.jsxAttribute(e.jsxIdentifier("name"),e.literal(a.value.value)),e.jsxAttribute(e.jsxIdentifier("logoSrc"),e.literal(r.value.value)),n&&e.jsxAttribute(e.jsxIdentifier("onClick"),n.value),t&&e.jsxAttribute(e.jsxIdentifier("href"),e.literal(t.value.value))].filter(Boolean),!0)),...s.node.children]))})}function P(l,e){l.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="ProductBarTab").forEach(s=>{const{clickHandler:a,otherAttrs:n}=s.value.openingElement.attributes.reduce((r,t)=>{switch(t.name.name){case"onClick":r.clickHandler=t;break;default:r.otherAttrs.push(t)}return r},{clickHandler:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("ProductBarTab"),[e.jsxAttribute(e.jsxIdentifier("onPress"),a.value),...n],!1),e.jsxClosingElement(e.jsxIdentifier("ProductBarTab")),[...s.node.children]))})}const x=R.reduce((l,[e,o,s,a])=>{let n=l[o];return n||(n={},l[o]=n),n[e]={newName:s,newPackage:a},l},{}),A={list:R,byOldPackage:x,props:_};function D(l,{jscodeshift:e}){const o=e(l.source);return b(o,e),w(o,e),g(o,e),O(o,e,A),h(o,e,A),P(o,e),L(o,e),k(o,e),N(o,e),o.toSource()}module.exports=D;
|
|
1
|
+
"use strict";function g(a,e){a.find(e.JSXOpeningElement).filter(s=>s.node.name.name==="KeyValueSetItem").forEach(s=>{const{itemKeyProp:r,titleColorProp:n,otherAttrs:o}=s.node.attributes.reduce((c,i)=>{switch(i.name.name){case"itemKey":c.itemKeyProp=i;break;case"titleColor":c.titleColorProp=i;break;default:c.otherAttrs.push(i)}return c},{itemKeyProp:null,titleColorProp:null,otherAttrs:[]});if(!n)return;const t=n.value.expression.property.name==="DARK"?e.jsxAttribute(e.jsxIdentifier("itemKey"),e.jsxExpressionContainer(e.arrowFunctionExpression([],e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("Box"),[e.jsxAttribute(e.jsxIdentifier("color"),e.literal("grey-dark"))],!1),e.jsxClosingElement(e.jsxIdentifier("Box")),[r.value.type==="JSXExpressionContainer"?r.value.expression.body:e.jsxText(r.value.value)])))):r;e(s).replaceWith(e.jsxOpeningElement(s.node.name,[t,...o],s.node.selfClosing))})}function O(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsMicroBlock").forEach(s=>{const{messageProp:r,otherAttrs:n}=s.value.openingElement.attributes.reduce((o,t)=>{switch(t.name.name){case"message":o.messageProp=t;break;default:o.otherAttrs.push(t)}return o},{messageProp:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsMicroBlock"),[e.jsxAttribute(e.jsxIdentifier("micro"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("SpsMicroBlock")),[e.jsxText(r.value.value)]))})}function h(a,e,l){const s=a.find(e.ImportDeclaration),r=new Map;for(const n of Object.keys(l.byOldPackage)){const o=l.byOldPackage[n];s.filter(t=>{var c;return((c=t.value)==null?void 0:c.type)==="ImportDeclaration"&&t.node.source.value===n}).forEach(t=>{const c=new Set,i=t.node.specifiers.filter(p=>o.hasOwnProperty(p.imported.name)?(c.add(p.imported.name),!1):!0),d=i.length===0,S=e(t);d||S.replaceWith(e.importDeclaration(i,t.node.source,t.node.importKind));const I=Array.from(c).reduce((p,u)=>{const{newName:m,newPackage:E}=o[u];return p.hasOwnProperty(E)||(p[E]=[]),p[E].push(m),p},{});for(const p of Object.keys(I)){const u=I[p];if(r.has(p)){const m=r.get(p),E=u.map(L=>e.importSpecifier(e.identifier(L))),T=e.importDeclaration([...m.node.specifiers,...E],m.node.source);r.set(p,T),e(m).replaceWith(T)}else{const m=e.importDeclaration(u.map(E=>e.importSpecifier(e.identifier(E))),e.literal(p));r.set(p,m),S.insertAfter(m)}}d&&S.remove()})}}function _(a,e,l){const s=a.find(e.JSXOpeningElement),r=a.find(e.JSXClosingElement);for(const[n,,o]of l.list)s.filter(t=>t.node.name.name===n).forEach(t=>{let{attributes:c}=t.node;if(l.props.hasOwnProperty(o)){const i=l.props[o];c=c.map(d=>i.hasOwnProperty(d.name.name)?e.jsxAttribute(e.jsxIdentifier(d.name.name),e.literal(i[d.name.name][d.value.expression.property.name])):d)}e(t).replaceWith(e.jsxOpeningElement(e.jsxIdentifier(o),c,t.node.selfClosing))}),r.filter(t=>t.node.name.name===n).forEach(t=>{e(t).replaceWith(e.jsxClosingElement(e.jsxIdentifier(o),t.node.attributes,t.node.selfClosing))})}const R=[["SpsCardV2","@spscommerce/ds-react","Card","@sps-woodland/cards"],["SpsCardV2Header","@spscommerce/ds-react","CardHeader","@sps-woodland/cards"],["SpsCardV2Title","@spscommerce/ds-react","CardTitle","@sps-woodland/cards"],["SpsCardV2Footer","@spscommerce/ds-react","CardFooter","@sps-woodland/cards"],["SpsClickableTag","@spscommerce/ds-react","ClickableTag","@sps-woodland/tags"],["SpsContentRow","@spscommerce/ds-react","ContentRow","@sps-woodland/content-row"],["SpsContentRowCol","@spscommerce/ds-react","ContentRowCol","@sps-woodland/content-row"],["SpsContentRowExpansion","@spscommerce/ds-react","ContentRowExpansion","@sps-woodland/content-row"],["SpsInsights","@spscommerce/ds-react","InsightCardSet","@sps-woodland/cards"],["SpsInsightTile","@spscommerce/ds-react","InsightCard","@sps-woodland/cards"],["SpsScrollableContainer","@spscommerce/ds-react","ScrollableContainer","@sps-woodland/cards"],["SpsApp","@spscommerce/ds-react","AppRoot","@sps-woodland/core"],["SpsI","@spscommerce/ds-react","Icon","@sps-woodland/core"],["SpsSpinner","@spscommerce/ds-react","Spinner","@sps-woodland/core"],["SpsVerticalRule","@spscommerce/ds-react","VerticalRule","@sps-woodland/core"],["SpsVr","@spscommerce/ds-react","Vr","@sps-woodland/core"],["I18nContext","@spscommerce/ds-react","I18nContext","@sps-woodland/core"],["bindProps","@spscommerce/ds-react","bindProps","@sps-woodland/core"],["contentOf","@spscommerce/ds-react","contentOf","@sps-woodland/core"],["Provide","@spscommerce/ds-react","Provide","@sps-woodland/core"],["selectChildren","@spscommerce/ds-react","selectChildren","@sps-woodland/core"],["usePatchReducer","@spscommerce/ds-react","usePatchReducer","@sps-woodland/core"],["SpsFeedbackBlock","@spscommerce/ds-react","FeedbackBlock","@sps-woodland/feedback-block"],["SpsMicroBlock","@spscommerce/ds-react","FeedbackBlock","@sps-woodland/feedback-block"],["SpsKeyValueList","@spscommerce/ds-react","KeyValueSet","@sps-woodland/key-value-set"],["SpsKeyValueListItem","@spscommerce/ds-react","KeyValueSetItem","@sps-woodland/key-value-set"],["SpsKeyValueTag","@spscommerce/ds-react","KeyValueTag","@sps-woodland/tags"],["SpsPageTitle","@spscommerce/ds-react","PageTitle","@sps-woodland/page-title"],["SpsPageSubtitle","@spscommerce/ds-react","PageSubtitle","@sps-woodland/page-title"],["SpsProductBar","@spscommerce/ds-react","ProductBar","@sps-woodland/product-bar"],["SpsProductBarTab","@spscommerce/ds-react","ProductBarTab","@sps-woodland/product-bar"],["SpsSlackLink","@spscommerce/ds-react","SlackLink","@sps-woodland/slack-link"],["SpsTabsV2","@spscommerce/ds-react","Tabs","@sps-woodland/tabs"],["SpsTileList","@spscommerce/ds-react","ContentTileList","@sps-woodland/content-tiles"],["SpsTile","@spscommerce/ds-react","ContentTile","@sps-woodland/content-tiles"],["SpsFilterTile","@spscommerce/ds-react","FilterTile","@sps-woodland/filter-tiles"],["SpsFilterTileList","@spscommerce/ds-react","FilterTileSet","@sps-woodland/filter-tiles"],["SpsSortingHeader","@spscommerce/ds-react","SortingHeader","@sps-woodland/sorting-header"],["SpsSortingHeaderCell","@spscommerce/ds-react","SortingHeaderCell","@sps-woodland/sorting-header"],["SpsTag","@spscommerce/ds-react","Tag","@sps-woodland/tags"],["SpsIllustrations","@spscommerce/ds-illustrations","Illustrations","@sps-woodland/illustrations"],["SpsZeroState","@spscommerce/ds-react","ZeroState","@sps-woodland/zero-state"],["SpsMicroZeroState","@spscommerce/ds-react","ZeroState","@sps-woodland/zero-state"],["rem","@spscommerce/ds-tokens","rem","@sps-woodland/tokens"],["border","@spscommerce/ds-tokens","border","@sps-woodland/tokens"],["grid","@spscommerce/ds-tokens","grid","@sps-woodland/tokens"],["sprinkles","@spscommerce/ds-tokens","sprinkles","@sps-woodland/tokens"],["Sprinkles","@spscommerce/ds-tokens","Sprinkles","@sps-woodland/tokens"],["Tokens","@spscommerce/ds-tokens","Tokens","@sps-woodland/tokens"]],C={ANGLE_LEFT:"angle-left",ANGLE_RIGHT:"angle-right",ARCHIVE:"archive",ARCHIVE_CIRCLE:"archive-circle",ARROW_DOWN:"arrow-down",ARROW_LEFT:"arrow-left",ARROW_LEFT_CIRCLE:"arrow-left-circle",ARROW_RIGHT:"arrow-right",ARROW_RIGHT_CIRCLE:"arrow-right-circle",ARROW_UP:"arrow-up",ASTERISK:"asterisk",ASTERISK_CIRCLE:"asterisk-circle",BAN:"ban",BAN_CIRCLE:"ban-circle",BARCODE:"barcode",BELL:"bell",BELL_FILLED:"bell-filled",BOLT:"bolt",BOOK:"book",BUILDING:"building",BURST:"burst",BURST_BOLT:"burst-bolt",CALENDAR:"calendar",CALENDAR_BLANK:"calendar-blank",CALENDAR_BLANK_CIRCLE:"calendar-blank-circle",CALENDAR_SELECT:"calendar-select",CAMERA:"camera",CHART_AREA:"chart-area",CHART_BAR:"chart-bar",CHART_LINE:"chart-line",CHART_PIE:"chart-pie",CHECKMARK:"checkmark",CHECKMARK_CIRCLE:"checkmark-circle",CHEVRON_DOWN:"chevron-down",CHEVRON_LEFT:"chevron-left",CHEVRON_RIGHT:"chevron-right",CHEVRON_UP:"chevron-up",CIRCLE_OUTLINE:"circle-outline",CLOCK:"clock",CLOCK_CIRCLE:"clock-circle",CODE_FORK:"code-fork",COLUMN_SWITCHER:"column-switcher",COMMENT_BUBBLE:"comment-bubble",COMMENT_BUBBLE_QUESTION:"comment-bubble-question",CONVERSATION:"conversation",CREDIT_CARD:"credit-card",DASHBOARD:"dashboard",DATABASE:"database",DESCENDING_ELLIPSES_CIRCLE:"descending-ellipses-circle",DISK:"disk",DISK_CIRCLE:"disk-circle",DOLLAR_SIGN:"dollar-sign",DOUBLE_ANGLE_LEFT:"double-angle-left",DOUBLE_ANGLE_RIGHT:"double-angle-right",DOWNLOAD_CLOUD:"download-cloud",DRILL:"drill",DUPLICATE:"duplicate",ELLIPSES:"ellipses",ENVELOPE:"envelope",EXCHANGE:"exchange",EXCLAMATION_CIRCLE:"exclamation-circle",EXCLAMATION_TRIANGLE:"exclamation-triangle",EXPAND_COLLAPSE:"expand-collapse",EYE:"eye",EYE_SLASH:"eye-slash",FILE:"file",FILE_DUPLICATE:"file-duplicate",FILE_PDF:"file-pdf",FILE_PRESENTATION:"file-presentation",FILE_SIZE:"file-size",FILE_SOLID:"file-solid",FILE_SOLID_TEXT:"file-solid-text",FILE_SPREADSHEET:"file-spreadsheet",FILE_TEXT:"file-text",FILTER:"filter",FLAG:"flag",FOLDER:"folder",FOLDER_OPEN:"folder-open",FOLDER_SOLID:"folder-solid",FOLDER_SOLID_OPEN:"folder-solid-open",GEAR:"gear",GLOBE:"globe",GRID:"grid",GROUP:"group",HAND_STOP:"hand-stop",HANDSHAKE:"handshake",HAT:"hat",HEART:"heart",HISTORY:"history",INBOX:"inbox",INCOMING:"incoming",INFO_CIRCLE:"info-circle",INTERCOM:"intercom",ITEM_TAG:"item-tag",KEY:"key",LIFE_PRESERVER:"life-preserver",LIGHTBULB:"lightbulb",LINK:"link",LINKEDIN:"linkedin",LIST:"list",LIST_CARDS:"list-cards",LIST_COLUMNS:"list-columns",LIST_SUMMARY:"list-summary",LIST_TABLE:"list-table",LOCATION:"location",LOCKED:"locked",LOCKED_CIRCLE:"locked-circle",MAP:"map",MAP_MARKER:"map-marker",MAXIMIZE:"maximize",MINIMIZE:"minimize",MINUS:"minus",MINUS_CIRCLE:"minus-circle",NEW_FILE:"new-file",NEW_SCREEN:"new-screen",OUTGOING:"outgoing",PAPER_PLANE:"paper-plane",PENCIL:"pencil",PHOTO:"photo",PIN:"pin",PINTEREST:"pinterest",PLAY:"play",PLUS_CIRCLE:"plus-circle",PLUS_SIGN:"plus-sign",PRESENTATION:"presentation",PRINTER:"printer",QR_CODE:"qr-code",QUESTION_CIRCLE:"question-circle",QUOTE_LEFT:"quote-left",QUOTE_RIGHT:"quote-right",RANDOM:"random",REFRESH:"refresh",RIGHT_CIRCLE:"right-circle",ROCKET:"rocket",SEARCH:"search",SEARCH_PLUS:"search-plus",SHARE:"share",SHOPPING_CART:"shopping-cart",SORT_ALPHA_ASC:"sort-alpha-asc",SORT_ALPHA_DESC:"sort-alpha-desc",SORT_NUM_ASC:"sort-num-asc",SORT_NUM_DESC:"sort-num-desc",STAR:"star",STAR_OUTLINE:"star-outline",STATUS_ARCHIVED:"status-archived",STATUS_CANCELLED:"status-cancelled",STATUS_ERROR:"status-error",STATUS_IN_PROCESS:"status-in-process",STATUS_IN_TRANSIT:"status-in-transit",STATUS_LOCKED:"status-locked",STATUS_NEW:"status-new",STATUS_OK:"status-ok",STATUS_ON_HOLD:"status-on-hold",STATUS_OUTDATED:"status-outdated",STATUS_REJECTED:"status-rejected",STATUS_SAVED:"status-saved",STATUS_SAVING:"status-saving",STATUS_TEMPLATE:"status-template",STATUS_WARNING:"status-warning",TABLE:"table",TABS:"tabs",TAG:"tag",TEMPLATE_CIRCLE:"template-circle",THUMBS_DOWN:"thumbs-down",THUMBS_DOWN_OUTLINE:"thumbs-down-outline",THUMBS_UP:"thumbs-up",THUMBS_UP_OUTLINE:"thumbs-up-outline",TRASH:"trash",TRUCK_SHIPPING:"truck-shipping",TWITTER:"twitter",UNDO:"undo",UNLOCKED:"unlocked",UPLOAD_CLOUD:"upload-cloud",USER:"user",USER_IMPERSONATION:"user-impersonation",WRENCH:"wrench",X:"x",X_CIRCLE:"x-circle"},k={Icon:{icon:C,size:{EXTRA_SMALL:"xs",SMALL:"sm",MEDIUM:"md",LARGE:"lg",EXTRA_LARGE:"lg"}},InsightCard:{icon:C,kind:{GENERAL:"general",SUCCESS:"success",ERROR:"error",WARNING:"warning",PROCESSING:"processing"}},Spinner:{size:{SMALL:"sm",MEDIUM:"md",LARGE:"lg"}},FeedbackBlock:{kind:{TIP:"tip",SUCCESS:"success",WARNING:"warning",ERROR:"error",INFO:"info"}},Tag:{kind:{DEFAULT:"default",KEY:"key",WARNING:"warning",ERROR:"error",PENDING:"pending",SUCCESS:"success",INFO:"info"}},ClickableTag:{kind:{BLUE:"blue",GRAY:"gray"}}};function N(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="Tag").forEach(s=>{const{iconProp:r,otherAttrs:n}=s.value.openingElement.attributes.reduce((o,t)=>{switch(t.name.name){case"icon":o.iconProp=t;break;default:o.otherAttrs.push(t)}return o},{iconProp:null,otherAttrs:[]});r&&e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("Tag"),[e.jsxAttribute(e.jsxIdentifier("icon"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("Tag"))))})}function b(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="KeyValueTag").forEach(s=>{const{iconProp:r,otherAttrs:n}=s.value.openingElement.attributes.reduce((o,t)=>{switch(t.name.name){case"icon":o.iconProp=t;break;default:o.otherAttrs.push(t)}return o},{iconProp:null,otherAttrs:[]});r&&e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("KeyValueTag"),[e.jsxAttribute(e.jsxIdentifier("icon"),null),...n],!1),e.jsxClosingElement(e.jsxIdentifier("KeyValueTag"))))})}function w(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsMicroZeroState").forEach(s=>{const{attrs:r}=s.value.openingElement.attributes.reduce((n,o)=>(n.attrs.push(o),n),{attrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsMicroZeroState"),[e.jsxAttribute(e.jsxIdentifier("micro"),null),...r],!0)))})}function P(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="SpsProductBar").forEach(s=>{const{productName:r,nameClick:n,logoSrc:o,productLink:t,otherAttrs:c}=s.value.openingElement.attributes.reduce((i,d)=>{switch(d.name.name){case"productName":i.productName=d;break;case"onProductNameClick":i.nameClick=d;break;case"productLogoSrc":i.logoSrc=d;break;case"productNameHref":i.productLink=d;break;case"tabs":break;case"activeTabs":break;case"onTabChange":break;default:i.otherAttrs.push(d)}return i},{productName:null,nameClick:null,logoSrc:null,productLink:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("SpsProductBar"),[...c],!1),e.jsxClosingElement(e.jsxIdentifier("SpsProductBar")),[e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("ProductBarName"),[r&&e.jsxAttribute(e.jsxIdentifier("name"),e.literal(r.value.value)),o&&e.jsxAttribute(e.jsxIdentifier("logoSrc"),e.literal(o.value.value)),n&&e.jsxAttribute(e.jsxIdentifier("onClick"),n.value),t&&e.jsxAttribute(e.jsxIdentifier("href"),e.literal(t.value.value))].filter(Boolean),!0)),...s.node.children]))})}function x(a,e){a.find(e.JSXElement).filter(s=>s.value.openingElement.name.name==="ProductBarTab").forEach(s=>{const{clickHandler:r,otherAttrs:n}=s.value.openingElement.attributes.reduce((o,t)=>{switch(t.name.name){case"onClick":o.clickHandler=t;break;default:o.otherAttrs.push(t)}return o},{clickHandler:null,otherAttrs:[]});e(s).replaceWith(e.jsxElement(e.jsxOpeningElement(e.jsxIdentifier("ProductBarTab"),[r&&e.jsxAttribute(e.jsxIdentifier("onPress"),r.value),...n].filter(Boolean),!1),e.jsxClosingElement(e.jsxIdentifier("ProductBarTab")),[...s.node.children]))})}const D=R.reduce((a,[e,l,s,r])=>{let n=a[l];return n||(n={},a[l]=n),n[e]={newName:s,newPackage:r},a},{}),A={list:R,byOldPackage:D,props:k};function f(a,{jscodeshift:e},l){var r;const s=e(a.source);return w(s,e),P(s,e),O(s,e),h(s,e,A),_(s,e,A),x(s,e),g(s,e),N(s,e),b(s,e),s.toSource((r=l==null?void 0:l.woodland)==null?void 0:r.output)}f.parser="tsx";module.exports=f;
|
package/main.js
CHANGED
|
@@ -49,6 +49,10 @@ const config = {
|
|
|
49
49
|
files: ["**/*.+(t|j)s*(x)"],
|
|
50
50
|
ignore: [],
|
|
51
51
|
verbose: false,
|
|
52
|
+
output: {
|
|
53
|
+
lineSeparator: require("os").EOL,
|
|
54
|
+
quote: null
|
|
55
|
+
}
|
|
52
56
|
};
|
|
53
57
|
|
|
54
58
|
if (fs.existsSync(WOODLAND_CONFIG_FILENAME)) {
|
|
@@ -93,5 +97,8 @@ run(transformFile, targets, {
|
|
|
93
97
|
print: config.dryRun && !config.dryNoPrint,
|
|
94
98
|
verbose: config.verbose,
|
|
95
99
|
extensions: "tsx",
|
|
96
|
-
parser: "tsx"
|
|
100
|
+
parser: "tsx",
|
|
101
|
+
woodland: {
|
|
102
|
+
output: config.output
|
|
103
|
+
}
|
|
97
104
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sps-woodland/codemods",
|
|
3
3
|
"description": "SPS Woodland Design System codemods",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.2.0",
|
|
5
5
|
"author": "SPS Commerce",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"repository": "https://github.com/spscommerce/woodland/tree/master/packages/@sps-woodland/codemods",
|
|
Binary file
|
|
Binary file
|