@nanoforge-dev/schematics 1.1.0 → 1.2.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.
@@ -20,6 +20,11 @@
20
20
  "factory": "./libs/part-main/part-main.factory#main",
21
21
  "description": "Create a Main file for client or server.",
22
22
  "schema": "./libs/part-main/schema.json"
23
+ },
24
+ "docker": {
25
+ "factory": "./libs/docker/docker.factory#main",
26
+ "description": "Create a Dockerfile for the application.",
27
+ "schema": "./libs/docker/schema.json"
23
28
  }
24
29
  }
25
30
  }
@@ -0,0 +1,8 @@
1
+ # Ignore files for PNPM, NPM and YARN
2
+ pnpm-lock.yaml
3
+ package-lock.json
4
+ yarn.lock
5
+ bun.lock
6
+
7
+ /node_modules
8
+ /.nanoforge
@@ -0,0 +1,8 @@
1
+ # Ignore files for PNPM, NPM and YARN
2
+ pnpm-lock.yaml
3
+ package-lock.json
4
+ yarn.lock
5
+ bun.lock
6
+
7
+ /node_modules
8
+ /.nanoforge
@@ -0,0 +1,22 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+
3
+ interface DockerSchema {
4
+ /**
5
+ * NanoForge application name
6
+ */
7
+ name: string;
8
+
9
+ /**
10
+ * NanoForge application package manager
11
+ */
12
+ packageManager: "npm" | "yarn" | "pnpm" | "bun";
13
+
14
+ /**
15
+ * Target directory for generated Docker files
16
+ */
17
+ directory?: string;
18
+ }
19
+
20
+ declare const main: (schema: DockerSchema) => Rule;
21
+
22
+ export { main };
@@ -0,0 +1,61 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/libs/docker/docker.factory.ts
5
+ import { strings } from "@angular-devkit/core";
6
+ import {
7
+ apply,
8
+ mergeWith,
9
+ move,
10
+ template,
11
+ url
12
+ } from "@angular-devkit/schematics";
13
+
14
+ // src/utils/formatting.ts
15
+ var toKebabCase = /* @__PURE__ */ __name((str) => {
16
+ return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
17
+ }, "toKebabCase");
18
+
19
+ // src/utils/name.ts
20
+ import { basename, parse } from "path";
21
+ var resolvePackageName = /* @__PURE__ */ __name((path) => {
22
+ const { base: baseFilename, dir: dirname } = parse(path);
23
+ if (baseFilename === ".") {
24
+ return basename(process.cwd());
25
+ }
26
+ if (dirname.match(/^@[^\s]/)) {
27
+ return `${dirname}/${baseFilename}`;
28
+ }
29
+ return baseFilename;
30
+ }, "resolvePackageName");
31
+
32
+ // src/defaults.ts
33
+ var DEFAULT_APP_NAME = "nanoforge-app";
34
+ var DEFAULT_PACKAGE_MANAGER = "npm";
35
+
36
+ // src/libs/docker/docker.factory.ts
37
+ var transform = /* @__PURE__ */ __name((schema) => {
38
+ const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
39
+ return {
40
+ name,
41
+ packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,
42
+ directory: schema.directory
43
+ };
44
+ }, "transform");
45
+ var generate = /* @__PURE__ */ __name((options, path) => {
46
+ return apply(url("./files"), [
47
+ template({
48
+ ...strings,
49
+ ...options
50
+ }),
51
+ move(path)
52
+ ]);
53
+ }, "generate");
54
+ var main = /* @__PURE__ */ __name((schema) => {
55
+ const options = transform(schema);
56
+ return mergeWith(generate(options, schema.directory ?? options.name));
57
+ }, "main");
58
+ export {
59
+ main
60
+ };
61
+ //# sourceMappingURL=docker.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/libs/docker/docker.factory.ts","../../../src/utils/formatting.ts","../../../src/utils/name.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { toKebabCase } from \"@utils/formatting\";\nimport { resolvePackageName } from \"@utils/name\";\n\nimport { DEFAULT_APP_NAME, DEFAULT_PACKAGE_MANAGER } from \"~/defaults\";\n\nimport { type DockerOptions } from \"./docker.options\";\nimport { type DockerSchema } from \"./docker.schema\";\n\nconst transform = (schema: DockerSchema): DockerOptions => {\n const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));\n\n return {\n name,\n packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,\n directory: schema.directory,\n };\n};\n\nconst generate = (options: DockerOptions, path: string): Source => {\n return apply(url(\"./files\" as Path), [\n template({\n ...strings,\n ...options,\n }),\n move(path),\n ]);\n};\n\nexport const main = (schema: DockerSchema): Rule => {\n const options = transform(schema);\n return mergeWith(generate(options, schema.directory ?? options.name));\n};\n","export const toKebabCase = (str: string): string => {\n return str\n .replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, \"$1-$2\")\n .replace(/[\\s_]+/g, \"-\")\n .toLowerCase();\n};\n","import { basename, parse } from \"path\";\n\nexport const resolvePackageName = (path: string): string => {\n const { base: baseFilename, dir: dirname } = parse(path);\n if (baseFilename === \".\") {\n return basename(process.cwd());\n }\n if (dirname.match(/^@[^\\s]/)) {\n return `${dirname}/${baseFilename}`;\n }\n return baseFilename;\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_CONFIG = {\n client: {\n build: {\n entryFile: \"client/main.ts\",\n outDir: \".nanoforge/client\",\n },\n runtime: {\n dir: \".nanoforge/client\",\n },\n },\n};\nexport const DEFAULT_SERVER_CONFIG = {\n server: {\n enable: true,\n build: {\n entryFile: \"server/main.ts\",\n outDir: \".nanoforge/server\",\n },\n runtime: {\n dir: \".nanoforge/server\",\n },\n },\n};\n"],"mappings":";;;;AAAA,SAAoB,eAAe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pine
5
+ <% } %>
6
+
7
+ <% if (packageManager === 'pnpm') { %>
8
+ ENV PNPM_HOME="/pnpm"
9
+ ENV PATH="$PNPM_HOME:$PATH"
10
+ RUN npm install -g pnpm
11
+ <% } %>
12
+
13
+ <% if (packageManager === 'yarn') { %>
14
+ RUN npm install -g yarn
15
+ <% } %>
16
+
17
+ WORKDIR /app
18
+ COPY package.json ./
19
+ <% if (packageManager === 'npm') { %>
20
+ COPY package-lock.json ./
21
+ <% } else if (packageManager === 'yarn') { %>
22
+ COPY yarn.lock ./
23
+ <% } else if (packageManager === 'pnpm') { %>
24
+ COPY pnpm-lock.yaml ./
25
+ <% } else if (packageManager === 'bun') { %>
26
+ COPY bun.lock ./
27
+ <% } %>
28
+ <% if (packageManager === 'npm') { %>
29
+ RUN npm install --no-lockfile
30
+ <% } if (packageManager === 'pnpm') { %>
31
+ RUN pnpm install --frozen-lockfile --allow-build=bun
32
+ <% } else { %>
33
+ RUN <%= packageManager %> install --frozen-lockfile
34
+ <% } %>
35
+ COPY . .
36
+
37
+ RUN <%= packageManager %> run build
38
+
39
+ CMD ["<%= packageManager %>", "run", "start"]
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "SchematicsNanoForgeDocker",
4
+ "title": "NanoForge Base Docker Options Schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "name": {
8
+ "type": "string",
9
+ "description": "The name of the application",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What name would you like to use for the new project ?"
15
+ },
16
+ "packageManager": {
17
+ "type": "string",
18
+ "enum": ["npm", "yarn", "pnpm", "bun"],
19
+ "description": "NanoForge application package manager",
20
+ "default": "npm"
21
+ },
22
+ "directory": {
23
+ "type": "string",
24
+ "description": "NanoForge application destination directory"
25
+ }
26
+ },
27
+ "required": ["name"]
28
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@nanoforge-dev/schematics",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "description": "NanoForge Schematics",
6
6
  "keywords": [
7
7
  "nanoforge",
@@ -87,7 +87,7 @@
87
87
  "build": "tsc --noEmit && tsup",
88
88
  "postbuild": "pnpm run copy:collection && pnpm run copy:lib",
89
89
  "copy:collection": "cpx src/collection.json dist && cpx 'src/libs/**/schema.json' dist/libs",
90
- "copy:lib": "cpx 'src/libs/**/files/**/*' dist/libs",
90
+ "copy:lib": "cpx 'src/libs/**/files/**/{.,}*' dist/libs",
91
91
  "lint": "prettier --check . && eslint --format=pretty src",
92
92
  "format": "prettier --write . && eslint --fix --format=pretty src",
93
93
  "changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r . --include-path '.'",