@zeplin/cli-connect-angular-plugin
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -0,6 +1,10 @@ | ||
import pug from "pug"; | ||
import { ConnectPlugin, ComponentConfig, ComponentData } from "@zeplin/cli"; | ||
import pug from "pug"; | ||
export default class implements ConnectPlugin { | ||
generateSnippet: pug.compileTemplate; | ||
generateDescription: pug.compileTemplate; | ||
constructor(opts?: { | ||
useFullDescription: boolean; | ||
useFullSnippet: boolean; | ||
}); | ||
process(context: ComponentConfig): Promise<ComponentData>; | ||
@@ -7,0 +11,0 @@ supports(x: ComponentConfig): boolean; |
@@ -15,10 +15,15 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const selector_1 = require("./selector"); | ||
const path_1 = __importDefault(require("path")); | ||
const pug_1 = __importDefault(require("pug")); | ||
const fs_extra_1 = require("fs-extra"); | ||
const compodoc_1 = require("@compodoc/compodoc"); | ||
const util_1 = require("./util"); | ||
class default_1 { | ||
constructor() { | ||
this.generateSnippet = pug_1.default.compileFile(path_1.default.join(__dirname, "template/snippet.pug")); | ||
this.generateDescription = pug_1.default.compileFile(path_1.default.join(__dirname, "template/description.pug")); | ||
constructor(opts) { | ||
this.generateSnippet = (opts && opts.useFullSnippet) | ||
? pug_1.default.compileFile(path_1.default.join(__dirname, "template/snippet-full.pug")) | ||
: pug_1.default.compileFile(path_1.default.join(__dirname, "template/snippet-summary.pug")); | ||
this.generateDescription = (opts && opts.useFullDescription) | ||
? pug_1.default.compileFile(path_1.default.join(__dirname, "template/description-full.pug")) | ||
: pug_1.default.compileFile(path_1.default.join(__dirname, "template/description-summary.pug")); | ||
} | ||
@@ -28,6 +33,5 @@ process(context) { | ||
const angularDependencies = new compodoc_1.AngularDependencies([path_1.default.resolve(context.path)], { tsconfigDirectory: ".", silent: true }); | ||
const rawComponents = (yield angularDependencies.getDependencies().components) || []; | ||
const components = this.processComponents(rawComponents); | ||
const rawComponents = angularDependencies.getDependencies().components || []; | ||
const components = yield Promise.all(this.processComponents(rawComponents)); | ||
const snippet = this.generateSnippet({ components }); | ||
// Const description = components.map(c => `#### ${c.name}\n${c.description}`).join("\n\n"); | ||
const description = this.generateDescription({ components }); | ||
@@ -45,4 +49,13 @@ const lang = "markup" /* Markup */; | ||
processComponents(rawComponents) { | ||
return rawComponents.map(rawComponent => { | ||
const { name, description, selector, inputsClass, propertiesClass, extends: _extends, implements: _implements, inputs: rawInputs } = rawComponent; | ||
return rawComponents.map((rawComponent) => __awaiter(this, void 0, void 0, function* () { | ||
const { file, name, description, rawdescription: rawDescription, selector, inputsClass, propertiesClass, extends: _extends, implements: _implements, inputs: rawInputs, template, templateUrl } = rawComponent; | ||
let hasChildren = false; | ||
if (template && template.length > 0) { | ||
hasChildren = util_1.ngContentExists(template); | ||
} | ||
else if (templateUrl && templateUrl.length > 0 && templateUrl[0].length > 0) { | ||
const fileContent = yield fs_extra_1.readFile(path_1.default.join(path_1.default.dirname(file), templateUrl[0])); | ||
hasChildren = util_1.ngContentExists(fileContent.toString()); | ||
} | ||
console.log(templateUrl); | ||
const selectors = []; | ||
@@ -77,3 +90,3 @@ const inputs = []; | ||
if (inputsClass) { | ||
inputs.concat(inputsClass); | ||
inputsClass.forEach(i => inputs.push(i)); | ||
} | ||
@@ -83,3 +96,3 @@ if (selector) { | ||
.split(",") | ||
.map(s => selector_1.parseSelector(s.trim())) | ||
.map(s => util_1.parseSelector(s.trim())) | ||
.forEach(s => { | ||
@@ -95,7 +108,9 @@ if (s) { | ||
description, | ||
rawDescription, | ||
inputs, | ||
_extends, | ||
_implements | ||
_implements, | ||
hasChildren | ||
}; | ||
}); | ||
})); | ||
} | ||
@@ -102,0 +117,0 @@ } |
@@ -16,3 +16,3 @@ declare module "@compodoc/compodoc" { | ||
interface ComponentDep extends Dep { | ||
file: any; | ||
file: string; | ||
changeDetection: any; | ||
@@ -19,0 +19,0 @@ encapsulation: any; |
{ | ||
"name": "@zeplin/cli-connect-angular-plugin", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Zeplin CLI Connected Components - Angular Plugin", | ||
@@ -8,3 +8,3 @@ "main": "./dist/index", | ||
"test": "jest", | ||
"build": "tsc && copyfiles -u 1 src/template/** dist/", | ||
"build": "rm -rf dist/ && tsc && copyfiles -u 1 src/template/** dist/", | ||
"lint": "eslint --ext .js,.ts .", | ||
@@ -28,2 +28,3 @@ "prepare": "npm run build" | ||
"devDependencies": { | ||
"@types/fs-extra": "^8.0.1", | ||
"@types/jest": "^24.0.18", | ||
@@ -48,4 +49,5 @@ "@types/node": "^12.7.5", | ||
"@compodoc/compodoc": "git+ssh://git@github.com/yuqu/compodoc.git#develop", | ||
"fs-extra": "^8.1.0", | ||
"pug": "^2.0.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
19595
17
219
3
17
1
+ Addedfs-extra@^8.1.0
+ Addedfs-extra@8.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addeduniversalify@0.1.2(transitive)