@telamonjs/cli 1.0.1 → 1.0.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Monorepo template: leaving link mode (`telamonjs:unlink` and the pre-commit hook) restores the committed `@telamonjs/ui` range, or the latest published version, instead of the local checkout's version, which may not be on npm yet. The logic lives in one `scripts/telamonjs-mode.mjs` shared by the scripts and the hooks.
8
+
3
9
  ## 1.0.1
4
10
 
5
11
  First public release of `@telamonjs/cli`. Release notes: [CHANGELOG.md](https://github.com/telamonjs/telamonjs/blob/main/CHANGELOG.md).
@@ -5,6 +5,6 @@ export interface CreateOptions {
5
5
  skipGit?: boolean;
6
6
  monorepo?: boolean;
7
7
  }
8
- export declare const DEFAULT_UI_VERSION = "^1.0.1";
8
+ export declare const DEFAULT_UI_VERSION = "^1.0.3";
9
9
  export declare function createApp(projectName?: string, options?: CreateOptions): Promise<void>;
10
10
  //# sourceMappingURL=create.d.ts.map
@@ -25,7 +25,7 @@ const __dirname = fileURLToPath(new URL('.', import.meta.url));
25
25
  // @telamonjs/ui version pinned into generated apps' package.json
26
26
  // (fills the {{uiVersion}} placeholder in templates/app/package.json).
27
27
  // Bump this with telamonjs-ui minors too: the templates follow the latest API.
28
- export const DEFAULT_UI_VERSION = '^1.0.1';
28
+ export const DEFAULT_UI_VERSION = '^1.0.3';
29
29
  // This CLI's own version, pinned as devDependency of generated apps so
30
30
  // `pnpm lint:telamonjs` (`telamonjs lint`) works without a global install.
31
31
  const CLI_VERSION = JSON.parse(fs.readFileSync(path.join(__dirname, '../../package.json'), 'utf-8')).version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telamonjs/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "CLI for TelamonJS: create a Next.js admin app (single app or monorepo), generate CRUD modules from a Prisma schema, lint admin modules and manage database dumps",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,7 +41,7 @@
41
41
  "sonner": "^2.0.7",
42
42
  "vitest": "^3.2.4",
43
43
  "zod": "^3.25.76",
44
- "@telamonjs/ui": "1.0.1"
44
+ "@telamonjs/ui": "1.0.3"
45
45
  },
46
46
  "files": [
47
47
  "dist",
@@ -1,15 +1,5 @@
1
1
  #!/bin/sh
2
- # Relink telamonjs-ui if it was linked before the commit (pre-commit unlinked it).
3
- # The telamonjs checkout sits next to this project unless TELAMONJS_UI says otherwise.
4
- TELAMONJS_UI="${TELAMONJS_UI:-$(cd .. && pwd)/telamonjs/packages/ui}"
5
- if ! grep -q '"link:' apps/web/package.json 2>/dev/null; then
6
- if [ -L "apps/web/node_modules/@telamonjs/ui" ]; then
7
- node -e "
8
- const f='apps/web/package.json';
9
- const p=JSON.parse(require('fs').readFileSync(f,'utf-8'));
10
- p.dependencies['@telamonjs/ui']='link:$TELAMONJS_UI';
11
- require('fs').writeFileSync(f,JSON.stringify(p,null,2)+'\n');
12
- "
13
- echo "telamonjs-ui relinked"
14
- fi
2
+ # Relink @telamonjs/ui if it was linked before the commit (pre-commit unlinked it).
3
+ if ! grep -q '"link:' apps/web/package.json 2>/dev/null && [ -L "apps/web/node_modules/@telamonjs/ui" ]; then
4
+ node scripts/telamonjs-mode.mjs link
15
5
  fi
@@ -1,16 +1,7 @@
1
1
  #!/bin/sh
2
2
  # Commits never carry a link: to the local telamonjs checkout; post-commit relinks.
3
- # The telamonjs checkout sits next to this project unless TELAMONJS_UI says otherwise.
4
- TELAMONJS_UI="${TELAMONJS_UI:-$(cd .. && pwd)/telamonjs/packages/ui}"
5
3
  if grep -q '"link:' apps/web/package.json 2>/dev/null; then
6
- V=$(node -e "console.log(require('$TELAMONJS_UI/package.json').version)")
7
- node -e "
8
- const f='apps/web/package.json';
9
- const p=JSON.parse(require('fs').readFileSync(f,'utf-8'));
10
- p.dependencies['@telamonjs/ui']='^$V';
11
- require('fs').writeFileSync(f,JSON.stringify(p,null,2)+'\n');
12
- "
4
+ node scripts/telamonjs-mode.mjs unlink || exit 1
13
5
  pnpm install --lockfile-only --silent 2>/dev/null
14
6
  git add apps/web/package.json pnpm-lock.yaml
15
- echo "telamonjs-ui: link: -> ^$V for this commit"
16
7
  fi
@@ -21,8 +21,8 @@
21
21
  "db:migrate": "pnpm --filter {{scope}}/shared prisma:migrate",
22
22
  "db:studio": "pnpm --filter {{scope}}/shared prisma:studio",
23
23
  "db:seed": "pnpm --filter {{scope}}/shared prisma:seed",
24
- "telamonjs:link": "node -e \"const f='apps/web/package.json';const p=JSON.parse(require('fs').readFileSync(f,'utf-8'));p.dependencies['@telamonjs/ui']='link:'+require('path').resolve(process.env.TELAMONJS_UI||'../telamonjs/packages/ui');require('fs').writeFileSync(f,JSON.stringify(p,null,2)+'\\n')\" && pnpm install",
25
- "telamonjs:unlink": "node -e \"const f='apps/web/package.json';const p=JSON.parse(require('fs').readFileSync(f,'utf-8'));const v=require(require('path').resolve(process.env.TELAMONJS_UI||'../telamonjs/packages/ui')+'/package.json').version;p.dependencies['@telamonjs/ui']='^'+v;require('fs').writeFileSync(f,JSON.stringify(p,null,2)+'\\n')\" && pnpm install",
24
+ "telamonjs:link": "node scripts/telamonjs-mode.mjs link && pnpm install",
25
+ "telamonjs:unlink": "node scripts/telamonjs-mode.mjs unlink && pnpm install",
26
26
  "prepare": "husky"
27
27
  },
28
28
  "devDependencies": {
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+ // Switches apps/web between the published @telamonjs/ui and a local checkout
3
+ // (link mode). Used by the telamonjs:link/unlink scripts and the husky hooks.
4
+ //
5
+ // node scripts/telamonjs-mode.mjs link # point at the checkout
6
+ // node scripts/telamonjs-mode.mjs unlink # back to the published range
7
+ //
8
+ // The checkout sits next to this project unless TELAMONJS_UI says otherwise.
9
+ import { execSync } from 'node:child_process'
10
+ import { readFileSync, writeFileSync } from 'node:fs'
11
+ import { resolve } from 'node:path'
12
+
13
+ const FILE = 'apps/web/package.json'
14
+ const PKG = '@telamonjs/ui'
15
+ const UI = resolve(process.env.TELAMONJS_UI ?? '../telamonjs/packages/ui')
16
+ const isLinked = range => typeof range === 'string' && range.startsWith('link:')
17
+
18
+ // The range to go back to: the one already committed, else the latest published
19
+ // version. Never the checkout's own version, which may not be on npm yet.
20
+ function publishedRange() {
21
+ try {
22
+ const committed = JSON.parse(
23
+ execSync(`git show HEAD:${FILE}`, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] })
24
+ ).dependencies?.[PKG]
25
+ if (committed && !isLinked(committed)) return committed
26
+ } catch {
27
+ // no commit yet, or the file is new
28
+ }
29
+ return '^' + execSync(`npm view ${PKG} version`, { encoding: 'utf8' }).trim()
30
+ }
31
+
32
+ const pkg = JSON.parse(readFileSync(FILE, 'utf8'))
33
+ const current = pkg.dependencies[PKG]
34
+ const command = process.argv[2]
35
+
36
+ if (command === 'link') {
37
+ pkg.dependencies[PKG] = 'link:' + UI
38
+ } else if (command === 'unlink') {
39
+ if (!isLinked(current)) process.exit(0)
40
+ pkg.dependencies[PKG] = publishedRange()
41
+ } else {
42
+ console.error('usage: node scripts/telamonjs-mode.mjs link|unlink')
43
+ process.exit(1)
44
+ }
45
+
46
+ writeFileSync(FILE, JSON.stringify(pkg, null, 2) + '\n')
47
+ console.log(`${PKG}: ${current} -> ${pkg.dependencies[PKG]}`)