@sekrab/bin 0.0.0-stage → 6.0.1

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.
Files changed (49) hide show
  1. package/package.json +32 -4
  2. package/readme.md +84 -0
  3. package/tasks/angular/angular.js +295 -0
  4. package/tasks/angular/angulardmart/component.dialog.template +24 -0
  5. package/tasks/angular/angulardmart/component.form.template +57 -0
  6. package/tasks/angular/angulardmart/component.partial.template +21 -0
  7. package/tasks/angular/angulardmart/component.template +21 -0
  8. package/tasks/angular/angulardmart/config.template +7 -0
  9. package/tasks/angular/angulardmart/directive.standalone.template +19 -0
  10. package/tasks/angular/angulardmart/model.template +61 -0
  11. package/tasks/angular/angulardmart/module.template +17 -0
  12. package/tasks/angular/angulardmart/pipe.standalone.template +11 -0
  13. package/tasks/angular/angulardmart/route.standalone.template +6 -0
  14. package/tasks/angular/angulardmart/route.template +4 -0
  15. package/tasks/angular/angulardmart/routeModule.template +21 -0
  16. package/tasks/angular/angulardmart/service.template +66 -0
  17. package/tasks/angular/angulardmart/state.template +10 -0
  18. package/tasks/angular/angulardmart/view.form.template +48 -0
  19. package/tasks/angular/angulardmart/view.partial.template +1 -0
  20. package/tasks/angular/angulardmart/view.template +5 -0
  21. package/tasks/angular/angulartemplates/component.dialog.template +24 -0
  22. package/tasks/angular/angulartemplates/component.form.template +56 -0
  23. package/tasks/angular/angulartemplates/component.partial.template +21 -0
  24. package/tasks/angular/angulartemplates/component.template +21 -0
  25. package/tasks/angular/angulartemplates/config.template +7 -0
  26. package/tasks/angular/angulartemplates/directive.standalone.template +19 -0
  27. package/tasks/angular/angulartemplates/model.template +39 -0
  28. package/tasks/angular/angulartemplates/module.template +17 -0
  29. package/tasks/angular/angulartemplates/pipe.standalone.template +11 -0
  30. package/tasks/angular/angulartemplates/route.standalone.template +6 -0
  31. package/tasks/angular/angulartemplates/route.template +4 -0
  32. package/tasks/angular/angulartemplates/routeModule.template +21 -0
  33. package/tasks/angular/angulartemplates/service.template +80 -0
  34. package/tasks/angular/angulartemplates/state.template +10 -0
  35. package/tasks/angular/angulartemplates/view.form.template +48 -0
  36. package/tasks/angular/angulartemplates/view.partial.template +1 -0
  37. package/tasks/angular/angulartemplates/view.template +5 -0
  38. package/tasks/angular/cli.js +27 -0
  39. package/tasks/angular/extract.js +115 -0
  40. package/tasks/cli.js +27 -0
  41. package/tasks/config.json +42 -0
  42. package/tasks/files.js +22 -0
  43. package/tasks/index.js +19 -0
  44. package/tasks/shut/cli.js +12 -0
  45. package/tasks/shut/critical.js +28 -0
  46. package/tasks/shut/shut.icons.js +78 -0
  47. package/tasks/shut/shut.js +87 -0
  48. package/tasks/svelte/translate.js +51 -0
  49. package/README.md +0 -3
@@ -0,0 +1,21 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { Routes, RouterModule } from '@angular/router';
4
+ // **gulpimport**
5
+
6
+ const routes: Routes = [
7
+ // **gulproute_first**
8
+ ];
9
+
10
+ @NgModule({
11
+ imports: [
12
+ // **gulpcomponent_standalone**
13
+ RouterModule.forChild(routes),
14
+ CommonModule
15
+ ],
16
+ declarations: [
17
+ // **gulpcomponent_first**
18
+ ]
19
+ })
20
+
21
+ export class MajorRoutingModule { }
@@ -0,0 +1,66 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { Config } from 'src/app/config';
3
+ import { map } from 'rxjs/operators';
4
+ import { Observable } from 'rxjs';
5
+ import { HttpClient } from '@angular/common/http';
6
+ import { EnumQueryType, EnumRequestType, EnumResourceType, IParam, Param } from 'src/app/utils/param.model';
7
+ import { mapList, mapResponse } from 'src/app/models/response.model';
8
+ import { I_Name_, _Name_, } from './_name_.model';
9
+ import { IList } from 'src/app/models/list.model';
10
+
11
+
12
+ @Injectable({providedIn: 'root'})
13
+ export class _Name_Service {
14
+
15
+ private http =inject(HttpClient);
16
+
17
+
18
+ Get_Name_s(options: IParam = {}): Observable<IList<I_Name_>> {
19
+ const _options: IParam = {
20
+ type: EnumQueryType.search,
21
+ forTypes: [EnumResourceType.content],
22
+ space: Config.API.rootSpace,
23
+ subpath: Config.API._name_.list,
24
+ size: 100,
25
+ withPayload: true,
26
+ };
27
+ const params = Param.MapQueryParams(_options);
28
+
29
+ return this.http.post(Config.API.resource.query, params).pipe(
30
+ map(response => {
31
+ return _Name_.NewList(mapList(response));
32
+ })
33
+ );
34
+ }
35
+
36
+ Create_Name_(_name_: I_Name_): Observable<I_Name_> {
37
+
38
+
39
+ const data = _Name_.PrepRequest(_name_, EnumRequestType.create);
40
+ return this.http.post(Config.API.resource.request, data).pipe(
41
+ map(response => {
42
+ return _Name_.NewInstance(mapResponse(response));
43
+ })
44
+ );
45
+ }
46
+
47
+ Save_Name_(_name_: I_Name_): Observable<I_Name_> {
48
+ const data = _Name_.PrepRequest(_name_, EnumRequestType.update);
49
+ return this.http.post(Config.API.resource.request, data).pipe(
50
+ map(_ => {
51
+ return _name_;
52
+ })
53
+ );
54
+
55
+ }
56
+
57
+ Delete_Name_(_name_: I_Name_): Observable<boolean> {
58
+ const data = _Name_.PrepRequest(_name_, EnumRequestType.delete);
59
+ return this.http.post(Config.API.resource.request, data).pipe(
60
+ map(_ => {
61
+ return true;
62
+ })
63
+ );
64
+ }
65
+
66
+ }
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { I_Name_ } from './_name_.model';
3
+ import { ListStateService } from 'src/app/utils/state.abstract';
4
+
5
+ @Injectable({providedIn: 'root'})
6
+ export class _Name_ListState extends ListStateService<I_Name_>{
7
+ constructor() {
8
+ super();
9
+ }
10
+ }
@@ -0,0 +1,48 @@
1
+ <form [formGroup]="majorForm" (ngSubmit)="saveMajor()" >
2
+
3
+ <div class="spaced">
4
+ <ol-input placeholder="Name">
5
+ <input
6
+ type="text"
7
+ id="name"
8
+ class="w100"
9
+ olinput
10
+ formControlName="name"
11
+ [required]="true"
12
+ />
13
+ <ng-container helptext>help text</ng-container>
14
+ </ol-input>
15
+ </div>
16
+
17
+ <div class="spaced">
18
+ <ol-input placeholder="Currency">
19
+ <select
20
+ formControlName="currency"
21
+ olinput
22
+ class="w100"
23
+ [required]="true"
24
+ [compareWith]="compareFn"
25
+ >
26
+ @for (currency of ['USD', 'EUR', 'GBP']; track $index) {
27
+ <option [value]="currency">{{ currency }}</option>
28
+ }
29
+ </select>
30
+ </ol-input>
31
+ </div>
32
+
33
+ <div class="spaced">
34
+
35
+ <ol-input placeholder="Notes">
36
+ <textarea
37
+ type="text"
38
+ id="notes"
39
+ class="w100 h2"
40
+ olinput
41
+ formControlName="notes"
42
+ ></textarea>
43
+ </ol-input>
44
+ </div>
45
+
46
+ <button class="btn-rev" type="submit" >Save</button>
47
+
48
+ </form>
@@ -0,0 +1 @@
1
+ <h5>Ready to implement component</h5>
@@ -0,0 +1,5 @@
1
+ <div class="page">
2
+ <div class="container">
3
+ Ready to implement routed component
4
+ </div>
5
+ </div>
@@ -0,0 +1,24 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
3
+ import { RouterModule } from '@angular/router';
4
+ import { DialogPartial } from '../../lib/dialog/partial';
5
+
6
+
7
+ @Component({
8
+ _selector_
9
+ templateUrl: './viewpath.html'
10
+ , changeDetection: ChangeDetectionStrategy.OnPush
11
+ , imports: [CommonModule, RouterModule]
12
+ })
13
+ export class MajorNameDialog implements OnInit {
14
+
15
+ data!: any;
16
+ dialog!: DialogPartial;
17
+
18
+ constructor() {
19
+ //
20
+ }
21
+ ngOnInit(): void {
22
+ //
23
+ }
24
+ }
@@ -0,0 +1,56 @@
1
+ import { ChangeDetectionStrategy, Component, input, OnInit, output } from '@angular/core';
2
+ import { FormGroup, FormBuilder, ReactiveFormsModule } from '@angular/forms';
3
+ import { Toast } from '../../lib/toast/toast.state';
4
+ import { IViewMode } from '../../models/viewmode.model';
5
+ import { CommonModule } from '@angular/common';
6
+ import { RouterModule } from '@angular/router';
7
+ import { InputComponent } from '../../lib/input/input.const';
8
+
9
+ @Component({
10
+ _selector_
11
+ templateUrl: './viewpath.html',
12
+ changeDetection: ChangeDetectionStrategy.OnPush
13
+ , imports: [CommonModule, RouterModule, ReactiveFormsModule, ...InputComponent]
14
+ })
15
+ export class MajorNameFormPartial implements OnInit {
16
+
17
+ mode = input<IViewMode>({ forNew: true });
18
+ onSave = output<any>();
19
+
20
+
21
+ majorForm: FormGroup;
22
+
23
+ constructor(private fb: FormBuilder, private toast: Toast) {
24
+ //
25
+ }
26
+ ngOnInit(): void {
27
+ //
28
+ this.majorForm = this.fb.group({
29
+ name: [],
30
+ currency: [],
31
+ notes: []
32
+ });
33
+ }
34
+
35
+ // use to compare for initial select... keep '=='
36
+ compareFn(c1: any, c2: any): boolean {
37
+ return c1 && c2 ? c1.id == c2.id : false;
38
+ }
39
+
40
+ saveMajor(): void {
41
+ this.toast.Hide();
42
+
43
+
44
+ if (this.majorForm.valid) {
45
+ // clone into a new object
46
+ const _value = this.majorForm.value;
47
+
48
+ const _major = { ..._value};
49
+
50
+ // then emit
51
+ this.onSave.emit(_major);
52
+ } else {
53
+ this.toast.ShowError('INVALID_FORM');
54
+ }
55
+ }
56
+ }
@@ -0,0 +1,21 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { ChangeDetectionStrategy, Component, input, output, OnInit } from '@angular/core';
3
+ import { RouterModule } from '@angular/router';
4
+ @Component({
5
+ _selector_
6
+ templateUrl: './viewpath.html'
7
+ , changeDetection: ChangeDetectionStrategy.OnPush
8
+ , imports: [CommonModule, RouterModule]
9
+ })
10
+ export class MajorNamePartial implements OnInit {
11
+
12
+ id = input.required<string>();
13
+ onSomething = output<any>();
14
+
15
+ constructor() {
16
+ //
17
+ }
18
+ ngOnInit(): void {
19
+ //
20
+ }
21
+ }
@@ -0,0 +1,21 @@
1
+ import { Component, OnInit, ChangeDetectionStrategy, input } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { RouterModule } from '@angular/router';
4
+
5
+ @Component({
6
+ _selector_
7
+ templateUrl: './viewpath.html'
8
+ , changeDetection: ChangeDetectionStrategy.OnPush
9
+ , imports: [CommonModule, RouterModule]
10
+ })
11
+ export class MajorNameComponent implements OnInit {
12
+
13
+ mode = input<string>(); // param
14
+
15
+ constructor() {
16
+ //
17
+ }
18
+ ngOnInit(): void {
19
+ //
20
+ }
21
+ }
@@ -0,0 +1,7 @@
1
+ _name_: {
2
+ list: '/_name_s/?:options',
3
+ details: '/_name_s/:id',
4
+ create: '/_name_s', // POST
5
+ save: '/_name_s/:id', // PUT
6
+ delete: '/_name_s/:id', // DELETE
7
+ }
@@ -0,0 +1,19 @@
1
+ import { OnInit, Directive, ElementRef, Input, Renderer2 } from '@angular/core';
2
+
3
+
4
+ @Directive({
5
+ selector: '[_name_]',
6
+ exportAs: '_name_'
7
+ })
8
+ export class _Name_Directive implements OnInit {
9
+
10
+ @Input() _name_: string;
11
+
12
+ constructor(private el: ElementRef, private renderer: Renderer2) {
13
+ //
14
+ }
15
+
16
+ ngOnInit() {
17
+ //
18
+ }
19
+ }
@@ -0,0 +1,39 @@
1
+ import { DataList, IList } from '../models/list.model';
2
+
3
+ export interface I_Name_ {
4
+ id: string;
5
+ }
6
+
7
+ export class _Name_ {
8
+
9
+ static NewInstance(_name_: any): I_Name_ {
10
+ return {
11
+ id: _name_.id
12
+ }
13
+ }
14
+ static NewInstances(_name_s: any[]): I_Name_[] {
15
+ return _name_s.map(_Name_.NewInstance);
16
+ }
17
+ static NewList(dataset: any): IList<I_Name_> {
18
+ const dl = new DataList<I_Name_>();
19
+ dl.mapper = _Name_.NewInstance;
20
+ return dl.NewDataList(dataset);
21
+
22
+ }
23
+
24
+ // prepare to POST
25
+ static PrepCreate(_name_: I_Name_): any {
26
+ return {
27
+ id: _name_.id
28
+ };
29
+ }
30
+ // prepare to PUT
31
+ static PrepSave(_name_: I_Name_): any {
32
+
33
+ return {
34
+ id: _name_.id
35
+ };
36
+
37
+ }
38
+
39
+ }
@@ -0,0 +1,17 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { RouterModule } from '@angular/router';
3
+ // **gulpimport**
4
+
5
+ @NgModule({
6
+ imports: [
7
+ RouterModule
8
+ ],
9
+ declarations: [
10
+ // **gulpcomponent_first**
11
+ ],
12
+ exports: [
13
+ // **gulpcomponent_first**
14
+ ]
15
+ })
16
+
17
+ export class MajorModule { }
@@ -0,0 +1,11 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+
3
+ @Pipe({ name: '_name_' })
4
+ export class _Name_Pipe implements PipeTransform {
5
+
6
+ transform(_name_: string): string {
7
+ return _name_;
8
+
9
+ }
10
+ }
11
+
@@ -0,0 +1,6 @@
1
+ import { Routes } from '@angular/router';
2
+ // **gulpimport**
3
+
4
+ export const MajorRoutes: Routes = [
5
+ // **gulproute_first**
6
+ ];
@@ -0,0 +1,4 @@
1
+ {
2
+ path: 'name',
3
+ component: MajorNameComponent
4
+ }
@@ -0,0 +1,21 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { Routes, RouterModule } from '@angular/router';
4
+ // **gulpimport**
5
+
6
+ const routes: Routes = [
7
+ // **gulproute_first**
8
+ ];
9
+
10
+ @NgModule({
11
+ imports: [
12
+ // **gulpcomponent_standalone**
13
+ RouterModule.forChild(routes),
14
+ CommonModule
15
+ ],
16
+ declarations: [
17
+ // **gulpcomponent_first**
18
+ ]
19
+ })
20
+
21
+ export class MajorRoutingModule { }
@@ -0,0 +1,80 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { Config } from '../config';
3
+ import { map } from 'rxjs/operators';
4
+ import { Observable } from 'rxjs';
5
+ import { HttpClient } from '@angular/common/http';
6
+ import { GetParamsAsString } from '../utils/common';
7
+ import { IListOptions, IList, ListOptions } from '../models/list.model';
8
+ import { I_Name_, _Name_, } from './_name_.model';
9
+
10
+
11
+ @Injectable({providedIn: 'root'})
12
+ export class _Name_Service {
13
+
14
+ private _listUrl = Config.API._name_.list;
15
+ private _detailsUrl = Config.API._name_.details;
16
+ private _createUrl = Config.API._name_.create;
17
+ private _saveUrl = Config.API._name_.save;
18
+ private _deleteUrl = Config.API._name_.delete;
19
+
20
+ constructor(private _http: HttpClient) {
21
+
22
+ }
23
+
24
+ Get_Name_s(options: IListOptions = {}): Observable<IList<I_Name_>> {
25
+ const params = GetParamsAsString(ListOptions.MapSearchListOptions(options));
26
+ const _url = this._listUrl.replace(':options', params);
27
+
28
+ return this._http.get(_url).pipe(
29
+ map(response => {
30
+ return _Name_.NewList(<any>response);
31
+ })
32
+ );
33
+ }
34
+
35
+
36
+ Get_Name_(id: string): Observable<I_Name_> {
37
+ const _url = this._detailsUrl.replace(':id', id);
38
+ return this._http.get(_url).pipe(
39
+ map(response => {
40
+ return _Name_.NewInstance(response);
41
+ })
42
+ );
43
+
44
+ }
45
+
46
+ Create_Name_(_name_: I_Name_): Observable<I_Name_> {
47
+ const _url = this._createUrl;
48
+ const data = _Name_.PrepCreate(_name_);
49
+ _debug(data, 'Create_Name_ data');
50
+
51
+ return this._http.post(_url, data).pipe(
52
+ map(response => {
53
+ return _Name_.NewInstance(<any>response);
54
+ })
55
+ );
56
+ }
57
+
58
+ Save_Name_(_name_: I_Name_): Observable<I_Name_> {
59
+ const _url = this._saveUrl.replace(':id', _name_.id);
60
+ const data = _Name_.PrepSave(_name_);
61
+ _debug(data, 'Save_Name_ data');
62
+
63
+ return this._http.put(_url, data).pipe(
64
+ map(response => {
65
+ return _name_;
66
+ })
67
+ );
68
+ }
69
+
70
+ Delete_Name_(_name_: I_Name_): Observable<boolean> {
71
+ const _url = this._deleteUrl.replace(':id', _name_.id);
72
+
73
+ return this._http.delete(_url).pipe(
74
+ map(response => {
75
+ return true;
76
+ })
77
+ );
78
+ }
79
+
80
+ }
@@ -0,0 +1,10 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { I_Name_ } from './_name_.model';
3
+ import { ListStateService } from 'src/app/utils/state.abstract';
4
+
5
+ @Injectable({providedIn: 'root'})
6
+ export class _Name_ListState extends ListStateService<I_Name_>{
7
+ constructor() {
8
+ super();
9
+ }
10
+ }
@@ -0,0 +1,48 @@
1
+ <form [formGroup]="majorForm" (ngSubmit)="saveMajor()" >
2
+
3
+ <div class="spaced">
4
+ <cr-input placeholder="Name">
5
+ <input
6
+ type="text"
7
+ id="name"
8
+ class="w100"
9
+ crinput
10
+ formControlName="name"
11
+ [required]="true"
12
+ />
13
+ <ng-container helptext>help text</ng-container>
14
+ </cr-input>
15
+ </div>
16
+
17
+ <div class="spaced">
18
+ <cr-input placeholder="Currency">
19
+ <select
20
+ formControlName="currency"
21
+ crinput
22
+ class="w100"
23
+ [required]="true"
24
+ [compareWith]="compareFn"
25
+ >
26
+ @for (currency of ['USD', 'EUR', 'GBP']; track $index) {
27
+ <option [value]="currency">{{ currency }}</option>
28
+ }
29
+ </select>
30
+ </cr-input>
31
+ </div>
32
+
33
+ <div class="spaced">
34
+
35
+ <cr-input placeholder="Notes">
36
+ <textarea
37
+ type="text"
38
+ id="notes"
39
+ class="w100 h2"
40
+ crinput
41
+ formControlName="notes"
42
+ ></textarea>
43
+ </cr-input>
44
+ </div>
45
+
46
+ <button class="btn-rev" type="submit" >Save</button>
47
+
48
+ </form>
@@ -0,0 +1 @@
1
+ <h5>Ready to implement component</h5>
@@ -0,0 +1,5 @@
1
+ <div class="page">
2
+ <div class="container">
3
+ Ready to implement routed component
4
+ </div>
5
+ </div>
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ // sekrab command line for the angular generators, installed as the "sekrab" bin of @sekrab/bin.
3
+ // Run from a client folder that has a config.json:
4
+ // npx sekrab component --major Projects --name List [--ispartial] [--isform] [--isdialog] [--standalone]
5
+ // npx sekrab <routemodule|pipe|directive|model|service> --name X
6
+ // npx sekrab fullService --name Project [--withstate]
7
+ // npx sekrab extract
8
+ // npx sekrab svelteTranslate
9
+
10
+ const { loadConfig, run } = require('../cli');
11
+ const config = loadConfig();
12
+ const ng = require('./angular')(config);
13
+
14
+ run('sekrab', {
15
+ // extract translation terms into the locale files
16
+ extract: require('./extract')(config),
17
+ // collect svelte translate() calls into keys.lang.json files
18
+ svelteTranslate: require('../svelte/translate')(config),
19
+ // the generators read --major, --name and flags from the command line
20
+ routemodule: ng.createRouteModule,
21
+ component: ng.createComponent,
22
+ pipe: ng.createPipe,
23
+ directive: ng.createDirective,
24
+ model: ng.createModel,
25
+ service: ng.createService,
26
+ fullService: ng.createFullService,
27
+ });