Prechádzať zdrojové kódy

refactor(admin-ui): Rename "devkit" to "compiler"

It's a more descriptive name, and "devkit" will be used for the ui extension package
Michael Bromley 6 rokov pred
rodič
commit
68eeb46c1f

+ 1 - 1
packages/admin-ui-plugin/build.ts

@@ -1,5 +1,5 @@
 /* tslint:disable:no-console */
-import { compileAdminUiApp } from '@vendure/admin-ui/devkit/compile';
+import { compileAdminUiApp } from '@vendure/admin-ui/compiler/compile';
 import path from 'path';
 
 console.log('Building admin-ui from source...');

+ 1 - 1
packages/admin-ui-plugin/src/plugin.ts

@@ -1,4 +1,4 @@
-import { Watcher } from '@vendure/admin-ui/devkit/watch';
+import { Watcher } from '@vendure/admin-ui/compiler/watch';
 import { DEFAULT_AUTH_TOKEN_HEADER_KEY } from '@vendure/common/lib/shared-constants';
 import { AdminUiConfig, AdminUiExtension, Type } from '@vendure/common/lib/shared-types';
 import {

+ 2 - 2
packages/admin-ui-plugin/src/ui-app-compiler.service.ts

@@ -1,5 +1,5 @@
 import { Injectable } from '@nestjs/common';
-import { compileAdminUiApp, watchAdminUiApp, Watcher } from '@vendure/admin-ui/devkit';
+import { compileAdminUiApp, watchAdminUiApp, Watcher } from '@vendure/admin-ui/compiler';
 import { AdminUiExtension } from '@vendure/common/lib/shared-types';
 import { Logger } from '@vendure/core';
 import crypto from 'crypto';
@@ -43,7 +43,7 @@ export class UiAppCompiler {
             const hash = crypto.createHash('sha256');
             hash.update(JSON.stringify(e));
             const id = hash.digest('hex');
-            return { ...e, id };
+            return { staticAssets: [], ...e, id };
         });
     }
 

+ 2 - 2
packages/admin-ui/.gitignore

@@ -14,8 +14,8 @@
 /src/app/extensions/extensions.module.ts.generated
 /src/app/extensions/extensions.module.ts.temp
 
-# compiled devkit files
-/devkit
+# compiled compiler files
+/compiler
 
 # IDEs and editors
 /.idea

+ 4 - 0
packages/admin-ui/README.md

@@ -6,6 +6,10 @@ It is an Angular application built with the Angular CLI.
 
 The UI is powered by the [Clarity Design System](https://vmware.github.io/clarity/).
 
+## Compiler
+
+The `/src/compiler` directory contains the code which is used to dynamically compile the Admin UI app with UI extensions. This code is used by the `@vendure/admin-ui-plugin`.
+
 ## Localization
 
 Localization of UI strings is handled by [ngx-translate](http://www.ngx-translate.com/). The translation strings should use the [ICU MessageFormat](http://userguide.icu-project.org/formatparse/messages).

+ 3 - 2
packages/admin-ui/package.json

@@ -5,9 +5,9 @@
   "scripts": {
     "ng": "ng",
     "start": "ng serve",
-    "build": "yarn reset-extensions && ng build --prod && yarn build:devkit",
+    "build": "yarn reset-extensions && ng build --prod && yarn build:compiler",
     "watch": "ng build --watch=true",
-    "build:devkit": "tsc -p tsconfig.devkit.json",
+    "build:compiler": "tsc -p tsconfig.compiler.json",
     "test": "ng test --watch=false --browsers=ChromeHeadlessCI --progress=false",
     "lint": "tslint --fix",
     "reset-extensions": "rimraf ./src/app/extensions/modules && rimraf ./src/app/extensions/*.generated && rimraf ./src/app/extensions/*.temp",
@@ -36,6 +36,7 @@
     "@ng-select/ng-select": "^3.0.5",
     "@ngx-translate/core": "^11.0.1",
     "@ngx-translate/http-loader": "^4.0.0",
+    "@vendure/ui-extension-devkit": "^0.6.4",
     "@webcomponents/custom-elements": "^1.2.4",
     "apollo-angular": "^1.6.0",
     "apollo-cache-inmemory": "^1.6.2",

+ 9 - 0
packages/admin-ui/src/devkit/common.ts → packages/admin-ui/src/compiler/common.ts

@@ -39,8 +39,17 @@ export function copyExtensionModules(extensions: Array<Required<AdminUiExtension
             }
         }
     }
+    fs.copySync(
+        require.resolve('@vendure/ui-extension-devkit'),
+        path.join(STATIC_ASSETS_OUTPUT_DIR, 'ui-extension-devkit.js'),
+    );
 }
 
+/**
+ * Copies over any files defined by the extensions' `staticAssets` array to the shared
+ * static assets directory. When the app is built by the ng cli, this assets directory is
+ * the copied over to the final static assets location (i.e. http://domain/admin/assets/)
+ */
 export function copyStaticAsset(staticAssetPath: string) {
     const stats = fs.statSync(staticAssetPath);
     if (stats.isDirectory()) {

+ 0 - 0
packages/admin-ui/src/devkit/compile.ts → packages/admin-ui/src/compiler/compile.ts


+ 0 - 0
packages/admin-ui/src/devkit/index.ts → packages/admin-ui/src/compiler/index.ts


+ 0 - 0
packages/admin-ui/src/devkit/watch.ts → packages/admin-ui/src/compiler/watch.ts


+ 2 - 2
packages/admin-ui/tsconfig.devkit.json → packages/admin-ui/tsconfig.compiler.json

@@ -2,7 +2,7 @@
   "compileOnSave": false,
   "compilerOptions": {
     "baseUrl": "./",
-    "outDir": "./devkit",
+    "outDir": "./compiler",
     "sourceMap": true,
     "module": "commonjs",
     "declaration": true,
@@ -15,7 +15,7 @@
     ]
   },
   "files": [
-    "src/devkit/index.ts"
+    "src/compiler/index.ts"
   ],
   "exclude": [
     "src/**/*"