@sealcode/sealgen 0.15.10 → 0.15.11

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.
@@ -1,10 +1,10 @@
1
1
  import _locreq from "locreq";
2
- import { curryImportPath } from "../utils/import-path.js";
3
2
  import prompts from "prompts";
4
3
  import { listCollections } from "../utils/list-collections.js";
5
4
  import { extractCollectionClassname } from "../generate-collections.js";
6
5
  import extract_fields_from_collection from "../utils/extract-fields-from-collection.js";
7
6
  import { DefaultListFilters } from "../page/default-list-filters.js";
7
+ import { formatWithPrettier } from "../utils/prettier.js";
8
8
  const target_locreq = _locreq(process.cwd());
9
9
  const listTemplate = async (action_name, newfilefullpath) => {
10
10
  const response = await prompts({
@@ -25,25 +25,23 @@ const listTemplate = async (action_name, newfilefullpath) => {
25
25
  ),
26
26
  extract_fields_from_collection(collection_name)
27
27
  ]);
28
- const rel = curryImportPath(newfilefullpath);
29
- return `import { Context } from "koa";
30
- import { CollectionItem } from "sealious";
31
- import { FlatTemplatable, TempstreamJSX } from "tempstream";
32
- import { ${uppercase_collection} } from "${rel(
33
- "src/back/collections/collections.js"
34
- )}";
35
- import html from "${rel("src/back/html.js")}";
28
+ const result = `import type { Context } from "koa";
29
+ import type { CollectionItem } from "sealious";
30
+ import type { FlatTemplatable } from "tempstream";
31
+ import { TempstreamJSX } from "tempstream";
32
+ import { Photos } from "../collections/collections.js";
33
+ import html from "../html.js";
34
+ import type { ListFilterRender } from "@sealcode/sealgen";
36
35
  import {
37
36
  SealiousItemListPage,
38
37
  BaseListPageFields,
39
38
  DefaultListFilters,
40
- ListFilterRender,
41
- } from "@sealcode/sealgen";;
39
+ } from "@sealcode/sealgen";
42
40
  import qs from "qs";
43
- import { is, predicates } from "@sealcode/ts-predicates";
44
41
 
45
42
  export const actionName = "${action_name}";
46
43
 
44
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
47
45
  const filterFields = [
48
46
  ${collection_fields.map(
49
47
  (field) => ` { field: "${field.name}", render: ${DefaultListFilters[field.type] ? `DefaultListFilters["${field.type}"]` : `DefaultListFilters.fallback`} }`
@@ -119,6 +117,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
119
117
  async renderItem(_: Context, item: CollectionItem<typeof ${uppercase_collection}>) {
120
118
  return <tr>
121
119
  {displayFields.map(({ field, format }) => {
120
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
122
121
  const value = item.get(field as any);
123
122
  return <td>{format ? format(value) : value}</td>;
124
123
  })}
@@ -141,6 +140,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
141
140
 
142
141
  })(${uppercase_collection});
143
142
  `;
143
+ return formatWithPrettier(result);
144
144
  };
145
145
  export {
146
146
  listTemplate
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sealcode/sealgen",
3
- "version": "0.15.10",
3
+ "version": "0.15.11",
4
4
  "description": "Module to automate adding routes and collections to a sealious application",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -5,6 +5,7 @@ import { listCollections } from "../utils/list-collections.js";
5
5
  import { extractCollectionClassname } from "../generate-collections.js";
6
6
  import extract_fields_from_collection from "../utils/extract-fields-from-collection.js";
7
7
  import { DefaultListFilters } from "../page/default-list-filters.js";
8
+ import { formatWithPrettier } from "../utils/prettier.js";
8
9
  const target_locreq = _locreq(process.cwd());
9
10
 
10
11
  export const listTemplate = async (
@@ -31,25 +32,23 @@ export const listTemplate = async (
31
32
  ),
32
33
  extract_fields_from_collection(collection_name),
33
34
  ]);
34
- const rel = curryImportPath(newfilefullpath);
35
- return `import { Context } from "koa";
36
- import { CollectionItem } from "sealious";
37
- import { FlatTemplatable, TempstreamJSX } from "tempstream";
38
- import { ${uppercase_collection} } from "${rel(
39
- "src/back/collections/collections.js"
40
- )}";
41
- import html from "${rel("src/back/html.js")}";
35
+ const result = `import type { Context } from "koa";
36
+ import type { CollectionItem } from "sealious";
37
+ import type { FlatTemplatable } from "tempstream";
38
+ import { TempstreamJSX } from "tempstream";
39
+ import { Photos } from "../collections/collections.js";
40
+ import html from "../html.js";
41
+ import type { ListFilterRender } from "@sealcode/sealgen";
42
42
  import {
43
43
  SealiousItemListPage,
44
44
  BaseListPageFields,
45
45
  DefaultListFilters,
46
- ListFilterRender,
47
- } from "@sealcode/sealgen";;
46
+ } from "@sealcode/sealgen";
48
47
  import qs from "qs";
49
- import { is, predicates } from "@sealcode/ts-predicates";
50
48
 
51
49
  export const actionName = "${action_name}";
52
50
 
51
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
53
52
  const filterFields = [
54
53
  ${collection_fields
55
54
  .map(
@@ -134,6 +133,7 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
134
133
  async renderItem(_: Context, item: CollectionItem<typeof ${uppercase_collection}>) {
135
134
  return <tr>
136
135
  {displayFields.map(({ field, format }) => {
136
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-explicit-any
137
137
  const value = item.get(field as any);
138
138
  return <td>{format ? format(value) : value}</td>;
139
139
  })}
@@ -156,4 +156,5 @@ export default new (class ${action_name}Page extends SealiousItemListPage<
156
156
 
157
157
  })(${uppercase_collection});
158
158
  `;
159
+ return formatWithPrettier(result);
159
160
  };