create-forgeon 0.3.12 → 0.3.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-forgeon",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "Forgeon project generator CLI",
5
5
  "license": "MIT",
6
6
  "author": "Forgeon",
@@ -1,4 +1,4 @@
1
- import { describe, it } from 'node:test';
1
+ import { describe, it } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import os from 'node:os';
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { ensureModuleExists } from './registry.mjs';
4
4
  import { writeModuleDocs } from './docs.mjs';
@@ -1,4 +1,4 @@
1
- import { describe, it } from 'node:test';
1
+ import { describe, it } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import fs from 'node:fs';
4
4
  import os from 'node:os';
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { copyRecursive, writeJson } from '../utils/fs.mjs';
4
4
  import {
@@ -1,4 +1,4 @@
1
- const MODULE_PRESETS = {
1
+ const MODULE_PRESETS = {
2
2
  'db-prisma': {
3
3
  id: 'db-prisma',
4
4
  label: 'DB Prisma',
@@ -1,4 +1,4 @@
1
- import fs from 'node:fs';
1
+ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { copyRecursive, writeJson } from '../utils/fs.mjs';
4
4
  import {
@@ -16,7 +16,7 @@ import {
16
16
  printOptionalIntegrationsWarning,
17
17
  runIntegrationFlow,
18
18
  } from './integrations/flow.mjs';
19
- import { writeJson } from './utils/fs.mjs';
19
+ import { readJson, writeJson } from './utils/fs.mjs';
20
20
 
21
21
  function printModuleList() {
22
22
  const modules = listModulePresets();
@@ -63,7 +63,7 @@ function collectDependencyManifestState(targetRoot) {
63
63
  }
64
64
 
65
65
  const filePath = path.join(currentDir, entry.name);
66
- const packageJson = JSON.parse(fs.readFileSync(filePath, 'utf8'));
66
+ const packageJson = readJson(filePath);
67
67
  const snapshot = {
68
68
  name: packageJson.name ?? null,
69
69
  dependencies: toSortedObject(packageJson.dependencies),
@@ -114,7 +114,7 @@ function ensureSyncTooling({ packageRoot, targetRoot }) {
114
114
  return;
115
115
  }
116
116
 
117
- const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
117
+ const packageJson = readJson(packagePath);
118
118
  if (!packageJson.scripts) {
119
119
  packageJson.scripts = {};
120
120
  }
@@ -309,3 +309,4 @@ export async function runAddModule(argv = process.argv.slice(2)) {
309
309
  console.log('Next: run pnpm install');
310
310
  }
311
311
  }
312
+
package/src/utils/fs.mjs CHANGED
@@ -1,26 +1,31 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
-
4
- export function copyRecursive(source, destination) {
5
- const stat = fs.statSync(source);
6
-
7
- if (stat.isDirectory()) {
8
- fs.mkdirSync(destination, { recursive: true });
9
- for (const entry of fs.readdirSync(source)) {
10
- copyRecursive(path.join(source, entry), path.join(destination, entry));
11
- }
12
- return;
13
- }
14
-
15
- fs.copyFileSync(source, destination);
16
- }
17
-
18
- export function writeJson(filePath, data) {
19
- fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
20
- }
21
-
22
- export function removeIfExists(targetPath) {
23
- if (fs.existsSync(targetPath)) {
24
- fs.rmSync(targetPath, { recursive: true, force: true });
25
- }
26
- }
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+
4
+ export function copyRecursive(source, destination) {
5
+ const stat = fs.statSync(source);
6
+
7
+ if (stat.isDirectory()) {
8
+ fs.mkdirSync(destination, { recursive: true });
9
+ for (const entry of fs.readdirSync(source)) {
10
+ copyRecursive(path.join(source, entry), path.join(destination, entry));
11
+ }
12
+ return;
13
+ }
14
+
15
+ fs.copyFileSync(source, destination);
16
+ }
17
+
18
+ export function writeJson(filePath, data) {
19
+ fs.writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`, 'utf8');
20
+ }
21
+
22
+ export function readJson(filePath) {
23
+ const raw = fs.readFileSync(filePath, 'utf8').replace(/^\uFEFF/, '');
24
+ return JSON.parse(raw);
25
+ }
26
+
27
+ export function removeIfExists(targetPath) {
28
+ if (fs.existsSync(targetPath)) {
29
+ fs.rmSync(targetPath, { recursive: true, force: true });
30
+ }
31
+ }
@@ -1,4 +1,4 @@
1
- ## Scope
1
+ ## Scope
2
2
 
3
3
  Current implementation includes:
4
4
 
@@ -1,4 +1,4 @@
1
- {
1
+ {
2
2
  "name": "@forgeon/scheduler",
3
3
  "version": "0.1.0",
4
4
  "private": true,
@@ -1,4 +1,4 @@
1
- import { Module } from '@nestjs/common';
1
+ import { Module } from '@nestjs/common';
2
2
  import { ScheduleModule } from '@nestjs/schedule';
3
3
  import { ForgeonQueueModule } from '@forgeon/queue';
4
4
  import { SchedulerConfigModule } from './scheduler-config.module';
@@ -1,4 +1,4 @@
1
- export * from './forgeon-scheduler.module';
1
+ export * from './forgeon-scheduler.module';
2
2
  export * from './scheduler-config.loader';
3
3
  export * from './scheduler-config.module';
4
4
  export * from './scheduler-config.service';
@@ -1,4 +1,4 @@
1
- import { registerAs } from '@nestjs/config';
1
+ import { registerAs } from '@nestjs/config';
2
2
  import { parseSchedulerEnv } from './scheduler-env.schema';
3
3
 
4
4
  export const SCHEDULER_CONFIG_NAMESPACE = 'scheduler';
@@ -1,4 +1,4 @@
1
- import { Module } from '@nestjs/common';
1
+ import { Module } from '@nestjs/common';
2
2
  import { ConfigModule } from '@nestjs/config';
3
3
  import { schedulerConfig } from './scheduler-config.loader';
4
4
  import { SchedulerConfigService } from './scheduler-config.service';
@@ -1,4 +1,4 @@
1
- import { Injectable } from '@nestjs/common';
1
+ import { Injectable } from '@nestjs/common';
2
2
  import { ConfigService } from '@nestjs/config';
3
3
  import {
4
4
  SCHEDULER_CONFIG_NAMESPACE,
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod';
2
2
 
3
3
  export const schedulerEnvSchema = z
4
4
  .object({
@@ -1,4 +1,4 @@
1
- import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
1
+ import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2
2
  import { SchedulerRegistry } from '@nestjs/schedule';
3
3
  import { QueueService } from '@forgeon/queue';
4
4
  import { CronJob } from 'cron';