@nutin/cli 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -1
- package/README.md +23 -15
- package/lib/index.mjs +7 -4
- package/lib/src/context-builder.mjs +35 -0
- package/lib/src/file-generator.mjs +26 -126
- package/lib/src/git-manager.mjs +1 -1
- package/lib/src/json-generator.mjs +31 -0
- package/lib/src/package-manager.mjs +21 -18
- package/lib/src/project-generator.mjs +53 -0
- package/lib/src/prompts.mjs +28 -15
- package/lib/src/template-compiler.mjs +1 -1
- package/lib/src/utils.mjs +9 -9
- package/lib/src/version.mjs +1 -0
- package/package.json +1 -1
- package/templates/base/.gitignore.hbs +1 -0
- package/templates/base/builder.config.js.hbs +7 -0
- package/templates/base/src/app/main.ts.hbs +2 -1
- package/templates/base/src/app/views/home/home.view.test.js.hbs +26 -0
- package/templates/base/src/app/views/home/home.view.ts.hbs +2 -2
- package/templates/base/src/app/views/not-found/not-found.view.ts.hbs +1 -1
- package/templates/base/src/core/base-classes/base-component/base-component.ts.hbs +23 -20
- package/templates/base/src/core/base-classes/base-component/helpers/catalog.helper.ts.hbs +2 -2
- package/templates/base/src/core/base-classes/base-component/helpers/children.helper.ts.hbs +4 -4
- package/templates/base/src/core/base-classes/base-component/helpers/dom.helper.ts.hbs +26 -13
- package/templates/base/src/core/base-classes/base-component/helpers/event.helper.ts.hbs +9 -9
- package/templates/base/src/core/base-classes/base-component/helpers/security.helper.ts.hbs +40 -8
- package/templates/base/src/core/base-classes/base-component/helpers/token.helper.ts.hbs +16 -16
- package/templates/base/src/core/base-classes/component/component.ts.hbs +12 -12
- package/templates/base/src/core/base-classes/component/helpers/config.helper.ts.hbs +2 -2
- package/templates/base/src/core/base-classes/component/helpers/data-binding.helper.ts.hbs +2 -2
- package/templates/base/src/core/base-classes/service/service.ts.hbs +35 -12
- package/templates/base/src/core/base-classes/view/view.ts.hbs +6 -6
- package/templates/base/src/core/services/event-bus/event-bus.ts.hbs +13 -13
- package/templates/base/src/core/services/http-client/helpers/http-builder.helper.ts.hbs +18 -18
- package/templates/base/src/core/services/http-client/helpers/http-manager.helper.ts.hbs +24 -24
- package/templates/base/src/core/services/http-client/http-client.ts.hbs +19 -19
- package/templates/base/src/core/services/pipe-registry/pipe-registry.ts.hbs +6 -6
- package/templates/base/src/core/services/router/helpers/navigation-manager.helper.ts.hbs +13 -13
- package/templates/base/src/core/services/router/helpers/route-guard-manager.helper.ts.hbs +22 -22
- package/templates/base/src/core/services/router/helpers/view-render-manager.helper.ts.hbs +6 -5
- package/templates/base/src/core/services/router/router.ts.hbs +45 -45
- package/templates/base/src/core/services/store/store.ts.hbs +6 -6
- package/templates/base/src/core/utils/anchor-manager/anchor-manager.utils.ts.hbs +6 -8
- package/templates/base/src/core/utils/button-manager/button-manager.utils.ts.hbs +9 -11
- package/templates/base/src/core/utils/helpers/attributes.helper.ts.hbs +11 -5
- package/templates/base/src/libs/pipes/pipes.ts.hbs +1 -1
- package/templates/base/src/libs/popover/popover.ts.hbs +48 -48
- package/templates/base/src/libs/snackbar/snackbar.ts.hbs +1 -1
- package/templates/base/tools/builder/builder.js.hbs +9 -3
- package/templates/base/tools/builder/core/add-tags.js.hbs +46 -0
- package/templates/base/tools/builder/core/copy-static.js.hbs +35 -35
- package/templates/base/tools/builder/core/finalize-build.js.hbs +6 -6
- package/templates/base/tools/builder/core/hash-files.js.hbs +52 -0
- package/templates/base/tools/builder/core/validate-html.js.hbs +12 -32
- package/templates/base/tools/utils/get-files-recursive.js.hbs +17 -8
- package/templates/features/deployHelper/tools/builder/core/compress-files.js.hbs +56 -0
- package/templates/{base → features/deployHelper}/tools/deployment/Dockerfile.hbs +12 -4
- package/templates/{base → features/deployHelper}/tools/deployment/nginx.conf.hbs +30 -2
- package/templates/features/i18n/src/core/base-classes/base-component/helpers/i18n.helper.ts.hbs +4 -6
- package/templates/features/i18n/src/core/services/i18n/i18n.ts.hbs +38 -47
- package/templates/features/stylinNutin/src/styles/core/_utilities.scss.hbs +17 -0
- package/templates/features/template/src/app/views/home/home.view.html.hbs +1 -1
- package/templates/features/template/tools/builder/core/merge-templates.js.hbs +2 -2
- package/templates/features/testinNutin/testin-nutin/core/src/utils/test-queue.js.hbs +2 -2
- package/templates/features/testinNutin/testin-nutin/runner.js.hbs +1 -0
- package/templates/features/testinNutin/testin-nutin.config.js.hbs +2 -2
- package/templates/base/tools/deployment/gzip.conf.hbs +0 -19
- package/templates/features/i18n/src/app/views/home/locales/fr.json.hbs +0 -9
- /package/templates/{base → features/deployHelper}/.dockerignore.hbs +0 -0
|
@@ -14,34 +14,16 @@ export class I18n extends Service<I18n> {
|
|
|
14
14
|
this._currentLanguage = this.getBrowserLanguage();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
private async loadDefaultTranslations(): Promise<void> {
|
|
22
|
-
try {
|
|
23
|
-
const response = await fetch(`/locales/${this._DEFAULT_LANGUAGE}.json`);
|
|
24
|
-
|
|
25
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
26
|
-
|
|
27
|
-
this._defaultTranslations = await response.json();
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.error('Default translation load error:', error);
|
|
30
|
-
}
|
|
17
|
+
public get currentLanguage(): Language {
|
|
18
|
+
return this._currentLanguage;
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
for (const key of keys) {
|
|
36
|
-
value = value?.[key];
|
|
37
|
-
if (!value) break;
|
|
38
|
-
}
|
|
39
|
-
return value;
|
|
21
|
+
public get defaultLanguage(): Language {
|
|
22
|
+
return this._DEFAULT_LANGUAGE;
|
|
40
23
|
}
|
|
41
24
|
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
this.dispose();
|
|
25
|
+
public get languages(): Language[] {
|
|
26
|
+
return this._LANGUAGES;
|
|
45
27
|
}
|
|
46
28
|
|
|
47
29
|
public async loadTranslations(lang: Language): Promise<void> {
|
|
@@ -63,7 +45,7 @@ export class I18n extends Service<I18n> {
|
|
|
63
45
|
}
|
|
64
46
|
}
|
|
65
47
|
|
|
66
|
-
public translate(key: string,
|
|
48
|
+
public translate(key: string, textContent?: string | null): string {
|
|
67
49
|
const keys = key.split('.');
|
|
68
50
|
|
|
69
51
|
// Try to get value from current language translations
|
|
@@ -74,28 +56,7 @@ export class I18n extends Service<I18n> {
|
|
|
74
56
|
value = this.getNestedValue(this._defaultTranslations, keys);
|
|
75
57
|
}
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
let result = value || key;
|
|
79
|
-
|
|
80
|
-
if (params) {
|
|
81
|
-
Object.entries(params).forEach(([k, v]) => {
|
|
82
|
-
result = result.replace(`{${k}}`, v);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public get currentLanguage(): Language {
|
|
90
|
-
return this._currentLanguage;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
public get defaultLanguage(): Language {
|
|
94
|
-
return this._DEFAULT_LANGUAGE;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
public get languages(): Language[] {
|
|
98
|
-
return this._LANGUAGES;
|
|
59
|
+
return value || textContent || key;
|
|
99
60
|
}
|
|
100
61
|
|
|
101
62
|
public async initTranslations(): Promise<void> {
|
|
@@ -115,6 +76,36 @@ export class I18n extends Service<I18n> {
|
|
|
115
76
|
this._defaultTranslations = {};
|
|
116
77
|
this._currentLanguage = this._DEFAULT_LANGUAGE;
|
|
117
78
|
}
|
|
79
|
+
|
|
80
|
+
protected onDestroy(): void | Promise<void> {
|
|
81
|
+
this.resetTranslations();
|
|
82
|
+
this.dispose();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private getBrowserLanguage() {
|
|
86
|
+
return navigator.language.split('-')[0] as Language;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
private async loadDefaultTranslations(): Promise<void> {
|
|
90
|
+
try {
|
|
91
|
+
const response = await fetch(`/locales/${this._DEFAULT_LANGUAGE}.json`);
|
|
92
|
+
|
|
93
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
94
|
+
|
|
95
|
+
this._defaultTranslations = await response.json();
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('Default translation load error:', error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private getNestedValue(obj: any, keys: string[]): any {
|
|
102
|
+
let value = obj;
|
|
103
|
+
for (const key of keys) {
|
|
104
|
+
value = value?.[key];
|
|
105
|
+
if (!value) break;
|
|
106
|
+
}
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
118
109
|
}
|
|
119
110
|
|
|
120
111
|
export const I18nService = I18n.getInstance();
|
|
@@ -90,6 +90,23 @@
|
|
|
90
90
|
font-family: $secondary-font;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
.u-font-primary {
|
|
94
|
+
font-family: $primary-font;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// text
|
|
98
|
+
.u-text-center {
|
|
99
|
+
text-align: center;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.u-text-right {
|
|
103
|
+
text-align: right;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.u-text-left {
|
|
107
|
+
text-align: left;
|
|
108
|
+
}
|
|
109
|
+
|
|
93
110
|
// flex
|
|
94
111
|
.u-flex-center {
|
|
95
112
|
@include mixins.flex-center;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{{#if stylinNutin}}
|
|
3
3
|
class="u-flex-center u-flex-column u-padd-y-large"
|
|
4
4
|
{{else}}
|
|
5
|
-
style="display:flex;justify-content:center;align-items:center;flex-direction:column"
|
|
5
|
+
style="display:flex;justify-content:center;align-items:center;flex-direction:column;padding-top:1rem;padding-bottom:1rem;"
|
|
6
6
|
{{/if}}>
|
|
7
7
|
<h1
|
|
8
8
|
{{#if i18n}}
|
|
@@ -19,7 +19,7 @@ async function mergeTemplates() {
|
|
|
19
19
|
try {
|
|
20
20
|
const htmlContent = await fs.readFile(htmlPath, 'utf-8');
|
|
21
21
|
const minifiedHtml = await minifyHTML(htmlContent);
|
|
22
|
-
if (isVerbose) print.info(`Minified HTML: ${
|
|
22
|
+
if (isVerbose) print.info(`Minified HTML: ${htmlPath}`);
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
25
|
let jsContent = await fs.readFile(jsPath, 'utf-8');
|
|
@@ -32,7 +32,7 @@ async function mergeTemplates() {
|
|
|
32
32
|
jsContent = jsContent.replace(PLACEHOLDER, minifiedHtml);
|
|
33
33
|
await fs.writeFile(jsPath, jsContent);
|
|
34
34
|
await fs.unlink(htmlPath);
|
|
35
|
-
if (isVerbose) print.info(
|
|
35
|
+
if (isVerbose) print.info(`Updated ${jsFilename} with template from ${htmlFilename}.`);
|
|
36
36
|
} catch (err) {
|
|
37
37
|
print.boldError(`ERROR: Cannot update ${jsFilename}. ${err.message}`);
|
|
38
38
|
}
|
|
@@ -24,9 +24,11 @@ export async function runQueuedTests() {
|
|
|
24
24
|
test = testQueue.deque();
|
|
25
25
|
|
|
26
26
|
if (test.suiteName !== previousSuite) {
|
|
27
|
+
teardownJsdom();
|
|
27
28
|
if (previousSuiteAfterAll) {
|
|
28
29
|
await previousSuiteAfterAll();
|
|
29
30
|
}
|
|
31
|
+
setupJsdom();
|
|
30
32
|
if (test.beforeAll) {
|
|
31
33
|
await test.beforeAll();
|
|
32
34
|
}
|
|
@@ -34,11 +36,9 @@ export async function runQueuedTests() {
|
|
|
34
36
|
previousSuiteAfterAll = test.afterAll;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
setupJsdom();
|
|
38
39
|
if (test.beforeEach) await test.beforeEach();
|
|
39
40
|
await test.testFn();
|
|
40
41
|
if (test.afterEach) await test.afterEach();
|
|
41
|
-
teardownJsdom();
|
|
42
42
|
|
|
43
43
|
passed++;
|
|
44
44
|
results.push({
|
|
@@ -4,11 +4,11 @@ export default {
|
|
|
4
4
|
// 'src/core', // toolkit core logic
|
|
5
5
|
// 'testin-nutin/core/tests', // test globals
|
|
6
6
|
],
|
|
7
|
-
verbose: false,
|
|
8
7
|
jsdomOptions: {
|
|
9
8
|
runScripts: false, // or true ("dangerously") if needed
|
|
10
9
|
resources: false, // or true ("usable") if needed
|
|
11
10
|
freezeGlobals: false,
|
|
12
11
|
pretendToBeVisual: true,
|
|
13
|
-
}
|
|
12
|
+
},
|
|
13
|
+
verbose: false,
|
|
14
14
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
gzip on;
|
|
2
|
-
gzip_vary on;
|
|
3
|
-
gzip_proxied any;
|
|
4
|
-
gzip_comp_level 6;
|
|
5
|
-
gzip_min_length 1000;
|
|
6
|
-
|
|
7
|
-
gzip_types
|
|
8
|
-
text/plain
|
|
9
|
-
text/css
|
|
10
|
-
text/xml
|
|
11
|
-
text/javascript
|
|
12
|
-
application/json
|
|
13
|
-
application/javascript
|
|
14
|
-
application/xml+rss
|
|
15
|
-
application/rss+xml
|
|
16
|
-
font/truetype
|
|
17
|
-
font/opentype
|
|
18
|
-
application/vnd.ms-fontobject
|
|
19
|
-
image/svg+xml;
|
|
File without changes
|