Commit Graph
36 Commits
Author SHA1 Message Date
Marvin Hagemeister 5a228625ea chore: release 2.1.3 (#3572)
- @fresh/core@2.1.3
- @fresh/update@2.1.2
- @fresh/plugin-vite@1.0.6
- @fresh/init@2.2.1
2025-10-23 13:15:07 +02:00
Brett Chalupa 662f795ae8 feat: add @/ path alias to generated projects (#3562)
Sets up `@/` as the default path alias in newly generated Fresh
projects, following the official Deno documentation guidelines. This
allows developers to use `@/` for absolute imports from the project root
instead of relative paths. This is especially convenient to remove
import that require deeply traversing up the directory tree.

The `@/` alias is now included in the imports section of deno.json for
all new projects, enabling cleaner import statements like:

```
import { Button } from "@/components/Button.tsx";
```

Fixes #3485
2025-10-21 11:24:36 +02:00
Marvin Hagemeister 8b7caba444 chore: release 2.1.2 (#3542)
- @fresh/core@2.1.2
- @fresh/update@2.1.2
- @fresh/plugin-vite@1.0.5
2025-10-08 12:56:08 +02:00
fry69 88de90704e test(init): fix address in use (#3532)
Reverting back to the old init script also re-introduced the "address in
use" problem.

This does not have any effect: `env: { PORT: "0" }`

Adding arguments to `deno task start` also have no effect.

The only solution I can come up with is to ignore the task and call
`deno serve` with proper arguments directly for the build tests.
2025-10-07 10:34:10 +02:00
Marvin Hagemeister 41fba500de fix(init): revert init template to make init work again (#3530)
https://github.com/denoland/fresh/pull/3524 unfortunately introduced a
regression in the init script which breaks it. This was caused by two
independent problems:

1. Only files reachable in the module graph are published, meaning the
templates itself weren't published to JSR
2. When publishing to JSR all specifiers become `https://` internally
which breaks doing path operations like `path.resolve()`,
`path.relative()` and all others. This is something that cannot be
tested locally in advance

Addressing these is going to require a bit of work. The quickest way to
get init working again is to revert it.
2025-10-06 17:48:25 +02:00
fry69 198816b042 feat(init): template based init script (#3524)
Supersedes earlier attempt ->
https://github.com/denoland/fresh/pull/3517

This is now ready for review.

The major upside and motivation for this template based approach is that
it is now possible to view what gets generated in the repository as
actual valid files including syntax highlighting and formatting.

Previously those files where just strings inside the old `init` script,
which is IMHO a nightmare for maintainability.

The approach for this template system is loosely based on Vite's
`create-vite`, which also includes (redundant) templates inside the
repository, see here ->
https://github.com/vitejs/vite/tree/main/packages/create-vite

Included in the tests are compatibility checks against the current
`@fresh/init@2.0.9`, those can get removed at a later point when the
templates start to diverge. They are only included for demonstration
purposes, that this new implementation generates 100% identical output.

This means that the first PR after this got included, which modifies the
templates so the output differs from the old `init` script, also needs
to include:
```shell
rm packages/init/tests/compatibility_test.ts
```

Since this is a rather large PR, it may be more approachable to view the
branch directly ->
https://github.com/fry69/fresh/tree/fry69/refactor-init-template-rename/packages/init

Generated PR message below:

---

Replaces inline string-based project generation with file-based
templates for improved maintainability and extensibility.

### Architecture

**Template structure:**
- `assets/template/` - Complete project templates (vite, vite-tailwind,
builder, builder-tailwind)
- `assets/variants/` - Additive overlays (docker, vscode,
vscode-tailwind)
- `assets/base/` - Common files synced across template variants

Templates use `__VARIABLE__` syntax for substitution (project name,
dependency versions). Files with `__` prefix are renamed to `.` prefix
during generation (e.g., `__gitignore` → .gitignore).

**Template selection logic:**
```
Base: vite|vite-tailwind|builder|builder-tailwind
Variants: +docker, +vscode, +vscode-tailwind
```

### Maintenance workflow

Edit shared files in `assets/base/vite/` or `assets/base/builder/`, then
run `deno task sync` to propagate changes to template variants.
Template-specific files (deno.json, vite.config.ts, styles.css) are
never overwritten.

### Version resolution

Matches existing behavior: only Fresh core version is fetched from JSR,
all other dependencies use fixed versions updated by release scripts.

### Testing

55 tests covering:
- Unit tests for core functionality
- Integration tests (project generation, builds, dev servers)
- CLI argument parsing
- Compatibility tests verifying output matches v2.0.9 (pre-refactor
baseline)
- Template sync workflow

### Breaking changes

None. CLI interface and programmatic API remain identical. Package
publishes to same `@fresh/init` scope at JSR.

### Documentation

- README.md - User-facing usage documentation
- DESIGN.md - Maintainer documentation (architecture, template
maintenance, development setup)
2025-10-06 09:12:07 +02:00
Marvin Hagemeister 5c05d6533f chore: release 2.1.1 (#3466)
- @fresh/core@2.1.1
- @fresh/update@2.1.1
- @fresh/plugin-vite@1.0.4
2025-09-19 20:27:35 +02:00
Marvin Hagemeister de9b8a7c40 chore: release 2.1.0 (#3443)
- @fresh/core@2.1.0
- @fresh/plugin-vite@1.0.3
- @fresh/update@2.1.0
- @fresh/init@2.0.9
2025-09-15 19:29:04 +02:00
fry69andgoogle-labs-jules[bot] a12e20d992 fix(init): correct temporary directory creation in tests (#3425)
The tests for the `init` package were failing with a `PermissionDenied`
error in Jules container environment when creating temporary
directories. This was because the tests were attempting to create the
temporary directories in the root of the project, where permissions are
often restricted.

This change corrects the issue by removing the local `withTmpDir` helper
function in `packages/init/src/init_test.ts` and instead using the one
from `../../fresh/src/test_utils.ts`. The shared helper function
correctly creates temporary directories in the operating system's
default temporary directory, which resolves the permission issue.

Sample error message from Jules before this fix:

```
 ERRORS 

init - new project => ./packages/init/src/init_test.ts:99:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
                         ^
    at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
    at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
    at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
    at file:///app/packages/init/src/init_test.ts:100:27

init - create project dir => ./packages/init/src/init_test.ts:107:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async file:///app/packages/init/src/init_test.ts:108:21

init - with tailwind => ./packages/init/src/init_test.ts:122:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
                         ^
    at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
    at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
    at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
    at file:///app/packages/init/src/init_test.ts:123:27

init - with vscode => ./packages/init/src/init_test.ts:140:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async file:///app/packages/init/src/init_test.ts:141:21

init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async fn (file:///app/packages/init/src/init_test.ts:159:23)

init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async file:///app/packages/init/src/init_test.ts:182:23

init - can start dev server => ./packages/init/src/init_test.ts:205:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async fn (file:///app/packages/init/src/init_test.ts:211:23)

init - can start built project => ./packages/init/src/init_test.ts:233:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
              ^
    at async withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:15)
    at async file:///app/packages/init/src/init_test.ts:234:21

init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
                         ^
    at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
    at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
    at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
    at file:///app/packages/init/src/init_test.ts:266:27

init - with vite => ./packages/init/src/init_test.ts:348:6
error: PermissionDenied: Permission denied (os error 13): tmpdir
  const dir = await Deno.makeTempDir(options);
                         ^
    at Object.makeTempDir (ext:deno_fs/30_fs.js:168:10)
    at withTmpDir (file:///app/packages/fresh/src/test_utils.ts:136:26)
    at withTmpDir (file:///app/packages/init/src/init_test.ts:41:10)
    at file:///app/packages/init/src/init_test.ts:349:27

 FAILURES 

init - new project => ./packages/init/src/init_test.ts:99:6
init - create project dir => ./packages/init/src/init_test.ts:107:6
init - with tailwind => ./packages/init/src/init_test.ts:122:6
init - with vscode => ./packages/init/src/init_test.ts:140:6
init - fmt, lint, and type check project => ./packages/init/src/init_test.ts:153:6
init with tailwind - fmt, lint, and type check project => ./packages/init/src/init_test.ts:179:6
init - can start dev server => ./packages/init/src/init_test.ts:205:6
init - can start built project => ./packages/init/src/init_test.ts:233:6
init - errors on missing build cache in prod => ./packages/init/src/init_test.ts:265:6
init - with vite => ./packages/init/src/init_test.ts:348:6

FAILED | 449 passed (14 steps) | 10 failed | 17 ignored (2m38s)
```

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-09-14 11:44:47 +02:00
Marvin Hagemeister 4cc0722465 chore: release 2.0.2 (#3418)
- @fresh/core@2.0.2
- @fresh/plugin-vite@1.0.2
- @fresh/update@2.0.2
- @fresh/init@2.0.8
2025-09-12 19:16:12 +02:00
Marvin Hagemeister 169f156f78 fix(init): incorrect target dir argument (#3415)
Fixes https://github.com/denoland/fresh/issues/3413
2025-09-12 15:37:06 +02:00
Marvin Hagemeister 0e6bddd06e chore: release 2.0.1 (#3404)
- @fresh/core@2.0.1
- @fresh/plugin-vite@1.0.1
- @fresh/update@2.0.1
- @fresh/init@2.0.7
2025-09-12 11:05:03 +02:00
Christian Svensson 6466c975d5 fix: show help text and refresh help formatting (#3399)
- Show help text when `-h` or `--help` is passed to `@fresh/init`
- Print current version for `@fresh/init` during `--help`
<img width="367" height="95" alt="image"
src="https://github.com/user-attachments/assets/e3318fae-ce8a-4cbb-bb0a-78f338f1b3a2"
/>
- Refresh `--help` text with colors similar to `deno -h`; + "Fresh
branding" style for the `@fresh/init` text
- Print `@fresh/core` version when `@fresh/init` runs
<img width="471" height="88" alt="image"
src="https://github.com/user-attachments/assets/1a0bd619-315d-4abb-889c-ec6eb3a9b45f"
/>

I think showing versions is helpful for verifying/debugging what Fresh
version will be installed during init before all files are generated.

## Comparisons

### `@fresh/init` + empty project name

#### Before

<img width="1104" height="615" alt="image"
src="https://github.com/user-attachments/assets/b1534bb5-eecc-4692-9977-df3903868416"
/>

#### After

<img width="1169" height="695" alt="image"
src="https://github.com/user-attachments/assets/6a743d79-bb59-463a-aadd-fbf734149258"
/>

### `@fresh/init --help`

#### Before

<img width="1007" height="150" alt="image"
src="https://github.com/user-attachments/assets/0ad42078-420c-4dc6-9561-4a338cc09741"
/>

#### After

<img width="1272" height="579" alt="image"
src="https://github.com/user-attachments/assets/3dfe6712-8604-4429-a418-5e6538117303"
/>
2025-09-12 10:04:54 +02:00
Marvin Hagemeister fb341e4ab7 chore: release 2.0.0 (#3371) 2025-09-09 18:52:36 +02:00
Marvin Hagemeister b06ef5a855 chore: release 2.0.0-beta.4 and @fresh/plugin-vite@0.9.12 (#3343) 2025-09-05 12:23:47 +02:00
Marvin Hagemeister fd2ebc63c5 fix(init): setup vite/client types on init (#3327)
Note that this also requires
https://github.com/denoland/deno/issues/30560 to work. That will be
released in either Deno `2.4.6` or `2.5.0` depending on which one comes
first.

Fixes https://github.com/denoland/fresh/issues/3319
2025-09-03 12:02:52 +02:00
Marvin Hagemeister 35f5cc4b7a fix(init): don't show counter value in document title (#3311)
It falsely gives the impression that the value in the document title
would be live.
2025-09-02 15:19:26 +02:00
Marvin Hagemeister cb4482dbe5 feat(init): init with vite by default and move builder to flag (#3309) 2025-09-02 14:14:28 +02:00
Marvin Hagemeister 6ddc0fbbcb fix(init): add hint in client.ts for HMR (#3307) 2025-09-02 09:55:33 +02:00
Marvin Hagemeister 6506edc97f fix(init): force latest vite plugin version (#3303)
Works around this bug in Deno
https://github.com/denoland/deno/issues/30588
2025-09-01 18:03:10 +02:00
Marvin Hagemeister 3dc01cfe6c chore: release 2.0.0-beta.3 (#3301) 2025-09-01 17:37:16 +02:00
Marvin Hagemeister ecdec5b4b2 chore: release 2.0.0-beta.2 (#3295) 2025-09-01 12:19:27 +02:00
Marvin Hagemeister 1e9ddcccc0 fix(init): document --vite arg (#3277) 2025-09-01 08:28:07 +02:00
Marvin Hagemeisterandfry69 33cb164b7d fix(init): document Vite and ask in init (#3281) (#3286)
Expands #3277

---------

Co-authored-by: fry69 <142489379+fry69@users.noreply.github.com>
2025-09-01 07:58:37 +02:00
Marvin Hagemeister 839d4a5841 fix(init): get latest version from JSR (#3279) 2025-08-29 21:24:37 +02:00
Marvin Hagemeister ce04409fad chore: release 2.0.0-beta.1 (#3275) 2025-08-29 18:03:06 +02:00
Marvin Hagemeister 62b62058fa feat(init): add --vite to bootstrap with vite (#3270) 2025-08-28 15:43:36 +02:00
Marvin Hagemeister a203448e01 chore: release 2.0.0-alpha.63 (#3261) 2025-08-26 10:16:41 +02:00
Marvin Hagemeister f1fe325c6d chore: release 2.0.0-alpha.62 (#3253) 2025-08-25 18:46:09 +02:00
Marvin Hagemeister 0555f9616c chore: release 2.0.0-alpha.61 (#3239) 2025-08-25 16:05:17 +02:00
Marvin Hagemeister 1daca75489 feat: bring back <Head> component (#3249)
This PR brings back the `<Head>` component from Fresh 1.x . The
implementation is much cleaner than back then and also works client-side
now too.
2025-08-25 15:40:47 +02:00
Marvin Hagemeister 6dd250c520 chore: release 2.0.0-alpha.60 (#3237) 2025-08-21 18:27:56 +02:00
Marvin Hagemeister 647d6f9adb chore: release 2.0.0-alpha.59 (#3231)
Fixes https://github.com/denoland/fresh/issues/3229
2025-08-20 09:48:41 +02:00
Marvin Hagemeister e05fd10977 chore: release 2.0.0-alpha.58 (#3217) 2025-08-12 12:55:38 +02:00
Marvin Hagemeister 073bacfbbb chore: release 2.0.0-alpha.57 (#3200) 2025-08-06 17:55:19 +02:00
Marvin Hagemeister 815b1940e3 chore: restructure repository into packages/ folder (#3197)
We're having a growing number of packages in this repository. This PR
moves them into a `packages/` directory like it's commonly done in other
projects.
2025-08-06 15:52:45 +02:00