From 391e22637135c76b6cdc8a9ddae7a2a78b70f959 Mon Sep 17 00:00:00 2001 From: Vunb Date: Thu, 12 Sep 2019 09:32:08 +0700 Subject: [PATCH 1/2] update readme --- packages/common/README.md | 10 ---------- packages/core/README.md | 10 ---------- packages/express/README.md | 10 ---------- packages/rest/README.md | 10 ---------- 4 files changed, 40 deletions(-) diff --git a/packages/common/README.md b/packages/common/README.md index 6a3c131..ef61749 100644 --- a/packages/common/README.md +++ b/packages/common/README.md @@ -9,16 +9,6 @@ Template-based Web Application Framework **Kites** is a framework providing `dynamic applications` assembling and `Template-based` extracting. Namely it contains a lot of templates and extensions to help building a new application quickly. -Take a look at this: - -```ts -@Launcher({ - imports?: [], // ... kites extensions manually imported here - discover?: Array | string | boolean; // autodiscover extensions in app's child directories or given path -}) -class App {} -``` - Features ======= diff --git a/packages/core/README.md b/packages/core/README.md index 6a3c131..ef61749 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -9,16 +9,6 @@ Template-based Web Application Framework **Kites** is a framework providing `dynamic applications` assembling and `Template-based` extracting. Namely it contains a lot of templates and extensions to help building a new application quickly. -Take a look at this: - -```ts -@Launcher({ - imports?: [], // ... kites extensions manually imported here - discover?: Array | string | boolean; // autodiscover extensions in app's child directories or given path -}) -class App {} -``` - Features ======= diff --git a/packages/express/README.md b/packages/express/README.md index 6a3c131..ef61749 100644 --- a/packages/express/README.md +++ b/packages/express/README.md @@ -9,16 +9,6 @@ Template-based Web Application Framework **Kites** is a framework providing `dynamic applications` assembling and `Template-based` extracting. Namely it contains a lot of templates and extensions to help building a new application quickly. -Take a look at this: - -```ts -@Launcher({ - imports?: [], // ... kites extensions manually imported here - discover?: Array | string | boolean; // autodiscover extensions in app's child directories or given path -}) -class App {} -``` - Features ======= diff --git a/packages/rest/README.md b/packages/rest/README.md index 6a3c131..ef61749 100644 --- a/packages/rest/README.md +++ b/packages/rest/README.md @@ -9,16 +9,6 @@ Template-based Web Application Framework **Kites** is a framework providing `dynamic applications` assembling and `Template-based` extracting. Namely it contains a lot of templates and extensions to help building a new application quickly. -Take a look at this: - -```ts -@Launcher({ - imports?: [], // ... kites extensions manually imported here - discover?: Array | string | boolean; // autodiscover extensions in app's child directories or given path -}) -class App {} -``` - Features ======= From 293c3846833d5af64171f5a08a255922e156a627 Mon Sep 17 00:00:00 2001 From: Vunb Date: Thu, 12 Sep 2019 09:40:53 +0700 Subject: [PATCH 2/2] kites extends extension options --- packages/core/engine/kites-instance.spec.ts | 3 +++ packages/core/extensions/extensions-manager.ts | 5 ++++- .../test/extensions/a-kites-extension/kites.config.js | 6 ------ .../test/extensions/sample-extension/kites.config.js | 9 +++++++++ .../{a-kites-extension => sample-extension}/main.js | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) delete mode 100644 packages/core/test/extensions/a-kites-extension/kites.config.js create mode 100644 packages/core/test/extensions/sample-extension/kites.config.js rename packages/core/test/extensions/{a-kites-extension => sample-extension}/main.js (51%) diff --git a/packages/core/engine/kites-instance.spec.ts b/packages/core/engine/kites-instance.spec.ts index bd1454c..0a054ce 100644 --- a/packages/core/engine/kites-instance.spec.ts +++ b/packages/core/engine/kites-instance.spec.ts @@ -83,6 +83,9 @@ describe('kites engine', () => { }).init(); expect(app.aKitesExtensionInitialized).eq(true, 'found a kites extension which has initialized!'); + expect(app.options.sample).eql({ + always: 'be here' + }, 'read extension options!'); }); it('should accept plain function as an extension', async () => { diff --git a/packages/core/extensions/extensions-manager.ts b/packages/core/extensions/extensions-manager.ts index 4851471..490d497 100644 --- a/packages/core/extensions/extensions-manager.ts +++ b/packages/core/extensions/extensions-manager.ts @@ -108,11 +108,14 @@ class ExtensionsManager extends EventEmitter { private useOne(extension: KitesExtension) { // extends options // Review _.assign(), _.defaults(), or _.merge? + const xname = extension.name && extension.name.toLowerCase(); const options = _.assign< ExtensionOptions, ExtensionOptions | undefined, - ExtensionOptions | undefined>({}, extension.options, this.kites.options[extension.name && extension.name.toLowerCase()]); + ExtensionOptions | undefined>({}, extension.options, this.kites.options[xname]); + extension.options = options; + this.kites.options[xname] = options; if (options.enabled === false) { this.kites.logger.debug(`Extension ${extension.name} is disabled, skipping`); diff --git a/packages/core/test/extensions/a-kites-extension/kites.config.js b/packages/core/test/extensions/a-kites-extension/kites.config.js deleted file mode 100644 index 97b1b41..0000000 --- a/packages/core/test/extensions/a-kites-extension/kites.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - 'name': 'a-kites-extension', - 'main': 'main.js', - 'dependencies': [], - 'hasPublicPart': false -} \ No newline at end of file diff --git a/packages/core/test/extensions/sample-extension/kites.config.js b/packages/core/test/extensions/sample-extension/kites.config.js new file mode 100644 index 0000000..1879c3d --- /dev/null +++ b/packages/core/test/extensions/sample-extension/kites.config.js @@ -0,0 +1,9 @@ +module.exports = { + name: 'sample', + main: 'main.js', + dependencies: [], + hasPublicPart: false, + options: { + always: 'be here' + } +} diff --git a/packages/core/test/extensions/a-kites-extension/main.js b/packages/core/test/extensions/sample-extension/main.js similarity index 51% rename from packages/core/test/extensions/a-kites-extension/main.js rename to packages/core/test/extensions/sample-extension/main.js index 087b320..9b11c04 100644 --- a/packages/core/test/extensions/a-kites-extension/main.js +++ b/packages/core/test/extensions/sample-extension/main.js @@ -1,3 +1,3 @@ module.exports = function (kites, definition) { - kites.aKitesExtensionInitialized = true -} \ No newline at end of file + kites.aKitesExtensionInitialized = true; +}