فهرست منبع

chore(admin-ui): Fix some deployment config issues

Michael Bromley 6 سال پیش
والد
کامیت
f3cb719001

+ 20 - 14
package.json

@@ -4,7 +4,7 @@
   "private": true,
   "scripts": {
     "core:watch": "concurrently -n tsc,gulp,common \"cd packages/core && yarn tsc:watch\" \"cd packages/core && yarn gulp:watch\" \"cd packages/common && yarn watch\"",
-    "bootstrap": "lerna bootstrap && cd admin-ui && yarn",
+    "bootstrap": "lerna bootstrap",
     "docs:watch": "concurrently --restart-tries 5 -n docgen,hugo,webpack -c green,blue,cyan \"yarn generate-graphql-docs && yarn generate-typescript-docs -w\" \"cd docs && hugo server\" \"cd docs && yarn webpack -w\"",
     "docs:build": "yarn generate-graphql-docs && yarn generate-typescript-docs && cd docs && yarn webpack --prod && node build.js && hugo",
     "docs:deploy": "cd docs && yarn && cd .. && yarn docs:build",
@@ -13,17 +13,17 @@
     "generate-graphql-docs": "ts-node scripts/docs/generate-graphql-docs.ts --api=shop && ts-node scripts/docs/generate-graphql-docs.ts --api=admin",
     "format": "prettier --write --html-whitespace-sensitivity ignore",
     "lint:packages": "yarn tslint --fix",
-    "lint:admin-ui": "cd admin-ui && yarn lint --fix",
+    "lint:admin-ui": "cd packages/admin-ui && yarn lint --fix",
     "version": "yarn check-imports && yarn build && yarn generate-changelog && git add CHANGELOG.md",
     "dev-server:start": "cd packages/dev-server && yarn start",
     "dev-server:populate": "cd packages/dev-server && yarn populate",
-    "test:all": "cd admin-ui && yarn test --watch=false --browsers=ChromeHeadlessCI --progress=false && cd ../ && yarn test:common && yarn test:core && yarn test:email-plugin && yarn test:elasticsearch-plugin && yarn test:e2e",
+    "test:all": "yarn test:admin-ui && yarn test:common && yarn test:core && yarn test:email-plugin && yarn test:elasticsearch-plugin && yarn test:e2e",
     "test:common": "jest --config packages/common/jest.config.js",
     "test:core": "jest --config packages/core/jest.config.js",
     "test:email-plugin": "jest --config packages/email-plugin/jest.config.js --maxWorkers=1",
     "test:elasticsearch-plugin": "jest --config packages/elasticsearch-plugin/jest.config.js",
     "test:e2e": "jest --config packages/core/e2e/config/jest-e2e.json --runInBand",
-    "test:admin-ui": "cd admin-ui && yarn test --watch=false --browsers=ChromeHeadlessCI --progress=false",
+    "test:admin-ui": "cd packages/admin-ui && yarn test --watch=false --browsers=ChromeHeadlessCI --progress=false",
     "build": "lerna run build",
     "check-imports": "ts-node scripts/check-imports.ts",
     "generate-changelog": "ts-node scripts/changelogs/generate-changelog.ts",
@@ -33,12 +33,12 @@
   "devDependencies": {
     "@commitlint/cli": "^7.6.1",
     "@commitlint/config-conventional": "^7.6.0",
-    "@graphql-codegen/add": "^1.1.3",
-    "@graphql-codegen/cli": "^1.1.3",
-    "@graphql-codegen/fragment-matcher": "^1.4.0",
-    "@graphql-codegen/typescript": "^1.1.3",
-    "@graphql-codegen/typescript-compatibility": "^1.1.3",
-    "@graphql-codegen/typescript-operations": "^1.1.3",
+    "@graphql-codegen/add": "1.2.0",
+    "@graphql-codegen/cli": "1.2.0",
+    "@graphql-codegen/fragment-matcher": "1.4.0",
+    "@graphql-codegen/typescript": "1.2.0",
+    "@graphql-codegen/typescript-compatibility": "1.2.0",
+    "@graphql-codegen/typescript-operations": "1.2.0",
     "@types/graphql": "^14.0.5",
     "@types/klaw-sync": "^6.0.0",
     "@types/node": "^10.11.5",
@@ -58,9 +58,15 @@
     "tslint": "^5.11.0",
     "typescript": "^3.2.4"
   },
-  "workspaces": [
-    "packages/*"
-  ],
+  "workspaces": {
+    "packages": [
+      "packages/*"
+    ],
+    "nohoist": [
+      "**/@types/jasmine",
+      "**/@types/jasminewd2"
+    ]
+  },
   "commitlint": {
     "extends": [
       "@commitlint/config-conventional"
@@ -80,7 +86,7 @@
       "commit-msg": "commitlint -e $HUSKY_GIT_PARAMS",
       "post-commit": "git update-index --again",
       "pre-commit": "lint-staged",
-      "pre-push": "yarn test:all && cd admin-ui && yarn build --prod"
+      "pre-push": "yarn test:all && cd packages/admin-ui && yarn build --prod"
     }
   }
 }

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

@@ -48,7 +48,7 @@ export class UiAppCompiler {
     private extensionModulesHaveChanged(extensions: Array<Required<AdminUiExtension>>): boolean {
         fs.ensureFileSync(this.hashfile);
         const previousHash = fs.readFileSync(this.hashfile, 'utf-8');
-        if (!previousHash && extensions.length === 0) {
+        if (!previousHash && (!extensions || extensions.length === 0)) {
             // No extensions are configured and there is no last has,
             // as when the plugin is newly installed. In this case,
             // it would be unnecessary to recompile.

+ 5 - 0
packages/admin-ui/.gitignore

@@ -12,6 +12,11 @@
 /src/app/extensions/modules
 /src/app/extensions/extensions.module.ts.generated
 
+# compiled devkit files
+/devkit/compile.js
+/devkit/compile.d.ts
+/devkit/compile.js.map
+
 # IDEs and editors
 /.idea
 .project

+ 7 - 0
packages/admin-ui/.npmignore

@@ -0,0 +1,7 @@
+.gitignore
+yarn-error.log
+e2e
+dist
+*.spec.ts
+src/app/extensions/modules
+src/app/extensions/*.generated

+ 11 - 1
packages/admin-ui/angular.json

@@ -1,5 +1,5 @@
 {
-  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
+  "$schema": "../../node_modules/@angular/cli/lib/config/schema.json",
   "version": 1,
   "newProjectRoot": "projects",
   "projects": {
@@ -59,6 +59,16 @@
               "extractLicenses": true,
               "vendorChunk": false,
               "buildOptimizer": true
+            },
+            "compile-in-plugin": {
+              "styles": [
+                "../../@clr/icons/clr-icons.min.css",
+                "src/styles/styles.scss",
+                "../../trix/dist/trix.css"
+              ],
+              "scripts": [
+                "../../trix/dist/trix-core.js"
+              ]
             }
           }
         },

+ 5 - 13
packages/admin-ui/devkit/compile.ts

@@ -20,19 +20,11 @@ export function compileAdminUiApp(outputPath: string, extensions: Array<Required
         copyExtensionModules(extensions);
         createExtensionsModule(extensions);
 
-        const buildProcess = spawn(
-            'yarn',
-            [
-                'build',
-                /*'--prod=true', */
-                `--outputPath=${relativeOutputPath}`,
-            ],
-            {
-                cwd,
-                shell: true,
-                stdio: 'inherit',
-            },
-        );
+        const buildProcess = spawn('yarn', ['build:in-plugin', `--outputPath=${relativeOutputPath}`], {
+            cwd,
+            shell: true,
+            stdio: 'inherit',
+        });
         buildProcess.on('close', code => {
             if (code === 0) {
                 resolve();

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

@@ -4,7 +4,8 @@
   "scripts": {
     "ng": "ng",
     "start": "ng serve",
-    "build": "ng build",
+    "build": "ng build --prod && yarn build:devkit",
+    "build:devkit": "tsc -p tsconfig.devkit.json",
     "test": "ng test",
     "lint": "tslint --fix",
     "e2e": "ng e2e",
@@ -38,6 +39,7 @@
     "apollo-link": "^1.2.12",
     "apollo-link-context": "^1.0.18",
     "apollo-upload-client": "^11.0.0",
+    "chokidar": "^3.0.2",
     "core-js": "^3.1.3",
     "fs-extra": "^8.1.0",
     "graphql": "^14.3.1",
@@ -48,6 +50,7 @@
     "rxjs": "^6.5.2",
     "trix": "^1.2.0",
     "tslib": "^1.10.0",
+    "typescript": "~3.5.3",
     "zone.js": "^0.10.0"
   },
   "devDependencies": {
@@ -67,7 +70,6 @@
     "protractor": "~5.4.2",
     "puppeteer": "^1.19.0",
     "rimraf": "^2.6.3",
-    "tslint": "^5.12.1",
-    "typescript": "~3.5.3"
+    "tslint": "^5.12.1"
   }
 }

+ 0 - 11
packages/admin-ui/src/app/core/providers/notification/notification.service.mock.ts

@@ -1,11 +0,0 @@
-import { MockOf } from '../../../../testing/testing-types';
-
-import { NotificationService } from './notification.service';
-
-export class MockNotificationService implements MockOf<NotificationService> {
-    notify = jasmine.createSpy('notify');
-    error = jasmine.createSpy('error');
-    info = jasmine.createSpy('info');
-    success = jasmine.createSpy('success');
-    warning = jasmine.createSpy('warning');
-}

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

@@ -42,7 +42,7 @@
 
 /** Evergreen browsers require these. **/
 // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
-import 'core-js/es7/reflect';
+import 'core-js/es/reflect';
 
 /**
  * Web Animations `@angular/platform-browser/animations`

+ 1 - 4
packages/admin-ui/src/tsconfig.app.json

@@ -2,10 +2,7 @@
   "extends": "../tsconfig.json",
   "compilerOptions": {
     "outDir": "../out-tsc/app",
-    "module": "es2015",
-    "types": [
-      "jasmine"
-    ]
+    "module": "es2015"
   },
   "exclude": [
     "src/test.ts",

+ 24 - 0
packages/admin-ui/tsconfig.devkit.json

@@ -0,0 +1,24 @@
+{
+  "compileOnSave": false,
+  "compilerOptions": {
+    "baseUrl": "./",
+    "outDir": "./devkit",
+    "sourceMap": true,
+    "module": "commonjs",
+    "declaration": true,
+    "moduleResolution": "node",
+    "strict": true,
+    "target": "esnext",
+    "skipLibCheck": true,
+    "lib": [
+      "es2017"
+    ]
+  },
+  "files": [
+    "devkit/compile.ts"
+  ],
+  "exclude": [
+    "src/**/*"
+  ]
+}
+

+ 1 - 0
scripts/publish-to-verdaccio.sh

@@ -4,6 +4,7 @@
 VERDACCIO=http://localhost:4873/
 
 cd ../packages/admin-ui-plugin && npm publish -reg $VERDACCIO &&\
+cd ../admin-ui && npm publish -reg $VERDACCIO &&\
 cd ../asset-server-plugin && npm publish -reg $VERDACCIO &&\
 cd ../common && npm publish -reg $VERDACCIO &&\
 cd ../core && npm publish -reg $VERDACCIO &&\