@emeryld/manager 0.6.1 → 0.6.3

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.
@@ -83,20 +83,19 @@ async function promptForClientKind(existing) {
83
83
  let selection;
84
84
  const scripts = CLIENT_KIND_OPTIONS.map((opt) => ({
85
85
  name: opt.label,
86
- emoji: '💻',
86
+ emoji: opt.id == 'vite-react' ? '💻' : opt.id == 'expo-react-native' ? '📱' : '🌐',
87
87
  description: opt.summary,
88
88
  handler: () => {
89
89
  selection = opt.id;
90
90
  },
91
91
  }));
92
- scripts.push({
93
- name: `Use default (${defaultKind})`,
94
- emoji: '✅',
95
- description: 'Keep the prior/default choice',
96
- handler: () => {
97
- selection = defaultKind;
98
- },
99
- });
92
+ // scripts.push({
93
+ // name: `Use default (${defaultKind})`,
94
+ // emoji: '✅',
95
+ // handler: () => {
96
+ // selection = defaultKind
97
+ // },
98
+ // })
100
99
  await runHelperCli({
101
100
  title: 'Select a client template',
102
101
  scripts,
@@ -2,6 +2,7 @@ import { readFileSync } from 'node:fs';
2
2
  import { access, mkdir, writeFile } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { promptYesNoAll } from '../prompts.js';
5
+ import { ModuleResolutionKind } from 'typescript';
5
6
  export const workspaceRoot = process.cwd();
6
7
  export function isWorkspaceRoot(dir) {
7
8
  return path.resolve(dir) === path.resolve(workspaceRoot);
@@ -347,6 +348,13 @@ export async function packageTsConfig(targetDir, options) {
347
348
  esModuleInterop: options?.esModuleInterop ?? true,
348
349
  allowSyntheticDefaultImports: options?.esModuleInterop ?? true,
349
350
  skipLibCheck: options?.skipLibCheck ?? true,
351
+ target: options?.target,
352
+ module: options?.module,
353
+ moduleResolution: options?.ModuleResolutionKind !== undefined
354
+ ? ModuleResolutionKind[options.ModuleResolutionKind]
355
+ : undefined,
356
+ delcaration: options?.declarationMap,
357
+ declarationMap: options?.declarationMap,
350
358
  });
351
359
  const config = stripUndefined({
352
360
  extends: extendsPath,
@@ -1,3 +1,4 @@
1
+ import { ModuleResolutionKind } from 'typescript';
1
2
  import { BASE_LINT_DEV_DEPENDENCIES, basePackageFiles, basePackageJson, baseScripts, buildReadme, isWorkspaceRoot, packageTsConfig, writeFileIfMissing, } from '../../shared.js';
2
3
  const EXPO_CLIENT_SCRIPTS = [
3
4
  'dev',
@@ -480,6 +481,9 @@ export async function scaffoldExpoReactNativeClient(ctx) {
480
481
  include: ['App.tsx', 'src/**/*.ts', 'src/**/*.tsx'],
481
482
  jsx: 'react-native',
482
483
  types: ['react', 'react-native'],
484
+ target: 'ES2022',
485
+ module: 'ESNext',
486
+ ModuleResolutionKind: ModuleResolutionKind.Bundler,
483
487
  rootDir: '.',
484
488
  });
485
489
  const files = {
@@ -1,3 +1,4 @@
1
+ import { ModuleResolutionKind } from 'typescript';
1
2
  import { BASE_LINT_DEV_DEPENDENCIES, basePackageFiles, basePackageJson, baseScripts, buildReadme, isWorkspaceRoot, packageTsConfig, writeFileIfMissing, } from '../../shared.js';
2
3
  const VITE_CLIENT_SCRIPTS = [
3
4
  'dev',
@@ -525,10 +526,15 @@ function indexHtml() {
525
526
  export async function scaffoldViteReactClient(ctx) {
526
527
  const includePrepare = isWorkspaceRoot(ctx.targetDir);
527
528
  const tsconfig = await packageTsConfig(ctx.targetDir, {
528
- include: ['src/**/*', 'vite.config.ts'],
529
+ include: ['src/**/*.ts', 'src/**/*.tsx'],
529
530
  lib: ['ES2022', 'DOM'],
530
531
  types: ['vite/client'],
531
532
  jsx: 'react-jsx',
533
+ target: 'ES2022',
534
+ module: 'ESNext',
535
+ ModuleResolutionKind: ModuleResolutionKind.Bundler,
536
+ esModuleInterop: true,
537
+ skipLibCheck: true,
532
538
  });
533
539
  const files = {
534
540
  'package.json': vitePackageJson(ctx.pkgName, ctx.contractName, includePrepare),
@@ -1,3 +1,4 @@
1
+ import { ModuleResolutionKind } from 'typescript';
1
2
  import { BASE_LINT_DEV_DEPENDENCIES, basePackageFiles, basePackageJson, buildReadme, baseScripts, packageTsConfig, isWorkspaceRoot, writeFileIfMissing, } from '../shared.js';
2
3
  const CONTRACT_SCRIPTS = [
3
4
  'dev',
@@ -16,19 +17,12 @@ const CONTRACT_SCRIPTS = [
16
17
  * in some module shapes (CJS export= or default export). To make scaffolds compile reliably,
17
18
  * we import as a namespace and then grab from either `default` or the namespace object.
18
19
  */
19
- export const CONTRACT_TS = `import * as rrroutesContract from '@emeryld/rrroutes-contract'
20
+ export const CONTRACT_TS = `import { defineSocketEvents, finalize, resource } from '@emeryld/rrroutes-contract'
20
21
  import { z } from 'zod'
21
22
 
22
- const api = (rrroutesContract as any).default ?? rrroutesContract
23
- const { defineSocketEvents, finalize, resource } = api as {
24
- defineSocketEvents: (...args: any[]) => any
25
- finalize: (...args: any[]) => any
26
- resource: (...args: any[]) => any
27
- }
28
-
29
23
  const routes = resource('/api')
30
24
  .sub(
31
- resource('health')
25
+ resource('/health')
32
26
  .get({
33
27
  outputSchema: z.object({
34
28
  status: z.literal('ok'),
@@ -121,6 +115,10 @@ async function contractFiles(pkgName, targetDir) {
121
115
  const tsconfig = await packageTsConfig(targetDir, {
122
116
  include: ['src/**/*.ts', 'src/**/*.tsx'],
123
117
  skipLibCheck: true,
118
+ "target": "ES2022",
119
+ "module": "ESNext",
120
+ "declarationMap": true,
121
+ ModuleResolutionKind: ModuleResolutionKind.Bundler,
124
122
  });
125
123
  return {
126
124
  'package.json': contractPackageJson(pkgName, { includePrepare }),
@@ -309,8 +309,8 @@ function rootPnpmWorkspace(patterns) {
309
309
  }
310
310
  function rootTsconfigBase(baseName, names) {
311
311
  const paths = {
312
- [names.contract]: [`packages/${baseName}-contract/src`],
313
- [`${names.contract}/*`]: [`packages/${baseName}-contract/src/*`],
312
+ [names.contract]: [`packages/${baseName}-contract/dist`],
313
+ [`${names.contract}/*`]: [`packages/${baseName}-contract/dist/*`],
314
314
  [names.server]: [`packages/${baseName}-server/src`],
315
315
  [`${names.server}/*`]: [`packages/${baseName}-server/src/*`],
316
316
  [names.client]: [`packages/${baseName}-client/src`],
@@ -1,11 +1,14 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
2
3
  import { createRequire } from 'node:module';
3
4
  import readline from 'node:readline/promises';
4
5
  import { stdin as input, stdout as output } from 'node:process';
5
6
  import { fileURLToPath } from 'node:url';
6
7
  import path from 'node:path';
7
8
  const __filename = fileURLToPath(import.meta.url);
8
- const rootDir = path.resolve(path.dirname(__filename), '..');
9
+ const managerRoot = path.resolve(path.dirname(__filename), '..');
10
+ // Workspace root is wherever the CLI is executed.
11
+ const rootDir = process.cwd();
9
12
  const managerRequire = createRequire(import.meta.url);
10
13
  let tsNodeLoaderPath;
11
14
  function getTsNodeLoaderPath() {
@@ -237,6 +240,15 @@ function runEntry(entry, forwardedArgs) {
237
240
  }
238
241
  const scriptPath = entry.absoluteScript;
239
242
  const tsConfigPath = path.join(rootDir, 'tsconfig.base.json');
243
+ const tsConfigFallback = path.join(rootDir, 'tsconfig.json');
244
+ const bundledTsconfig = path.join(managerRoot, 'tsconfig.base.json');
245
+ const projectPath = existsSync(tsConfigPath)
246
+ ? tsConfigPath
247
+ : existsSync(tsConfigFallback)
248
+ ? tsConfigFallback
249
+ : existsSync(bundledTsconfig)
250
+ ? bundledTsconfig
251
+ : undefined;
240
252
  const extension = path.extname(scriptPath).toLowerCase();
241
253
  const isTypeScript = extension === '.js' || extension === '.mts' || extension === '.cts';
242
254
  const command = process.execPath;
@@ -253,7 +265,10 @@ function runEntry(entry, forwardedArgs) {
253
265
  cwd: rootDir,
254
266
  stdio: 'inherit',
255
267
  env: isTypeScript
256
- ? { ...process.env, TS_NODE_PROJECT: tsConfigPath }
268
+ ? {
269
+ ...process.env,
270
+ ...(projectPath ? { TS_NODE_PROJECT: projectPath } : {}),
271
+ }
257
272
  : process.env,
258
273
  shell: process.platform === 'win32' && isTypeScript,
259
274
  });
package/dist/utils/run.js CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/utils/run.js
2
2
  import { spawn } from 'node:child_process';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
- const __filename = fileURLToPath(import.meta.url);
6
- export const rootDir = path.resolve(path.dirname(__filename), '..', '..');
3
+ // Always execute commands from the workspace where the CLI is invoked.
4
+ // This makes installs from node_modules behave correctly instead of
5
+ // running in the package's own directory.
6
+ export const rootDir = process.cwd();
7
7
  export function run(command, args, options = {}) {
8
8
  return new Promise((resolve, reject) => {
9
9
  const child = spawn(command, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/manager",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
5
5
  "license": "MIT",
6
6
  "type": "module",