Skip to content

Add --init flag to scaffold a QuickStart ScalaJS project#76

Merged
Quafadas merged 3 commits into
mainfrom
copilot/add-init-quickproj-flag
May 7, 2026
Merged

Add --init flag to scaffold a QuickStart ScalaJS project#76
Quafadas merged 3 commits into
mainfrom
copilot/add-init-quickproj-flag

Conversation

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor

Adds a --init <projectName> CLI flag that creates a ready-to-run Laminar/ScalaJS starter project in a subdirectory, then exits — no server started.

What gets scaffolded

Given sjsls --init quickproj, creates:

quickproj/
├── importMap.json       # CDN import map for the `ms` npm package via jsDelivr
├── project.scala        # Scala CLI directives + Laminar app with ms facade
└── assets/
    └── index.less       # Styled LESS stylesheet

Exits with:

Scaffolded app. To run it:
  cd quickproj
  sjsls --styles-dir assets

Changes

  • sjsls/src/scaffold.scala (new): template strings for all three files + scaffoldProject(projectName, baseDir) using fs2 to create dirs and write files. Accepts an optional baseDir: Option[Path] (defaults to the process working directory) to support testability.
  • sjsls/src/CliOpts.scala: adds initOpt: Opts[String] for --init <string>
  • sjsls/src/liveServer.scala: wires initOpt.map(scaffoldProject(_)) as a command alternative alongside the existing version flag
  • sjsls/test/src/ScaffoldSpec.scala (new): 4 CatsEffectSuite tests using a temp directory fixture to verify the directory layout is created correctly and that each scaffolded file contains the expected content

Copilot AI linked an issue May 7, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add --init quickproj flag to CLI for project scaffold Add --init flag to scaffold a QuickStart ScalaJS project May 7, 2026
Copilot AI requested a review from Quafadas May 7, 2026 09:54
@Quafadas Quafadas marked this pull request as ready for review May 7, 2026 09:57
@Quafadas

Quafadas commented May 7, 2026

Copy link
Copy Markdown
Owner

@copilot please add some tests

Copilot AI commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please add some tests

Added ScaffoldSpec in commit 2c06ca3 with 4 tests:

  • directory layout — verifies importMap.json, project.scala, and assets/index.less are all created and ExitCode.Success is returned
  • importMap.json content — checks for the @ms@2.1.3/+esm key and jsDelivr CDN URL
  • project.scala content — checks for JS platform directive, Laminar dep, ES module kind, import map reference, and the renderOnDomContentLoaded entry point
  • index.less content — checks for the @accent LESS variable and the #app selector

I also refactored scaffoldProject to accept an optional baseDir: Option[Path] (defaulting to the process working directory) so tests can pass a temp directory without touching the filesystem at an unpredictable location.

@Quafadas Quafadas merged commit f3c6b33 into main May 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project scaffold QuickStart

2 participants