Skip to content

Commit 280ad5f

Browse files
committed
chore(apps): make the packages publishable and keep them out of releases
The apps packages were npm workspaces of the repo root, whose only other job is the semantic-release run in release.yml and prerelease-alpha.yml. Its npm ci therefore installed every app dependency, cloudflared's 38 MB binary included. They get their own workspace root at apps/ instead, so the release install drops from ~490 to ~310 packages and local development is one npm install in apps/. Publishing fixes: - Both packages declared 0.0.1-alpha.1, already on npm with different contents (the newest published is alpha.7). They move to 0.0.1-alpha.8. - files: ["dist"] with no build hook shipped an empty package from a clean checkout; both gain prepack. - Neither declared a license or a repository. - create-tolgee-app pinned an SDK release that does not export selfRegisterApp or applyTolgeeTheme, so the scaffold only failed later, as TypeScript errors. resolveSdk now refuses the registry path outright and names what to do; PUBLISHED_SDK_RELEASED is the flag to flip once the SDK is published. - create-tolgee-app's .gitignore did not cover node_modules. Dependency fixes: - cloudflared is a local-dev convenience whose postinstall downloads an unpinned, unverified binary; it moves to devDependencies and the tunnel script now degrades to a message when it is absent instead of crashing. - @tginternal/client was a direct dependency of the template and keys-showcase but imported by neither. - express 4 -> 5, @clack/prompts 0.11 -> 1, and @types/node aligned with the Node versions the packages actually claim. Finally, nothing in CI built, typechecked or tested any of this, which is how all of the above got in. test.yml gains an apps-check job that installs the workspace, builds the SDK, typechecks all three packages and runs their tests.
1 parent b1f8937 commit 280ad5f

18 files changed

Lines changed: 8330 additions & 10231 deletions

File tree

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,29 @@ jobs:
376376
run: npm test
377377
working-directory: ./webapp
378378

379+
apps-check:
380+
name: Apps workspace check 🧩
381+
runs-on: ubuntu-24.04
382+
steps:
383+
- uses: actions/checkout@v4
384+
385+
- name: Setup environment
386+
uses: ./.github/actions/setup-env
387+
with:
388+
java: "false"
389+
390+
# --ignore-scripts keeps cloudflared's postinstall from downloading its
391+
# ~38 MB binary; it is a dev-tunnel convenience nothing here runs.
392+
- name: Install apps dependencies
393+
run: npm ci --ignore-scripts
394+
working-directory: ./apps
395+
396+
# Builds the SDK first — the generator and the example apps typecheck
397+
# against its dist/, not its sources.
398+
- name: Build, typecheck and test the apps workspace
399+
run: npm run check
400+
working-directory: ./apps
401+
379402
schema-check:
380403
name: Schema Check 📋
381404
needs: [backend-build]
@@ -651,6 +674,7 @@ jobs:
651674
- frontend-code-check
652675
- frontend-test
653676
- frontend-test-without-ee
677+
- apps-check
654678
- schema-check
655679
- migration-check
656680
- data-cy-check
@@ -697,6 +721,10 @@ jobs:
697721
failed_jobs+=("frontend-test-without-ee")
698722
fi
699723
724+
if [[ "${{ needs.apps-check.result }}" != "success" ]]; then
725+
failed_jobs+=("apps-check")
726+
fi
727+
700728
if [[ "${{ needs.schema-check.result }}" != "success" ]]; then
701729
failed_jobs+=("schema-check")
702730
fi

apps/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

apps/create-tolgee-app/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
node_modules
12
dist
3+
*.tsbuildinfo

apps/create-tolgee-app/README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ to your Tolgee instance.
88
npx create-tolgee-app my-app
99
```
1010

11-
> **Status: alpha, not published.** Inside this repository the package is
12-
> resolved through npm workspaces, so `npm install` at the repo root links it
13-
> (and `@tolgee/apps-sdk`) locally. `npx create-tolgee-app` from a clean machine
14-
> does not work yet. Run from a checkout, it scaffolds anywhere on disk and
15-
> wires the generated app to the SDK sources — see *Which SDK the generated app
16-
> gets*.
11+
> **Status: alpha, needs a checkout.** Inside this repository the package is
12+
> resolved through npm workspaces, so `npm install` in `apps/` links it (and
13+
> `@tolgee/apps-sdk`) locally. `npx create-tolgee-app` from a clean machine
14+
> **exits with an error**: no `@tolgee/apps-sdk` on npm carries the API the
15+
> template imports, so the scaffold could only produce a project that does not
16+
> compile. Run from a checkout, it scaffolds anywhere on disk and wires the
17+
> generated app to the SDK sources — see *Which SDK the generated app gets*.
1718
1819
## What it generates
1920

@@ -89,14 +90,21 @@ summary and again in the next steps.
8990

9091
| Mode | What the dependency becomes |
9192
| --- | --- |
92-
| `auto` (default) | `*` when the app is generated into this repo's npm workspaces (they link the SDK already), otherwise `file:<abs path>/apps/tolgee-apps-sdk`, and an exact published version when the CLI has no SDK sources next to it |
93+
| `auto` (default) | `*` when the app is generated into the `apps/` npm workspaces (they link the SDK already), otherwise `file:<abs path>/apps/tolgee-apps-sdk` |
9394
| `local` | as `auto`, but fails instead of falling back to the registry |
9495
| `published` | an exact published version, never a range |
9596

97+
**`published` currently refuses to run.** Every `@tolgee/apps-sdk` release on npm
98+
predates `selfRegisterApp` and `applyTolgeeTheme`, which the template imports, so
99+
the generator exits with that sentence rather than handing you a project full of
100+
missing-export errors. `PUBLISHED_SDK_RELEASED` in `src/registry.ts` is the flag
101+
to flip — together with `PUBLISHED_SDK_VERSION` — once the SDK is on npm. `auto`
102+
hits the same wall only when the CLI has no SDK sources next to it.
103+
96104
A `file:` dependency uses the SDK's build output, so the SDK has to be built:
97105

98106
```bash
99-
npm run build --workspace @tolgee/apps-sdk
107+
npm run build --workspace @tolgee/apps-sdk # from apps/
100108
```
101109

102110
The generator does not build it for you, but it does check and says so in the
@@ -111,6 +119,11 @@ Cloudflare quick tunnel, publishes the public URLs to `.tolgee-dev/tunnel.json`,
111119
and the server registers the app with *those* URLs. `TOLGEE_DEV_TUNNEL=none`, or
112120
a localhost `TOLGEE_URL`, keeps everything local.
113121

122+
`cloudflared` is a **dev dependency** of the generated app — it downloads a
123+
platform binary on install, which no deployment of the app needs. A production
124+
install (`npm ci --omit=dev`) simply has no tunnel; the script says so and lets
125+
Vite and the app server carry on.
126+
114127
## Non-interactive use
115128

116129
```bash
@@ -133,6 +146,9 @@ them there to run two apps side by side.
133146

134147
## Developing this package
135148

149+
It is part of the `apps/` npm workspace, so dependencies come from
150+
`npm install` there, not at the repo root.
151+
136152
```bash
137153
npm run dev # run the CLI from source (tsx)
138154
npm run typecheck
Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
22
"name": "create-tolgee-app",
3-
"version": "0.0.1-alpha.1",
3+
"version": "0.0.1-alpha.8",
44
"description": "Scaffold a Tolgee App — a Vite + React dashboard page with a manifest server — in one command.",
5+
"license": "Apache-2.0",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/tolgee/tolgee-platform.git",
9+
"directory": "apps/create-tolgee-app"
10+
},
11+
"homepage": "https://github.com/tolgee/tolgee-platform/tree/main/apps/create-tolgee-app#readme",
12+
"bugs": {
13+
"url": "https://github.com/tolgee/tolgee-platform/issues"
14+
},
515
"type": "module",
616
"bin": {
717
"create-tolgee-app": "./dist/index.js"
@@ -12,21 +22,25 @@
1222
],
1323
"scripts": {
1424
"build": "tsup",
25+
"prepack": "npm run build",
1526
"dev": "tsx src/index.ts",
1627
"typecheck": "tsc --noEmit -p tsconfig.json"
1728
},
1829
"dependencies": {
19-
"@clack/prompts": "^0.11.0",
30+
"@clack/prompts": "^1.7.0",
2031
"picocolors": "^1.1.1"
2132
},
2233
"devDependencies": {
2334
"@tolgee/apps-sdk": "*",
24-
"@types/node": "^24.12.3",
35+
"@types/node": "^20.19.9",
2536
"tsup": "^8.3.5",
2637
"tsx": "^4.19.2",
2738
"typescript": "~6.0.2"
2839
},
40+
"publishConfig": {
41+
"access": "public"
42+
},
2943
"engines": {
30-
"node": ">=20"
44+
"node": ">=20.12.0"
3145
}
3246
}

apps/create-tolgee-app/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,9 @@ const nextSteps = (answers: Answers): string[] => {
289289
return steps
290290
}
291291

292-
main().catch((err) => {
293-
console.error(err)
292+
main().catch((err: unknown) => {
293+
// These are the generator's own "you cannot get there from here" messages —
294+
// a stack trace would only bury them.
295+
log.error(err instanceof Error ? err.message : String(err))
294296
process.exit(1)
295297
})

apps/create-tolgee-app/src/registry.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,24 @@ export type SdkMode = 'auto' | 'local' | 'published'
5454
export const SDK_MODES: SdkMode[] = ['auto', 'local', 'published']
5555

5656
/**
57-
* Used only when the generator cannot see the SDK sources. It is an exact
58-
* version on purpose: the SDK's npm `latest` tag points at an early alpha that
59-
* predates most of the API, so any range (`*`, `^…`) resolves to a package the
60-
* generated app does not compile against.
57+
* Version the template is written against, used when the generator cannot see
58+
* the SDK sources. It is an exact version on purpose: the SDK's npm `latest` tag
59+
* points at an early alpha that predates most of the API, so any range (`*`,
60+
* `^…`) resolves to a package the generated app does not compile against.
6161
*/
62-
export const PUBLISHED_SDK_VERSION = '0.0.1-alpha.1'
62+
export const PUBLISHED_SDK_VERSION = '0.0.1-alpha.8'
63+
64+
/**
65+
* RELEASE MARKER — flip to `true` in the same commit that publishes
66+
* `PUBLISHED_SDK_VERSION` to npm, and keep the two in lockstep afterwards.
67+
*
68+
* While it is `false`, `resolveSdk` refuses to scaffold against the registry:
69+
* every version published so far predates `selfRegisterApp` and
70+
* `applyTolgeeTheme`, which the template imports, so the generated app would
71+
* fail to typecheck with a wall of missing-export errors instead of one
72+
* sentence naming the cause.
73+
*/
74+
export const PUBLISHED_SDK_RELEASED = false
6375

6476
export const DEFAULT_TOLGEE_URL = 'http://localhost:8718'
6577
export const DEFAULT_VITE_PORT = 5180

0 commit comments

Comments
 (0)