@sealcode/sealgen 0.1.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.
Files changed (72) hide show
  1. package/.arcconfig +12 -0
  2. package/.arclint +18 -0
  3. package/.eslintrc.js +37 -0
  4. package/.log/ti-10372.log +479 -0
  5. package/.log/ti-10727.log +479 -0
  6. package/.log/tsserver.log +3811 -0
  7. package/.prettierrc +14 -0
  8. package/@types/add-collection.d.ts +1 -0
  9. package/@types/add-route.d.ts +1 -0
  10. package/@types/back/collections/delete-me.d.ts +7 -0
  11. package/@types/generate-collections.d.ts +1 -0
  12. package/@types/generate-routes.d.ts +1 -0
  13. package/@types/index.d.ts +2 -0
  14. package/@types/templates/collection.d.ts +1 -0
  15. package/@types/templates/form.d.ts +1 -0
  16. package/@types/templates/page.d.ts +1 -0
  17. package/@types/templates/route-test.d.ts +1 -0
  18. package/@types/utils/escape-url-params.d.ts +2 -0
  19. package/@types/utils/exec.d.ts +5 -0
  20. package/@types/utils/import-path.d.ts +2 -0
  21. package/@types/utils/question.d.ts +1 -0
  22. package/@types/utils/walk.d.ts +1 -0
  23. package/jenkins.sanity.sh +3 -0
  24. package/lib/add-collection.js +41 -0
  25. package/lib/add-collection.js.map +1 -0
  26. package/lib/add-route.js +52 -0
  27. package/lib/add-route.js.map +1 -0
  28. package/lib/back/collections/delete-me.js +14 -0
  29. package/lib/back/collections/delete-me.js.map +1 -0
  30. package/lib/generate-collections.js +67 -0
  31. package/lib/generate-collections.js.map +1 -0
  32. package/lib/generate-routes.js +71 -0
  33. package/lib/generate-routes.js.map +1 -0
  34. package/lib/index.js +39 -0
  35. package/lib/index.js.map +1 -0
  36. package/lib/templates/collection.js +16 -0
  37. package/lib/templates/collection.js.map +1 -0
  38. package/lib/templates/form.js +46 -0
  39. package/lib/templates/form.js.map +1 -0
  40. package/lib/templates/page.js +24 -0
  41. package/lib/templates/page.js.map +1 -0
  42. package/lib/templates/route-test.js +27 -0
  43. package/lib/templates/route-test.js.map +1 -0
  44. package/lib/utils/escape-url-params.js +18 -0
  45. package/lib/utils/escape-url-params.js.map +1 -0
  46. package/lib/utils/exec.js +37 -0
  47. package/lib/utils/exec.js.map +1 -0
  48. package/lib/utils/import-path.js +24 -0
  49. package/lib/utils/import-path.js.map +1 -0
  50. package/lib/utils/question.js +34 -0
  51. package/lib/utils/question.js.map +1 -0
  52. package/lib/utils/walk.js +35 -0
  53. package/lib/utils/walk.js.map +1 -0
  54. package/package.json +38 -0
  55. package/src/add-collection.ts +30 -0
  56. package/src/add-route.ts +49 -0
  57. package/src/example.test.ts +11 -0
  58. package/src/generate-collections.ts +72 -0
  59. package/src/generate-routes.ts +78 -0
  60. package/src/index.ts +28 -0
  61. package/src/templates/collection.ts +11 -0
  62. package/src/templates/form.ts +42 -0
  63. package/src/templates/page.ts +23 -0
  64. package/src/templates/route-test.ts +23 -0
  65. package/src/tsconfig.json +18 -0
  66. package/src/utils/escape-url-params.ts +13 -0
  67. package/src/utils/exec.ts +24 -0
  68. package/src/utils/import-path.ts +25 -0
  69. package/src/utils/question.ts +20 -0
  70. package/src/utils/walk.ts +20 -0
  71. package/test.js +68 -0
  72. package/tsconfig.json +26 -0
package/.prettierrc ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ useTabs: true,
3
+ tabWidth: 4,
4
+ trailingComma: "es5",
5
+ "overrides": [
6
+ {
7
+ "files": "*.yml",
8
+ "options": {
9
+ "tabWidth": 2,
10
+ "useTabs": false
11
+ }
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1 @@
1
+ export declare function addCollection(): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function addRoute(): Promise<void>;
@@ -0,0 +1,7 @@
1
+ import { Collection } from "sealious";
2
+ export default class Deleteme extends Collection {
3
+ fields: {
4
+ content: any;
5
+ };
6
+ defaultPolicy: any;
7
+ }
@@ -0,0 +1 @@
1
+ export declare function generateCollections(): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function generateRoutes(): Promise<void>;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1 @@
1
+ export declare function collectionTemplate(collection_name: string): string;
@@ -0,0 +1 @@
1
+ export declare const formTemplate: (action_name: string, newfilefullpath: string) => string;
@@ -0,0 +1 @@
1
+ export declare const pageTemplate: (action_name: string, fullpath: string) => string;
@@ -0,0 +1 @@
1
+ export declare function testTemplate(action_name: string, new_file_fullpath: string): string;
@@ -0,0 +1,2 @@
1
+ export declare function escape_url_params(url: string): string;
2
+ export declare function unescape_url_params(url: string): string;
@@ -0,0 +1,5 @@
1
+ export declare function exec(program: string, args: string[]): Promise<{
2
+ stderr: string;
3
+ stdout: string;
4
+ exitCode: number;
5
+ }>;
@@ -0,0 +1,2 @@
1
+ export declare function importPath(project_module_path: string, project_target_path: string): string;
2
+ export declare function curryImportPath(project_module_path: string): (project_target_path: string) => string;
@@ -0,0 +1 @@
1
+ export declare function question(text: string, validator: (answer: string) => boolean): Promise<string>;
@@ -0,0 +1 @@
1
+ export declare function walk(dir: string): Promise<string[]>;
@@ -0,0 +1,3 @@
1
+ #!/bin/bash -xe
2
+ npm run test
3
+ npm run build
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.addCollection = void 0;
16
+ const path_1 = require("path");
17
+ const locreq_1 = __importDefault(require("locreq"));
18
+ const fs_1 = require("fs");
19
+ const question_1 = require("./utils/question");
20
+ const collection_1 = require("./templates/collection");
21
+ const generate_collections_1 = require("./generate-collections");
22
+ const target_locreq = locreq_1.default(process.cwd());
23
+ function addCollection() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const collection_name = yield question_1.question('What\'s the name of the collection class (e.g. "SecretDocuments", must start with a capital letter): ', (s) => s.length > 3 && s[0].toUpperCase() == s[0]);
26
+ const url = yield question_1.question("Enter the url-friendly name for the collection (e.g. secret-documents): ", (s) => !s.includes("/") && !s.includes(" "));
27
+ const file_path = target_locreq.resolve(`src/back/collections/${url}.ts`);
28
+ if (fs_1.existsSync(file_path)) {
29
+ // eslint-disable-next-line no-console
30
+ console.error(`ERROR: File ${file_path} already exists.`);
31
+ return;
32
+ }
33
+ yield fs_1.promises.mkdir(path_1.resolve(file_path, "../"), { recursive: true });
34
+ yield fs_1.promises.writeFile(file_path, collection_1.collectionTemplate(collection_name));
35
+ // eslint-disable-next-line no-console
36
+ console.log(`${file_path} created`);
37
+ yield generate_collections_1.generateCollections();
38
+ });
39
+ }
40
+ exports.addCollection = addCollection;
41
+ //# sourceMappingURL=add-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-collection.js","sourceRoot":"","sources":["../src/add-collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,oDAA6B;AAC7B,2BAAgD;AAChD,+CAA4C;AAC5C,uDAA4D;AAC5D,iEAA6D;AAC7D,MAAM,aAAa,GAAG,gBAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAE7C,SAAsB,aAAa;;QAClC,MAAM,eAAe,GAAG,MAAM,mBAAQ,CACrC,uGAAuG,EACvG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CACzD,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,mBAAQ,CACzB,0EAA0E,EAC1E,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CACnD,CAAC;QACF,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,wBAAwB,GAAG,KAAK,CAAC,CAAC;QAE1E,IAAI,eAAU,CAAC,SAAS,CAAC,EAAE;YAC1B,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,eAAe,SAAS,kBAAkB,CAAC,CAAC;YAC1D,OAAO;SACP;QACD,MAAM,aAAE,CAAC,KAAK,CAAC,cAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,MAAM,aAAE,CAAC,SAAS,CAAC,SAAS,EAAE,+BAAkB,CAAC,eAAe,CAAC,CAAC,CAAC;QACnE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,UAAU,CAAC,CAAC;QACpC,MAAM,0CAAmB,EAAE,CAAC;IAC7B,CAAC;CAAA;AArBD,sCAqBC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.addRoute = void 0;
16
+ const path_1 = require("path");
17
+ const fs_1 = require("fs");
18
+ const question_1 = require("./utils/question");
19
+ const page_1 = require("./templates/page");
20
+ const form_1 = require("./templates/form");
21
+ const route_test_1 = require("./templates/route-test");
22
+ const escape_url_params_1 = require("./utils/escape-url-params");
23
+ const locreq_1 = __importDefault(require("locreq"));
24
+ const generate_routes_1 = require("./generate-routes");
25
+ const target_locreq = locreq_1.default(process.cwd());
26
+ function addRoute() {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const action = yield question_1.question('What\'s the name of the action (e.g. "AddUser"): ', (s) => s.length > 3);
29
+ const url = yield question_1.question("Enter a full absolute answer for the new route (e.g. /admin/users/add): ", (s) => s.trim()[0] == "/");
30
+ const mode = (yield question_1.question("Is this a page (p) or a form (f)? ", (a) => ["p", "f"].includes(a.toLowerCase()))) == "p"
31
+ ? "page"
32
+ : "form";
33
+ const file_path = target_locreq.resolve(`src/back/routes/${escape_url_params_1.escape_url_params(url)}.${mode}.ts`);
34
+ const test_file_path = target_locreq.resolve(`src/back/routes/${escape_url_params_1.escape_url_params(url)}.test.ts`);
35
+ const template = mode == "page" ? page_1.pageTemplate : form_1.formTemplate;
36
+ if (fs_1.existsSync(file_path)) {
37
+ // eslint-disable-next-line no-console
38
+ console.error(`ERROR: File ${file_path} already exists.`);
39
+ return;
40
+ }
41
+ yield fs_1.promises.mkdir(path_1.resolve(file_path, "../"), { recursive: true });
42
+ yield fs_1.promises.writeFile(file_path, template(action, file_path));
43
+ yield fs_1.promises.writeFile(test_file_path, route_test_1.testTemplate(action, file_path));
44
+ // eslint-disable-next-line no-console
45
+ console.log(`${file_path} created`);
46
+ // eslint-disable-next-line no-console
47
+ console.log(`${test_file_path} created`);
48
+ yield generate_routes_1.generateRoutes();
49
+ });
50
+ }
51
+ exports.addRoute = addRoute;
52
+ //# sourceMappingURL=add-route.js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B,sCAAsC;YACtC,OAAO,CAAC,KAAK,CAAC,eAAe,SAAS,kBAAkB,CAAC,CAAC;YAC1D,OAAO;SACP;QACD,MAAM,aAAE,CAAC,KAAK,CAAC,cAAO,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,MAAM,aAAE,CAAC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;QAC3D,MAAM,aAAE,CAAC,SAAS,CAAC,cAAc,EAAE,yBAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;QACpE,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,UAAU,CAAC,CAAC;QACpC,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,GAAG,cAAc,UAAU,CAAC,CAAC;QACzC,MAAM,gCAAc,EAAE,CAAC;IACxB,CAAC;CAAA;AApCD,4BAoCC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sealious_1 = require("sealious");
4
+ class Deleteme extends sealious_1.Collection {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.fields = {
8
+ content: new sealious_1.FieldTypes.Text(),
9
+ };
10
+ this.defaultPolicy = new sealious_1.Policies.Public();
11
+ }
12
+ }
13
+ exports.default = Deleteme;
14
+ //# sourceMappingURL=delete-me.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-me.js","sourceRoot":"","sources":["../../../src/back/collections/delete-me.ts"],"names":[],"mappings":";;AAAA,uCAA4D;AAE5D,MAAqB,QAAS,SAAQ,qBAAU;IAAhD;;QACC,WAAM,GAAG;YACR,OAAO,EAAE,IAAI,qBAAU,CAAC,IAAI,EAAE;SAC9B,CAAC;QACF,kBAAa,GAAG,IAAI,mBAAQ,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;CAAA;AALD,2BAKC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.generateCollections = void 0;
16
+ const locreq_1 = __importDefault(require("locreq"));
17
+ const fs_1 = require("fs");
18
+ const ts_predicates_1 = require("@sealcode/ts-predicates");
19
+ const target_locreq = locreq_1.default(process.cwd());
20
+ function extractCollectionClassname(full_file_path) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const file_content = yield fs_1.promises.readFile(full_file_path, "utf-8");
23
+ const result = file_content.match(/export default class (\w+)/);
24
+ if (result === null) {
25
+ throw new Error("Missing 'export default class' statement?");
26
+ }
27
+ return ts_predicates_1.assertType(result[1], ts_predicates_1.predicates.string, "Missing export default class?");
28
+ });
29
+ }
30
+ function generateCollections() {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const collections_dir = target_locreq.resolve("src/back/collections");
33
+ const files = (yield fs_1.promises.readdir(collections_dir)).filter((f) => !f.match(/\.(sub)?test\./) && f != "collections.ts");
34
+ const file_data = yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
35
+ const full_path = target_locreq.resolve("src/back/collections/" + file);
36
+ const class_name = yield extractCollectionClassname(full_path);
37
+ return {
38
+ class_name,
39
+ file,
40
+ full_path,
41
+ urlname: file.replace(".ts", ""),
42
+ };
43
+ })));
44
+ const content = `// DO NOT EDIT! This file is generated automaticaly with 'npm run generate-collections'
45
+ import { App } from "sealious";
46
+
47
+ ${file_data
48
+ .map(({ class_name, urlname }) => `import _${class_name} from "./${urlname}";`)
49
+ .join("\n")}
50
+
51
+ ${file_data
52
+ .map(({ class_name }) => `export const ${class_name} = new _${class_name}();`)
53
+ .join("\n")}
54
+
55
+ export const collections = {
56
+ ...App.BaseCollections,
57
+ ${file_data
58
+ .map(({ class_name, urlname }) => ` "${urlname}": ${class_name},`)
59
+ .join("\n")}
60
+ };`;
61
+ yield fs_1.promises.writeFile(target_locreq.resolve("src/back/collections/collections.ts"), content);
62
+ // eslint-disable-next-line no-console
63
+ console.log("Successfuly generated new src/back/collections/collections.ts file");
64
+ });
65
+ }
66
+ exports.generateCollections = generateCollections;
67
+ //# sourceMappingURL=generate-collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-collections.js","sourceRoot":"","sources":["../src/generate-collections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,2BAAoC;AACpC,2DAAiE;AAEjE,MAAM,aAAa,GAAG,gBAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAE7C,SAAe,0BAA0B,CACxC,cAAsB;;QAEtB,MAAM,YAAY,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChE,IAAI,MAAM,KAAK,IAAI,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;SAC7D;QACD,OAAO,0BAAU,CAChB,MAAM,CAAC,CAAC,CAAC,EACT,0BAAU,CAAC,MAAM,EACjB,+BAA+B,CAC/B,CAAC;IACH,CAAC;CAAA;AAED,SAAsB,mBAAmB;;QACxC,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC,sB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AO,CAAC,GAAG,CACV,oEAAoE,CACpE,CAAC;IACH,CAAC;CAAA;AAlDD,kDAkDC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.generateRoutes = void 0;
16
+ const fs_1 = require("fs");
17
+ const path_1 = require("path");
18
+ const locreq_1 = __importDefault(require("locreq"));
19
+ const walk_1 = require("./utils/walk");
20
+ const import_path_1 = require("./utils/import-path");
21
+ const ts_predicates_1 = require("@sealcode/ts-predicates");
22
+ const escape_url_params_1 = require("./utils/escape-url-params");
23
+ const locreq = locreq_1.default(__dirname);
24
+ function extractActionName(full_file_path) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const file_content = yield fs_1.promises.readFile(full_file_path, "utf-8");
27
+ const result = file_content.match(/export const actionName = "(\w+)"/);
28
+ if (result === null) {
29
+ throw new Error("Missing 'export const actionName' statement?");
30
+ }
31
+ return ts_predicates_1.assertType(result[1], ts_predicates_1.predicates.string, "Missing export default class?");
32
+ });
33
+ }
34
+ function generateRoutes() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const files = yield Promise.all((yield walk_1.walk(locreq.resolve("src/back/routes")))
37
+ .filter((f) => f.endsWith(".page.ts") || f.endsWith(".form.ts"))
38
+ .map((fullpath) => __awaiter(this, void 0, void 0, function* () {
39
+ return ({
40
+ fullpath,
41
+ actionName: yield extractActionName(fullpath),
42
+ url: escape_url_params_1.unescape_url_params("/" +
43
+ path_1.relative(locreq.resolve("src/back/routes"), fullpath).replace(/\..+/, "")),
44
+ });
45
+ })));
46
+ yield fs_1.promises.writeFile(locreq.resolve("src/back/routes/routes.ts"), `// DO NOT EDIT! This file is generated automaticaly with npm run generate-routes
47
+
48
+ import Router from "@koa/router";
49
+ import { Middlewares } from "sealious";
50
+
51
+ ${files
52
+ .map(({ actionName, fullpath }) => `import { default as ${actionName} } from "${import_path_1.importPath(locreq.resolve("src/back/routes/routes.ts"), fullpath)}";`)
53
+ .join("\n")}
54
+
55
+ ${files
56
+ .map(({ actionName, url }) => `export const ${actionName}URL = "${url}";`)
57
+ .join("\n")}
58
+
59
+ export default function mountAutoRoutes(router: Router) {
60
+ ${files
61
+ .map(({ actionName, }) => ` router.use(${actionName}URL, Middlewares.extractContext(), Middlewares.parseBody());
62
+ ${actionName}.mount(router, ${actionName}URL);`)
63
+ .join("\n\n")}
64
+ }
65
+ `);
66
+ // eslint-disable-next-line no-console
67
+ console.log("Successfuly generated new src/back/routes/routes.ts file");
68
+ });
69
+ }
70
+ exports.generateRoutes = generateRoutes;
71
+ //# sourceMappingURL=generate-routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-routes.js","sourceRoot":"","sources":["../src/generate-routes.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2BAAoC;AACpC,+BAAgC;AAChC,oDAA6B;AAC7B,uCAAoC;AACpC,qDAAiD;AACjD,2DAAiE;AACjE,iEAAgE;AAEhE,MAAM,MAAM,GAAG,gBAAO,CAAC,SAAS,CAAC,CAAC;AAElC,SAAe,iBAAiB,CAAC,cAAsB;;QACtD,MAAM,YAAY,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,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CAAC,gBAAgB,UAAU,UAAU,GAAG,IAAI,CAAC;aACzE,IAAI,CAAC,IAAI,CAAC;;;EAGV,KAAK;aACL,GAAG,CACH,CAAC,EACA,UAAU,GACV,EAAE,EAAE,CAAC,eAAe,UAAU;GAC9B,UAAU,kBAAkB,UAAU,OAAO,CAC9C;aACA,IAAI,CAAC,MAAM,CAAC;;CAEb,CACC,CAAC;QACF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;IACzE,CAAC;CAAA;AAtDD,wCAsDC"}
package/lib/index.js ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ const add_collection_1 = require("./add-collection");
14
+ const add_route_1 = require("./add-route");
15
+ const generate_collections_1 = require("./generate-collections");
16
+ const generate_routes_1 = require("./generate-routes");
17
+ const actions = {
18
+ "add-collection": add_collection_1.addCollection,
19
+ "add-route": add_route_1.addRoute,
20
+ "generate-collections": generate_collections_1.generateCollections,
21
+ "generate-routes": generate_routes_1.generateRoutes,
22
+ default: function () {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ console.log("Usage: `sealscript <action>`");
25
+ console.log(`Available actions: ${Object.keys(actions)
26
+ .filter((e) => e != "default")
27
+ .join(", ")}`);
28
+ });
29
+ },
30
+ };
31
+ void (function () {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const action = process.argv.at(-1);
34
+ actions;
35
+ const fn = actions[action || "default"] || actions.default;
36
+ yield fn();
37
+ });
38
+ })();
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,qDAAiD;AACjD,2CAAuC;AACvC,iEAA6D;AAC7D,uDAAmD;AAEnD,MAAM,OAAO,GAAoD;IAChE,gBAAgB,EAAE,8BAAa;IAC/B,WAAW,EAAE,oBAAQ;IACrB,sBAAsB,EAAE,0CAAmB;IAC3C,iBAAiB,EAAE,gCAAc;IACjC,OAAO,EAAE;;YACR,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;YAC5C,OAAO,CAAC,GAAG,CACV,sBAAsB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;iBACxC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,SAAS,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC,EAAE,CACd,CAAC;QACH,CAAC;KAAA;CACD,CAAC;AAEF,KAAK,CAAC;;QACL,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,OAAO,CAAC;QACR,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC;QAC3D,MAAM,EAAE,EAAE,CAAC;IACZ,CAAC;CAAA,CAAC,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectionTemplate = void 0;
4
+ function collectionTemplate(collection_name) {
5
+ return `import { Collection, FieldTypes, Policies } from "sealious";
6
+
7
+ export default class ${collection_name} extends Collection {
8
+ fields = {
9
+ content: new FieldTypes.Text(),
10
+ };
11
+ defaultPolicy = new Policies.Public();
12
+ }
13
+ `;
14
+ }
15
+ exports.collectionTemplate = collectionTemplate;
16
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/templates/collection.ts"],"names":[],"mappings":";;;AAAA,SAAgB,kBAAkB,CAAC,eAAuB;IACzD,OAAO;;uBAEe,eAAe;;;;;;CAMrC,CAAC;AACF,CAAC;AAVD,gDAUC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formTemplate = void 0;
4
+ const import_path_1 = require("../utils/import-path");
5
+ const formTemplate = (action_name, newfilefullpath) => {
6
+ const rel = import_path_1.curryImportPath(newfilefullpath);
7
+ return `import { BaseContext } from "koa";
8
+ import Users from "${rel("src/back/collections/users")}";
9
+ import { FormHeader, SimpleInput } from "${rel("src/back/forms/controls")}";
10
+ import { FormField } from "${rel("src/back/forms/field")}";
11
+ import Form, { FormData } from "${rel("src/back/forms/form")}";
12
+ import { collectionFieldValidator } from "${rel("src/back/forms/validator")}";
13
+ import html from "${rel("src/back/html")}";
14
+
15
+ export const actionName = "${action_name}";
16
+
17
+ export default new(class ${action_name}Form extends Form {
18
+ defaultSuccessMessage = "Pomyślnie utworzono użytkownika";
19
+
20
+ fields = [new FormField("email", true, collectionFieldValidator(Users.fields.email))];
21
+
22
+ controls = [
23
+ new FormHeader("Enter your email address"),
24
+ new SimpleInput("email", { label: "Your email", type: "email" }),
25
+ ];
26
+
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ async canAccess(_: BaseContext) {
29
+ return { canAccess: true, message: "" };
30
+ }
31
+
32
+ async onSubmit(ctx: BaseContext, values: Record<"email", string>) {
33
+ await ctx.$app.collections.users.create(ctx.$context, {
34
+ username: values.email,
35
+ ...values,
36
+ });
37
+ }
38
+
39
+ async render(ctx: BaseContext, data: FormData, path: string) {
40
+ return html(ctx, "${action_name}", await super.render(ctx, data, path));
41
+ }
42
+ })();
43
+ `;
44
+ };
45
+ exports.formTemplate = formTemplate;
46
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/templates/form.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEhD,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,eAAuB,EAAE,EAAE;IAC5E,MAAM,GAAG,GAAG,6BAAe,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO;qBACa,GAAG,CAAC,4BAA4B,CAAC;2CACX,GAAG,CAAC,yBAAyB,CAAC;6BAC5C,GAAG,CAAC,sBAAsB,CAAC;kCACtB,GAAG,CAAC,qBAAqB,CAAC;4CAChB,GAAG,CAAC,0BAA0B,CAAC;oBACvD,GAAG,CAAC,eAAe,CAAC;;6BAEX,WAAW;;2BAEb,WAAW;;;;;;;;;;;;;;;;;;;;;;;sBAuBhB,WAAW;;;CAGhC,CAAC;AACF,CAAC,CAAC;AAvCW,QAAA,YAAY,gBAuCvB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pageTemplate = void 0;
4
+ const import_path_1 = require("../utils/import-path");
5
+ const pageTemplate = (action_name, fullpath) => `import { BaseContext } from "koa";
6
+ import { tempstream } from "tempstream";
7
+ import { Page } from "${import_path_1.importPath(fullpath, "src/back/page/page")}";
8
+
9
+ export const actionName = "${action_name}";
10
+
11
+ export default new (class ${action_name}Page extends Page {
12
+
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+ async canAccess(_: BaseContext) {
15
+ return { canAccess: true, message: "" };
16
+ }
17
+
18
+ async render(ctx: BaseContext) {
19
+ return tempstream/* HTML */ \`<div></div>\`;
20
+ }
21
+ })();
22
+ `;
23
+ exports.pageTemplate = pageTemplate;
24
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/templates/page.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAE3C,MAAM,YAAY,GAAG,CAC3B,WAAmB,EACnB,QAAgB,EACf,EAAE,CAAC;;wBAEmB,wBAAU,CAAC,QAAQ,EAAE,oBAAoB,CAAC;;6BAErC,WAAW;;4BAEZ,WAAW;;;;;;;;;;;CAWtC,CAAC;AApBW,QAAA,YAAY,gBAoBvB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.testTemplate = void 0;
4
+ const import_path_1 = require("../utils/import-path");
5
+ function testTemplate(action_name, new_file_fullpath) {
6
+ const rel = import_path_1.curryImportPath(new_file_fullpath);
7
+ return `import { withProdApp } from "${rel("src/back/test_utils/with-prod-app")}";
8
+ import { LONG_TEST_TIMEOUT, webhintURL } from "${rel("src/back/test_utils/webhint")}";
9
+ import { ${action_name}URL } from "${rel("src/back/routes/routes")}";
10
+
11
+ describe("${action_name}", () => {
12
+ it("doesn't crash", async function () {
13
+ this.timeout(LONG_TEST_TIMEOUT);
14
+ return withProdApp(async ({ base_url, rest_api }) => {
15
+ await rest_api.get(${action_name}URL);
16
+ await webhintURL(base_url + ${action_name}URL);
17
+ // alternatively you can use webhintHTML for faster but less precise scans
18
+ // or for scanning responses of requests that use some form of authorization:
19
+ // const response = await rest_api.get(${action_name}URL);
20
+ // await webhintHTML(response);
21
+ });
22
+ });
23
+ });
24
+ `;
25
+ }
26
+ exports.testTemplate = testTemplate;
27
+ //# sourceMappingURL=route-test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-test.js","sourceRoot":"","sources":["../../src/templates/route-test.ts"],"names":[],"mappings":";;;AAAA,sDAAuD;AAEvD,SAAgB,YAAY,CAAC,WAAmB,EAAE,iBAAyB;IAC1E,MAAM,GAAG,GAAG,6BAAe,CAAC,iBAAiB,CAAC,CAAC;IAC/C,OAAO,gCAAgC,GAAG,CAAC,mCAAmC,CAAC;iDAC/B,GAAG,CAAC,6BAA6B,CAAC;WACxE,WAAW,eAAe,GAAG,CAAC,wBAAwB,CAAC;;YAEtD,WAAW;;;;wBAIC,WAAW;iCACF,WAAW;;;4CAGA,WAAW;;;;;CAKtD,CAAC;AACF,CAAC;AApBD,oCAoBC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unescape_url_params = exports.escape_url_params = void 0;
4
+ function escape_url_params(url) {
5
+ return url
6
+ .split("/")
7
+ .map((e) => (e.startsWith(":") ? `[${e.slice(1)}]` : e))
8
+ .join("/");
9
+ }
10
+ exports.escape_url_params = escape_url_params;
11
+ function unescape_url_params(url) {
12
+ return url
13
+ .split("/")
14
+ .map((e) => (e.startsWith("[") ? `:${e.slice(1, e.length - 1)}` : e))
15
+ .join("/");
16
+ }
17
+ exports.unescape_url_params = unescape_url_params;
18
+ //# sourceMappingURL=escape-url-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape-url-params.js","sourceRoot":"","sources":["../../src/utils/escape-url-params.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAC,GAAW;IAC5C,OAAO,GAAG;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACvD,IAAI,CAAC,GAAG,CAAC,CAAC;AACb,CAAC;AALD,8CAKC;AAED,SAAgB,mBAAmB,CAAC,GAAW;IAC9C,OAAO,GAAG;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACpE,IAAI,CAAC,GAAG,CAAC,CAAC;AACb,CAAC;AALD,kDAKC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.exec = void 0;
13
+ /* eslint-disable no-console */
14
+ const child_process_1 = require("child_process");
15
+ function exec(program, args) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ return new Promise((resolve, reject) => {
18
+ let stdout = "";
19
+ let stderr = "";
20
+ const process = child_process_1.spawn(program, args);
21
+ process.stdout.on("data", (data) => (stdout += data.toString()));
22
+ process.stderr.on("data", (data) => (stderr += data.toString()));
23
+ process.on("close", (exitCode) => {
24
+ if (exitCode === 0) {
25
+ resolve({ stdout, stderr, exitCode });
26
+ }
27
+ else {
28
+ console.error([program, ...args].join(" "));
29
+ console.error(stderr);
30
+ reject({ stdout, stderr, exitCode });
31
+ }
32
+ });
33
+ });
34
+ });
35
+ }
36
+ exports.exec = exec;
37
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,iDAAsC;AAEtC,SAAsB,IAAI,CACzB,OAAe,EACf,IAAc;;QAEd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,qBAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACrC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAChC,IAAI,QAAQ,KAAK,CAAC,EAAE;oBACnB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;iBACtC;qBAAM;oBACN,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC5C,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBACtB,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;iBACrC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CAAA;AApBD,oBAoBC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.curryImportPath = exports.importPath = void 0;
7
+ const path_1 = require("path");
8
+ const locreq_1 = __importDefault(require("locreq"));
9
+ const locreq = locreq_1.default(__dirname);
10
+ function importPath(project_module_path, project_target_path) {
11
+ let result = path_1.relative(path_1.dirname(locreq.resolve(project_module_path)), locreq.resolve(project_target_path).replace(/.ts$/, ""));
12
+ if (result[0] != ".") {
13
+ result = "./" + result;
14
+ }
15
+ return result;
16
+ }
17
+ exports.importPath = importPath;
18
+ function curryImportPath(project_module_path) {
19
+ return function (project_target_path) {
20
+ return importPath(project_module_path, project_target_path);
21
+ };
22
+ }
23
+ exports.curryImportPath = curryImportPath;
24
+ //# sourceMappingURL=import-path.js.map