@sps-woodland/codemods
Advanced tools
Comparing version 0.0.4 to 7.0.0
@@ -1,1 +0,1 @@ | ||
"use strict";function P(s,e,t){const o=s.find(e.ImportDeclaration),r=new Map;for(const c of Object.keys(t.byOldPackage)){const{oldNames:l,newPackages:n}=t.byOldPackage[c];o.filter(d=>d.node.source.value===c).forEach(d=>{const k=e(d).replaceWith(e.importDeclaration(d.node.specifiers.filter(a=>!l.has(a.imported.name)),d.node.source));for(const a of Object.keys(n)){const p=n[a];if(r.has(a)){const i=r.get(a),m=e.importDeclaration([...i.node.specifiers,...p.map(w=>e.importSpecifier(e.identifier(w)))],i.node.source);r.set(a,m),e(i).replaceWith(m)}else{const i=e.importDeclaration(p.map(m=>e.importSpecifier(e.identifier(m))),e.literal(a));r.set(a,i),k.insertAfter(i)}}})}}function u(s,e,t){const o=s.find(e.JSXOpeningElement),r=s.find(e.JSXClosingElement);for(const{oldName:c,newName:l}of t.list)o.filter(n=>n.node.name.name===c).forEach(n=>{e(n).replaceWith(e.jsxOpeningElement(e.jsxIdentifier(l),n.node.attributes,n.node.selfClosing))}),r.filter(n=>n.node.name.name===c).forEach(n=>{e(n).replaceWith(e.jsxClosingElement(e.jsxIdentifier(l),n.node.attributes,n.node.selfClosing))})}const g=[{oldName:"SpsCardV2",newName:"Card",newPackage:"@woodland/cards",oldPackage:"@spscommerce/ds-react"}],N=g.reduce((s,e)=>{let t=s[e.oldPackage];t||(s[e.oldPackage]=t={oldNames:new Set,newPackages:{}}),t.oldNames.add(e.oldName);let o=t.newPackages[e.newPackage];return o||(t.newPackages[e.newPackage]=o=[]),o.push(e.newName),s},{}),f={list:g,byOldPackage:N};function h(s,{jscodeshift:e},t){const o=e(s.source);return P(o,e,f),u(o,e,f),o.toSource()}module.exports=h; | ||
"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; |
90
main.js
#!/usr/bin/env node | ||
const fs = require("fs"); | ||
const glob = require("glob"); | ||
@@ -7,8 +8,28 @@ const path = require("path"); | ||
const WOODLAND_CONFIG_FILENAME = "woodland.config.json"; | ||
const yargv = yargs | ||
.usage("Usage: $0 [options]") | ||
.option("verbose", { | ||
alias: "v", | ||
type: "boolean", | ||
description: "Print additional details to console" | ||
.usage("Usage: $0 [options] [...globs]") | ||
.options({ | ||
"dry-run": { | ||
alias: "d", | ||
type: "boolean", | ||
description: "Perform a dry run, printing transformation output to the console and not writing to any files", | ||
}, | ||
"dry-no-print": { | ||
type: "boolean", | ||
description: "Suppress printing transformation output in a dry run", | ||
}, | ||
"ignore": { | ||
type: "array", | ||
}, | ||
"verbose": { | ||
alias: "v", | ||
type: "boolean", | ||
description: "Print additional details to console", | ||
}, | ||
"vv": { | ||
type: "boolean", | ||
description: "Print even more additional details to console (includes --verbose)" | ||
} | ||
}) | ||
@@ -18,16 +39,61 @@ .help("help") | ||
console.log(yargv); | ||
if (yargv.vv) { | ||
Object.assign(yargv, { | ||
verbose: true, | ||
v: true, | ||
}); | ||
console.log("Received parameters:", yargv); | ||
} | ||
const config = { | ||
dryRun: false, | ||
dryNoPrint: false, | ||
files: ["**/*.+(t|j)s*(x)"], | ||
ignore: [], | ||
verbose: false, | ||
}; | ||
if (fs.existsSync(WOODLAND_CONFIG_FILENAME)) { | ||
const woodlandConfig = JSON.parse(fs.readFileSync(WOODLAND_CONFIG_FILENAME)); | ||
if (woodlandConfig.hasOwnProperty("codemods")) { | ||
Object.assign(config, woodlandConfig.codemods); | ||
} | ||
} | ||
if (yargv._.length > 0) { | ||
config.files = yargv._; | ||
} | ||
for (const key of Object.keys(yargv)) { | ||
if (config.hasOwnProperty(key)) { | ||
config[key] = yargv[key]; | ||
} | ||
} | ||
// ALWAYS ignore node_modules | ||
config.ignore.push("node_modules/**/*"); | ||
if (yargv.vv) { | ||
console.log("Resolved config:"); | ||
console.log(JSON.stringify(config, null, 4)); | ||
} | ||
const transformFile = path.resolve(__dirname, "./dist/transform.js") | ||
const targets = glob.sync("**/*.tsx"); | ||
const targets = config.files | ||
.map((globStr) => glob.sync(globStr, { | ||
ignore: config.ignore, | ||
})) | ||
.reduce((acc, list) => acc.concat(list), []); | ||
if (config.verbose) { | ||
console.log("Matched the following files to be modded:"); | ||
console.log(JSON.stringify(targets, null, 4)); | ||
} | ||
run(transformFile, targets, { | ||
dry: true, | ||
print: true, | ||
verbose: 1, | ||
dry: config.dryRun, | ||
print: config.dryRun && !config.dryNoPrint, | ||
verbose: config.verbose, | ||
extensions: "tsx", | ||
parser: "tsx" | ||
}).then((result) => { | ||
console.log(result); | ||
}); |
{ | ||
"name": "@sps-woodland/codemods", | ||
"description": "SPS Woodland Design System codemods", | ||
"version": "0.0.4", | ||
"version": "7.0.0", | ||
"author": "SPS Commerce", | ||
@@ -9,2 +9,7 @@ "license": "UNLICENSED", | ||
"homepage": "https://github.com/spscommerce/woodland/tree/master/packages/@sps-woodland/codemods#readme", | ||
"scripts": { | ||
"build": "vite build", | ||
"clean": "git clean -fdX", | ||
"pub": "pnpm pack && npm publish" | ||
}, | ||
"main": "./main.js", | ||
@@ -23,8 +28,3 @@ "bin": "./main.js", | ||
"yargs": "^12.0.2" | ||
}, | ||
"scripts": { | ||
"build": "vite build", | ||
"clean": "git clean -fdX", | ||
"pub": "pnpm pack && npm publish" | ||
} | ||
} | ||
} |
@@ -7,3 +7,3 @@ import path from "path"; | ||
lib: { | ||
entry: path.resolve(__dirname, "src/transform.js"), | ||
entry: path.resolve(__dirname, "src/transform.ts"), | ||
formats: ["cjs"], | ||
@@ -10,0 +10,0 @@ fileName: "transform", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
24871
6
157
1
2
1