Skip to content

Commit

Permalink
improve logging during project initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Sep 12, 2024
1 parent 65f26f3 commit d6bd6ce
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/tall-kiwis-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-effect-app": patch
---

improve logging during project initialization
43 changes: 29 additions & 14 deletions packages/create-effect-app/src/Cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Ansi from "@effect/printer-ansi/Ansi"
import * as AnsiDoc from "@effect/printer-ansi/AnsiDoc"
import * as Array from "effect/Array"
import * as Effect from "effect/Effect"
import { pipe } from "effect/Function"
import * as Match from "effect/Match"
import * as Option from "effect/Option"
import * as Yaml from "yaml"
Expand Down Expand Up @@ -152,8 +153,8 @@ function createExample(config: ExampleConfig) {
const fs = yield* FileSystem.FileSystem

yield* Effect.logInfo(AnsiDoc.hsep([
AnsiDoc.text("Creating a new Effect application in"),
AnsiDoc.text(config.projectName).pipe(AnsiDoc.annotate(Ansi.green))
AnsiDoc.text("Creating a new Effect application in: "),
AnsiDoc.text(config.projectName).pipe(AnsiDoc.annotate(Ansi.magenta))
]))

// Create the project path
Expand All @@ -169,7 +170,8 @@ function createExample(config: ExampleConfig) {

yield* Effect.logInfo(AnsiDoc.hsep([
AnsiDoc.text("Success!").pipe(AnsiDoc.annotate(Ansi.green)),
AnsiDoc.text(`Effect example application was initialized in ${config.projectName}`)
AnsiDoc.text("Effect example application was initialized in: "),
AnsiDoc.text(config.projectName).pipe(AnsiDoc.annotate(Ansi.cyan))
]))
})
}
Expand Down Expand Up @@ -299,21 +301,34 @@ function createTemplate(config: TemplateConfig) {
yield* Effect.logInfo(AnsiDoc.hsep([
AnsiDoc.text("Success!").pipe(AnsiDoc.annotate(Ansi.green)),
AnsiDoc.text(`Effect template project was initialized in:`),
AnsiDoc.hardLine,
AnsiDoc.indent(AnsiDoc.text(config.projectName).pipe(AnsiDoc.annotate(Ansi.magenta)), 2)
AnsiDoc.text(config.projectName).pipe(AnsiDoc.annotate(Ansi.cyan))
]))

yield* Effect.logInfo(AnsiDoc.hsep([
AnsiDoc.text("Take a look at the template's"),
AnsiDoc.text("README.md").pipe(AnsiDoc.annotate(Ansi.cyan)),
AnsiDoc.text("for more information")
]))

const filesToCheck = []
filesToCheck.push(path.join(config.projectName, "LICENSE"))
if (config.projectType.withChangesets) {
yield* Effect.logInfo(AnsiDoc.hsep([
AnsiDoc.text("Make sure to update the Changesets configuration file"),
AnsiDoc.text("with your target GitHub repository for changelog links:"),
AnsiDoc.hardLine,
AnsiDoc.text(path.join(config.projectName, ".changeset", "config.json")).pipe(
AnsiDoc.annotate(Ansi.magenta),
AnsiDoc.indent(2)
)
]))
filesToCheck.push(path.join(config.projectName, ".changeset", "config.json"))
}

yield* Effect.logInfo(AnsiDoc.cats([
AnsiDoc.hsep([
AnsiDoc.text("Make sure to replace any"),
AnsiDoc.text("<PLACEHOLDER>").pipe(AnsiDoc.annotate(Ansi.cyan)),
AnsiDoc.text("entries in the following files:")
]),
pipe(
filesToCheck,
Array.map((file) => AnsiDoc.catWithSpace(AnsiDoc.char("-"), AnsiDoc.text(file))),
AnsiDoc.vsep,
AnsiDoc.indent(2)
)
]))
})
}

Expand Down
2 changes: 1 addition & 1 deletion templates/basic/.changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": [
"@changesets/changelog-github",
{
"repo": "REPLACE_ME"
"repo": "<PLACEHOLDER>"
}
],
"commit": false,
Expand Down
21 changes: 21 additions & 0 deletions templates/basic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present <PLACEHOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
32 changes: 31 additions & 1 deletion templates/basic/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# Effect Basic Package Template
# Effect Package Template

This template provides a solid foundation for building scalable and maintainable TypeScript package with Effect.

## Running Code

This template leverages [tsx](https://tsx.is) to allow execution of TypeScript files via NodeJS as if they were written in plain JavaScript.

To execute a file with `tsx`:

```sh
pnpm tsx ./path/to/the/file.ts
```

## Operations

**Building**

To build the package:

```sh
pnpm build
```

**Testing**

To test the package:

```sh
pnpm test
```
2 changes: 1 addition & 1 deletion templates/cli/.changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": [
"@changesets/changelog-github",
{
"repo": "REPLACE_ME"
"repo": "<PLACEHOLDER>"
}
],
"commit": false,
Expand Down
21 changes: 21 additions & 0 deletions templates/cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present <PLACEHOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 32 additions & 1 deletion templates/cli/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# Effect CLI Application Template
# Effect CLI Application Template

This template provides a solid foundation for building scalable and maintainable command-line applications with Effect.

## Running Code

This template leverages [tsx](https://tsx.is) to allow execution of TypeScript files via NodeJS as if they were written in plain JavaScript.

To execute a file with `tsx`:

```sh
pnpm tsx ./path/to/the/file.ts
```

## Operations

**Building**

To build the package:

```sh
pnpm build
```

**Testing**

To test the package:

```sh
pnpm test
```

2 changes: 1 addition & 1 deletion templates/monorepo/.changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"changelog": [
"@changesets/changelog-github",
{
"repo": "REPLACE_ME"
"repo": "<PLACEHOLDER>"
}
],
"commit": false,
Expand Down
21 changes: 21 additions & 0 deletions templates/monorepo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-present <PLACEHOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 32 additions & 1 deletion templates/monorepo/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# Effect Monorepo Template
# Effect Monorepo Template

This template provides a solid foundation for building scalable and maintainable TypeScript applications with Effect.

## Running Code

This template leverages [tsx](https://tsx.is) to allow execution of TypeScript files via NodeJS as if they were written in plain JavaScript.

To execute a file with `tsx`:

```sh
pnpm tsx ./path/to/the/file.ts
```

## Operations

**Building**

To build all packages in the monorepo:

```sh
pnpm build
```

**Testing**

To test all packages in the monorepo:

```sh
pnpm test
```

0 comments on commit d6bd6ce

Please sign in to comment.