From 6616fc45c8d7bf4e7d2a7a426f27476784ceb038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa=20Valderrama?= Date: Fri, 1 Mar 2024 11:13:50 +0100 Subject: [PATCH] feat: move parser to plugins-data-parser library --- libs/plugins-data-parser/.eslintrc.json | 25 ++++ libs/plugins-data-parser/README.md | 7 + libs/plugins-data-parser/package.json | 10 ++ libs/plugins-data-parser/project.json | 19 +++ libs/plugins-data-parser/src/index.ts | 1 + .../src/lib/models/index.ts | 1 + .../src/lib/models/parsed-file.model.ts | 127 ++++++++++++++++++ .../src/lib/plugins-data-parser.ts | 2 + .../src/lib/utils/index.ts | 1 + .../src/lib/utils/object.util.ts | 24 ---- .../src/lib/utils/parse-arr.util.ts | 22 +-- .../src/lib/utils/parse-properties.util.ts | 55 ++++++++ .../src/lib/utils/parse.util.ts | 28 +++- libs/plugins-data-parser/tsconfig.json | 19 +++ libs/plugins-data-parser/tsconfig.lib.json | 10 ++ libs/plugins-runtime/src/index.ts | 3 - nx.json | 5 + tsconfig.base.json | 2 + 18 files changed, 317 insertions(+), 44 deletions(-) create mode 100644 libs/plugins-data-parser/.eslintrc.json create mode 100644 libs/plugins-data-parser/README.md create mode 100644 libs/plugins-data-parser/package.json create mode 100644 libs/plugins-data-parser/project.json create mode 100644 libs/plugins-data-parser/src/index.ts create mode 100644 libs/plugins-data-parser/src/lib/models/index.ts create mode 100644 libs/plugins-data-parser/src/lib/models/parsed-file.model.ts create mode 100644 libs/plugins-data-parser/src/lib/plugins-data-parser.ts rename libs/{plugins-runtime => plugins-data-parser}/src/lib/utils/index.ts (69%) rename libs/{plugins-runtime => plugins-data-parser}/src/lib/utils/object.util.ts (51%) rename libs/{plugins-runtime => plugins-data-parser}/src/lib/utils/parse-arr.util.ts (88%) create mode 100644 libs/plugins-data-parser/src/lib/utils/parse-properties.util.ts rename libs/{plugins-runtime => plugins-data-parser}/src/lib/utils/parse.util.ts (72%) create mode 100644 libs/plugins-data-parser/tsconfig.json create mode 100644 libs/plugins-data-parser/tsconfig.lib.json diff --git a/libs/plugins-data-parser/.eslintrc.json b/libs/plugins-data-parser/.eslintrc.json new file mode 100644 index 0000000..adbe7ae --- /dev/null +++ b/libs/plugins-data-parser/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "error" + } + } + ] +} diff --git a/libs/plugins-data-parser/README.md b/libs/plugins-data-parser/README.md new file mode 100644 index 0000000..cedc3bd --- /dev/null +++ b/libs/plugins-data-parser/README.md @@ -0,0 +1,7 @@ +# plugins-data-parser + +This library was generated with [Nx](https://nx.dev). + +## Building + +Run `nx build plugins-data-parser` to build the library. diff --git a/libs/plugins-data-parser/package.json b/libs/plugins-data-parser/package.json new file mode 100644 index 0000000..a59ea4c --- /dev/null +++ b/libs/plugins-data-parser/package.json @@ -0,0 +1,10 @@ +{ + "name": "plugins-data-parser", + "version": "0.0.1", + "dependencies": { + "tslib": "^2.3.0" + }, + "type": "commonjs", + "main": "./src/index.js", + "typings": "./src/index.d.ts" +} diff --git a/libs/plugins-data-parser/project.json b/libs/plugins-data-parser/project.json new file mode 100644 index 0000000..dfa4f3a --- /dev/null +++ b/libs/plugins-data-parser/project.json @@ -0,0 +1,19 @@ +{ + "name": "plugins-data-parser", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/plugins-data-parser/src", + "projectType": "library", + "targets": { + "build": { + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/plugins-data-parser", + "main": "libs/plugins-data-parser/src/index.ts", + "tsConfig": "libs/plugins-data-parser/tsconfig.lib.json", + "assets": ["libs/plugins-data-parser/*.md"] + } + } + }, + "tags": [] +} diff --git a/libs/plugins-data-parser/src/index.ts b/libs/plugins-data-parser/src/index.ts new file mode 100644 index 0000000..2ed39dd --- /dev/null +++ b/libs/plugins-data-parser/src/index.ts @@ -0,0 +1 @@ +export * from './lib/plugins-data-parser'; diff --git a/libs/plugins-data-parser/src/lib/models/index.ts b/libs/plugins-data-parser/src/lib/models/index.ts new file mode 100644 index 0000000..cf28d34 --- /dev/null +++ b/libs/plugins-data-parser/src/lib/models/index.ts @@ -0,0 +1 @@ +export * from './parsed-file.model'; diff --git a/libs/plugins-data-parser/src/lib/models/parsed-file.model.ts b/libs/plugins-data-parser/src/lib/models/parsed-file.model.ts new file mode 100644 index 0000000..1ec71f1 --- /dev/null +++ b/libs/plugins-data-parser/src/lib/models/parsed-file.model.ts @@ -0,0 +1,127 @@ +export interface ParsedFile { + id: string; + name: string; + data: FileData; +} + +export interface FileData { + id: string; + version: number; + colors: IdData[]; + typographies: IdData[]; + pages: RootTail; // Tail is an array of uuid (string) + pagesIndex?: IdData[]; + components: IdData[]; + media?: IdData[]; +} + +export interface Color { + color: string; + opacity: number; + id: string; + name: string; + fileId: string; + path: string | null; +} + +export interface Typhography { + lineHeight: string; + path: string | null; + fontStyle: string; + textTransform: string; + fontId: string; + fontSize: string; + fontWeight: string; + name: string; + fontVariantId: string; + id: string; + letterSpacing: string; + fontFamily: string; + modifiedAt?: Date; +} + +export interface PageIndex { + options: IdData