Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ant-design/icons

Package Overview
Dependencies
Maintainers
3
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design/icons - npm Package Compare versions

Comparing version 0.1.0-alpha.2 to 0.1.1-alpha.1

build/env.ts

67

build/generateIcons.ts
'use strict';
import fs = require('fs');

@@ -8,44 +7,21 @@ import globby = require('globby');

import path = require('path');
import rimraf = require('rimraf');
import SVGO = require('svgo');
// tslint:disable-next-line:no-var-requires
const pkg = require('../package.json');
// tslint:disable-next-line:no-var-requires
const { rimraf } = require('mz-modules');
import assert = require('assert');
import chalk from 'chalk';
import { generateAbstractTree, getSVGOPlugin, IconDefinition, INode } from './utils';
import { environment } from './env';
import { Environment, IconDefinition, Node } from './typings';
import { generateAbstractTree, log } from './utils';
const environment: IEnvironment = {
paths: {
SVG_DIR: path.resolve(__dirname, '../src/svg'),
SVGS_TS_TEMPLATE: path.resolve(__dirname, './templates/svgs.ts.template'),
SVGS_TS_OUTPUT: path.resolve(__dirname, '../src/svgs.ts'),
MANIFEST_TS_TEMPLATE: path.resolve(__dirname, './templates/manifest.ts.template'),
MANIFEST_TS_OUTPUT: path.resolve(__dirname, '../src/manifest.ts')
},
base: path.resolve(__dirname, '../'),
options: {
svgo: {
plugins: getSVGOPlugin()
}
}
};
export async function build(env: Environment) {
const startTime = Date.now();
interface IEnvironment {
paths: { [key: string]: string };
base: string;
options: {
svgo: SVGO.Options
};
}
async function build(env: IEnvironment) {
console.time('Build Time');
// clear.
console.log(chalk.green(`🌟 [Generate SVG] Clear folders.`));
log(`Clear folders.`);
await Promise.all(
Object.keys(env.paths)
.filter((key) => key.endsWith('OUTPUT')) // DO NOT DELETE THIS LINE!!!
.map((key) => rimraf(env.paths[key])) // This is evil. Make sure you just delete the OUTPUT.
.map((key) => {
// This is evil. Make sure you just delete the OUTPUT.
log(`Delete ${env.paths[key]}.`);
return new Promise((resolve) => rimraf(env.paths[key], resolve));
})
);

@@ -58,3 +34,3 @@

const svgFilePaths = svgFileNames.map((name) => path.resolve(env.paths.SVG_DIR, name));
console.log(chalk.green(`🌟 [Generate SVG] Icon Amount: ${svgFileNames.length}.`));
log(`Icon Amount: ${svgFileNames.length}.`);

@@ -73,3 +49,3 @@ // optimizing SVG files.

const domFragment: any = parse5.parseFragment(compressedSvg.data);
const ast = generateAbstractTree(domFragment.childNodes[0] as INode, kebabCaseName);
const ast = generateAbstractTree(domFragment.childNodes[0] as Node, kebabCaseName);
const icon: IconDefinition = {

@@ -87,5 +63,3 @@ ...ast,

// render svgs.ts
console.log(
chalk.green(`🌟 [Generate SVG] Generate "svgs.ts" to ${path.relative(__dirname, env.paths.SVGS_TS_TEMPLATE)}.`)
);
log(`Generate "svgs.ts" to ${path.relative(__dirname, env.paths.SVGS_TS_TEMPLATE)}.`);
const svgsTs = fs.readFileSync(env.paths.SVGS_TS_TEMPLATE, 'utf8');

@@ -104,7 +78,3 @@ const renderedSvgsTs = svgsTs

// render manifest.ts
console.log(
chalk.green(
`🌟 [Generate SVG] Generate "manifest.ts" to ${path.relative(__dirname, env.paths.MANIFEST_TS_TEMPLATE)}.`
)
);
log(`Generate "manifest.ts" to ${path.relative(__dirname, env.paths.MANIFEST_TS_TEMPLATE)}.`);
const manifestTs = fs.readFileSync(env.paths.MANIFEST_TS_TEMPLATE, 'utf8');

@@ -117,4 +87,5 @@ const renderedManifestTs = manifestTs

fs.writeFileSync(env.paths.MANIFEST_TS_OUTPUT, renderedManifestTs, 'utf8');
console.log(chalk.green(`🌟 [Generate SVG] Finished.`));
console.timeEnd('Build Time');
log(`Finished.`);
log(`Build Time: ${(Date.now() - startTime) / 1000}s.`);
}

@@ -121,0 +92,0 @@

@@ -1,23 +0,12 @@

export interface INode {
nodeName: string;
tagName?: string;
attrs: Array<{ name: string, value: string }>;
value?: string;
childNodes: INode[];
}
export interface IAbstractTree {
width: number;
height: number;
style?: string;
children: Array<{ tag: string, attrs: { [key: string]: string } }>;
}
export interface IconDefinition extends IAbstractTree {
name: string;
}
import assert = require('assert');
import chalk from 'chalk';
import fs = require('fs');
import { AbstractTree, Node } from './typings';
export function generateAbstractTree(node: INode, debugName?: string): IAbstractTree {
/**
* Parse the node generated by parse5 into the abstract tree.
* @param node the node that need parsing.
* @param debugName debug name, used in assert statement.
*/
export function generateAbstractTree(node: Node, debugName?: string): AbstractTree {
assert(node, debugName);

@@ -59,70 +48,45 @@ assert(node.tagName === 'svg', debugName);

/**
* get the SVGO config.
*/
export function getSVGOPlugin() {
return [{
cleanupAttrs: true
}, {
removeDoctype: true
}, {
removeXMLProcInst: true
}, {
removeComments: true
}, {
removeMetadata: true
}, {
removeTitle: true
}, {
removeDesc: true
}, {
removeUselessDefs: true
}, {
removeEditorsNSData: true
}, {
removeEmptyAttrs: true
}, {
removeHiddenElems: true
}, {
removeEmptyText: true
}, {
removeEmptyContainers: true
}, {
removeViewBox: false
}, {
cleanupEnableBackground: true
}, {
convertStyleToAttrs: true
}, {
convertColors: true
}, {
convertPathData: true
}, {
convertTransform: true
}, {
removeUnknownsAndDefaults: true
}, {
removeNonInheritableGroupAttrs: true
}, {
removeUselessStrokeAndFill: true
}, {
removeUnusedNS: true
}, {
cleanupIDs: true
}, {
cleanupNumericValues: true
}, {
moveElemsAttrsToGroup: true
}, {
moveGroupAttrsToElems: true
}, {
collapseGroups: true
}, {
removeRasterImages: false
}, {
mergePaths: true
}, {
convertShapeToPath: true
}, {
sortAttrs: true
}, {
removeDimensions: true
}];
return [
{ cleanupAttrs: true },
{ removeDoctype: true },
{ removeXMLProcInst: true },
{ removeComments: true },
{ removeMetadata: true },
{ removeTitle: true },
{ removeDesc: true },
{ removeUselessDefs: true },
{ removeEditorsNSData: true },
{ removeEmptyAttrs: true },
{ removeHiddenElems: true },
{ removeEmptyText: true },
{ removeEmptyContainers: true },
{ removeViewBox: false },
{ cleanupEnableBackground: true },
{ convertStyleToAttrs: true },
{ convertColors: true },
{ convertPathData: true },
{ convertTransform: true },
{ removeUnknownsAndDefaults: true },
{ removeNonInheritableGroupAttrs: true },
{ removeUselessStrokeAndFill: true },
{ removeUnusedNS: true },
{ cleanupIDs: true },
{ cleanupNumericValues: true },
{ moveElemsAttrsToGroup: true },
{ moveGroupAttrsToElems: true },
{ collapseGroups: true },
{ removeRasterImages: false },
{ mergePaths: true },
{ convertShapeToPath: true },
{ sortAttrs: true },
{ removeDimensions: true }
];
}
export function log(message: string) {
return console.log(chalk.green(`🌟 [Generate Icon Definition] ${message}`));
}
export * from './svgs';
export { manifest } from './manifest';
export declare const manifest: {
[key: string]: string;
};
export declare const BatchFolding: IconDefinition;
export declare const CiCircleFill: IconDefinition;
export declare const Ci: IconDefinition;
export declare const CodeSandboxCircleFill: IconDefinition;
export declare const Ci: IconDefinition;
export declare const CodeSandboxSquareFill: IconDefinition;
export declare const CodeSandbox: IconDefinition;
export declare const DollarCircleFill: IconDefinition;
export declare const Dollar: IconDefinition;
export declare const EuroCircleFill: IconDefinition;
export declare const Dollar: IconDefinition;
export declare const Euro: IconDefinition;

@@ -203,4 +203,4 @@ export declare const GitlabFill: IconDefinition;

export declare const FacebookFill: IconDefinition;
export declare const Facebook: IconDefinition;
export declare const Fall: IconDefinition;
export declare const Facebook: IconDefinition;
export declare const FileException: IconDefinition;

@@ -361,4 +361,4 @@ export declare const FileDone: IconDefinition;

export declare const PlaySquareFill: IconDefinition;
export declare const PlaySquare: IconDefinition;
export declare const PlusCircleFill: IconDefinition;
export declare const PlaySquare: IconDefinition;
export declare const PlusCircle: IconDefinition;

@@ -418,4 +418,4 @@ export declare const PlusSquareFill: IconDefinition;

export declare const Scissor: IconDefinition;
export declare const Search: IconDefinition;
export declare const SecurityScanFill: IconDefinition;
export declare const Search: IconDefinition;
export declare const SecurityScan: IconDefinition;

@@ -426,4 +426,4 @@ export declare const Select: IconDefinition;

export declare const SeverFill: IconDefinition;
export declare const Sever: IconDefinition;
export declare const Shake: IconDefinition;
export declare const Sever: IconDefinition;
export declare const Share: IconDefinition;

@@ -448,5 +448,5 @@ export declare const ShopFill: IconDefinition;

export declare const SmallDash: IconDefinition;
export declare const SmileFill: IconDefinition;
export declare const Smile: IconDefinition;
export declare const SnippetsFill: IconDefinition;
export declare const SmileFill: IconDefinition;
export declare const Snippets: IconDefinition;

@@ -461,4 +461,4 @@ export declare const Solution: IconDefinition;

export declare const Stock: IconDefinition;
export declare const Stop: IconDefinition;
export declare const StopFill: IconDefinition;
export declare const Stop: IconDefinition;
export declare const Strikethrough: IconDefinition;

@@ -523,2 +523,3 @@ export declare const Swap: IconDefinition;

export declare const WindowsFill: IconDefinition;
export declare const Windows: IconDefinition;
export declare const Woman: IconDefinition;

@@ -534,5 +535,4 @@ export declare const WrenchFill: IconDefinition;

export declare const Zhihu: IconDefinition;
export declare const Windows: IconDefinition;
export declare const antDesignIcons: IconDefinition[];
export interface IAbstractTree {
export interface AbstractTree {
width: number;

@@ -548,4 +548,4 @@ height: number;

}
export interface IconDefinition extends IAbstractTree {
export interface IconDefinition extends AbstractTree {
name: string;
}
{
"name": "@ant-design/icons",
"version": "0.1.0-alpha.2",
"version": "0.1.1-alpha.1",
"description": "Ant Design Icons",
"module": "esm/index.js",
"module": "es/index.js",
"main": "lib/index.js",

@@ -15,37 +15,32 @@ "sideEffects": false,

"scripts": {
"build": "rollup --config",
"generate": "cross-env TS_NODE_PROJECT=build/tsconfig.json node --require ts-node/register build/generateIcons.ts"
"build": "npm run build:lib && npm run build:es",
"build:lib": "rimraf lib && tsc",
"build:es": "rimraf es && tsc --outDir es --module esnext",
"generate": "cross-env TS_NODE_PROJECT=build/tsconfig.json node --require ts-node/register build/generateIcons.ts",
"test": "npm run test:unit",
"test:unit": "cross-env TS_NODE_PROJECT=test/tsconfig.json mocha --require espower-typescript/guess test/**/*.ts -t 5000"
},
"directories": {
"test": "test/"
},
"devDependencies": {
"@svgr/core": "^2.1.0",
"@types/es6-promisify": "^6.0.0",
"@svgr/core": "^2.1.1",
"@types/globby": "^8.0.0",
"@types/lodash": "^4.14.111",
"@types/node": "^10.5.2",
"@types/lodash": "^4.14.115",
"@types/mocha": "^5.2.5",
"@types/node": "^10.5.5",
"@types/parse5": "^5.0.0",
"@types/react": "^16.4.6",
"@types/rimraf": "^2.0.2",
"@types/svgo": "^1.0.1",
"chalk": "^2.4.1",
"cross-env": "^5.2.0",
"es6-promisify": "^6.0.0",
"espower-typescript": "^9.0.0",
"globby": "^8.0.1",
"lodash": "^4.17.10",
"lodash.kebabcase": "^4.1.1",
"mz-modules": "^2.1.0",
"mocha": "^5.2.0",
"parse5": "^5.0.0",
"power-assert": "^1.6.0",
"rollup": "^0.62.0",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-svg-to-symbol": "^1.0.0",
"rollup-plugin-typescript2": "^0.15.1",
"rimraf": "^2.6.2",
"svgo": "^1.0.5",
"ts-node": "^7.0.0",
"tslint": "^5.10.0",
"typescript": "^2.9.2"
"tslint": "^5.11.0",
"typescript": "^3.0.1"
}
}

@@ -17,3 +17,3 @@ # Ant Design Icons

- React: See [react-antd-icons](./packages/react-antd-icons)
- React: See [@ant-design/icons-react](./packages/icons-react)
- Vue: WIP

@@ -24,3 +24,3 @@ - Angular: WIP

```ts
import { Alibaba } from 'antd-icons/esm';
import { Alibaba } from '@ant-design/icons/esm';

@@ -27,0 +27,0 @@ console.log(Alibaba);

@@ -5,18 +5,11 @@ {

"target": "es5",
"module": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"lib": [
"es2015",
"dom"
]
"outDir": "lib",
"removeComments": true
},
"exclude": [
"examples/",
"node_modules/",
"build/",
"packages/",
"test/"
"include": [
"src/**/*"
]
}

@@ -6,2 +6,3 @@ {

"rules": {
"interface-name": false,
"quotemark": [

@@ -8,0 +9,0 @@ true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc