css-codemod
Advanced tools
Comparing version
import { Plugin } from 'postcss'; | ||
export declare type Processors = Omit<Plugin, 'postcssPlugin' | 'prepare'>; | ||
export declare const traverse: (css: string, processors: Processors) => Promise<string | null>; | ||
declare type Processors = Omit<Plugin, 'postcssPlugin' | 'prepare'>; | ||
declare const traverse: (css: string, processors: Processors) => Promise<string | null>; | ||
export { Processors, traverse }; |
@@ -0,8 +1,77 @@ | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __reExport = (target, module2, copyDefault, desc) => { | ||
if (module2 && typeof module2 === "object" || typeof module2 === "function") { | ||
for (let key of __getOwnPropNames(module2)) | ||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) | ||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); | ||
} | ||
return target; | ||
}; | ||
var __toESM = (module2, isNodeMode) => { | ||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); | ||
}; | ||
var __toCommonJS = /* @__PURE__ */ ((cache) => { | ||
return (module2, temp) => { | ||
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp); | ||
}; | ||
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0); | ||
'use strict' | ||
// src/index.ts | ||
var src_exports = {}; | ||
__export(src_exports, { | ||
traverse: () => traverse | ||
}); | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./css-codemod.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./css-codemod.cjs.development.js') | ||
} | ||
// src/traverse/index.ts | ||
var import_postcss = __toESM(require("postcss")); | ||
var createTransformPlugin = (processors) => __spreadValues({ | ||
postcssPlugin: "css-codemod-plugin" | ||
}, processors); | ||
var traverse = async (css, processors) => { | ||
try { | ||
const plugins = [createTransformPlugin(processors)]; | ||
const processor = (0, import_postcss.default)(plugins); | ||
const result = await processor.process(css, { | ||
from: void 0 | ||
}); | ||
return result.css; | ||
} catch (err) { | ||
console.error(`Unexpected error processing CSS. | ||
CSS string: | ||
${css} | ||
Error: | ||
${err}`); | ||
} | ||
return null; | ||
}; | ||
module.exports = __toCommonJS(src_exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
traverse | ||
}); |
{ | ||
"version": "0.0.0-pr.1.1.d09f085", | ||
"version": "0.0.0-pr.2.1.0d4b6a7", | ||
"license": "MIT", | ||
@@ -13,12 +13,16 @@ "name": "css-codemod", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=14" | ||
}, | ||
"bin": { | ||
"css-codemod": "./dist/cli.js" | ||
}, | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"build": "tsup src/index.ts src/cli.ts --dts", | ||
"test": "tsdx test", | ||
"lint": "tsdx lint", | ||
"prepare": "tsdx build", | ||
"prepare": "yarn build", | ||
"size": "size-limit", | ||
"analyze": "size-limit --why" | ||
"analyze": "size-limit --why", | ||
"clean": "rimraf dist" | ||
}, | ||
@@ -36,10 +40,9 @@ "husky": { | ||
}, | ||
"module": "dist/css-codemod.esm.js", | ||
"size-limit": [ | ||
{ | ||
"path": "dist/css-codemod.cjs.production.min.js", | ||
"path": "dist/index.js", | ||
"limit": "100 KB" | ||
}, | ||
{ | ||
"path": "dist/css-codemod.esm.js", | ||
"path": "dist/cli.js", | ||
"limit": "100 KB" | ||
@@ -52,6 +55,8 @@ } | ||
"husky": "^7.0.4", | ||
"rimraf": "^3.0.2", | ||
"size-limit": "^7.0.5", | ||
"tsdx": "^0.14.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^3.9.10" | ||
"tsup": "^5.11.11", | ||
"typescript": "^4.5.5" | ||
}, | ||
@@ -58,0 +63,0 @@ "dependencies": { |
@@ -1,33 +0,1 @@ | ||
import postcss, { AcceptedPlugin, Plugin } from 'postcss'; | ||
// TODO: export `Processors` from `postcss`. | ||
export type Processors = Omit<Plugin, 'postcssPlugin' | 'prepare'>; | ||
const createTransformPlugin = (processors: Processors): Plugin => ({ | ||
postcssPlugin: 'css-codemod-plugin', | ||
...processors, | ||
}); | ||
export const traverse = async ( | ||
css: string, | ||
processors: Processors | ||
): Promise<string | null> => { | ||
try { | ||
const plugins: AcceptedPlugin[] = [createTransformPlugin(processors)]; | ||
const processor = postcss(plugins); | ||
const result = await processor.process(css, { | ||
// Explicitly set to undefined to silence a warning about sourcemaps. | ||
from: undefined, | ||
}); | ||
return result.css; | ||
} catch (err) { | ||
console.error( | ||
`Unexpected error processing CSS.\n\nCSS string:\n${css}\n\nError:\n${err}` | ||
); | ||
} | ||
return null; | ||
}; | ||
export { traverse, Processors } from './traverse'; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
-33.33%1
-50%1
-66.67%7096
-96.44%9
28.57%10
-16.67%110
-92.82%