Skip to content

Commit

Permalink
docs(examples): my-calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
jjangga0214 committed Dec 5, 2023
1 parent 9140b1b commit c38d239
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 17 deletions.
1 change: 1 addition & 0 deletions .changeset/js-dependsOn.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
'@haetae/javascript': patch
---

\
- Support a glob pattern for `dependent` of `dependsOn()`.
- Support glob patterns for `dependents` of `dependOn()`.
9 changes: 8 additions & 1 deletion examples/cjs-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

An example of using Haetae in CJS Javascript project.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
# Check if it works
pnpm haetae helloworld
```
9 changes: 8 additions & 1 deletion examples/cjs-ts-1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ An example of using Haetae in CJS Typescript project.

[`$TS_NODE_COMPILER_OPTIONS`](https://typestrong.org/ts-node/docs/options/#compileroptions) is used.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
# Check if it works
pnpm haetae helloworld
```
9 changes: 8 additions & 1 deletion examples/cjs-ts-2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ An example of using Haetae in CJS Typescript project.

A dedicated Typescript config *`tsconfig.haetae.json`* is used.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
# Check if it works
pnpm haetae helloworld
```
9 changes: 8 additions & 1 deletion examples/esm-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

An example of using Haetae in ESM Javascript project.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
# Check if it works
pnpm haetae helloworld
```
9 changes: 8 additions & 1 deletion examples/esm-ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

An example of using Haetae in ESM Typescript project.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
# Check if it works
pnpm haetae helloworld
```
12 changes: 12 additions & 0 deletions examples/my-calculator/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# my-calculator-test

This is an example project guided by the official *Getting Started* docs.

To execute, build the package [`heatae`](../../packages/haetae) first.

```bash
pnpm --filter "haetae" build
```

Then check if it works.

```bash
pnpm haetae tests
```
4 changes: 3 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"lint": "eslint --ext .js,.cjs,.mjs,.jsx,.ts,.tsx,.md .",
"lint:md": "markdownlint .",
"build": "tsc --build tsconfig.build.json",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage -c ../../jest.config.js ./packages/cli/",
"prepublishOnly": "tsc --build tsconfig.build.json"
},
"peerDependencies": {
Expand Down Expand Up @@ -52,7 +53,8 @@
"@types/lodash.isobject": "^3.0.7",
"@types/semver": "^7.5.0",
"@types/signale": "^1.4.4",
"@types/yargs": "^17.0.24"
"@types/yargs": "^17.0.24",
"execa": "^8.0.1"
},
"keywords": [
"haetae",
Expand Down
53 changes: 53 additions & 0 deletions packages/cli/test/e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { $ as $$ } from 'execa'
import { dirname } from 'dirname-filename-esm'
import upath from 'upath'

const $ = $$({
stdio: 'pipe',
})

const examples = upath.resolve(dirname(import.meta), '../../../examples')

describe('test', () => {
// eslint-disable-next-line jest/no-hooks
beforeAll(async () => {
await $`pnpm --filter "haetae" build`
})

test('cjs-js', async () => {
const { stdout } = await $({
cwd: `${examples}/cjs-js`,
})`pnpm haetae helloworld`
expect(stdout).toContain('Command helloworld is successfully executed.')
})
test('cjs-ts-1', async () => {
const { stdout } = await $({
cwd: `${examples}/cjs-ts-1`,
})`pnpm haetae helloworld`
expect(stdout).toContain('Command helloworld is successfully executed.')
})
test('cjs-ts-2', async () => {
const { stdout } = await $({
cwd: `${examples}/cjs-ts-2`,
})`pnpm haetae helloworld`
expect(stdout).toContain('Command helloworld is successfully executed.')
})
test('esm-js', async () => {
const { stdout } = await $({
cwd: `${examples}/esm-js`,
})`pnpm haetae helloworld`
expect(stdout).toContain('Command helloworld is successfully executed.')
})
test('esm-ts', async () => {
const { stdout } = await $({
cwd: `${examples}/esm-ts`,
})`pnpm haetae helloworld`
expect(stdout).toContain('Command helloworld is successfully executed.')
})
test('my-calculator', async () => {
const { stdout } = await $({
cwd: `${examples}/my-calculator`,
})`pnpm haetae test`
expect(stdout).toContain('Command test is successfully executed.')
})
})
2 changes: 1 addition & 1 deletion packages/haetae/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# `haetae`

The main user-friendly package recommended to most of users of Haetae.
The main recommended user-friendly package for most of the users of Haetae.

Refer to the official documentation website.
13 changes: 3 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c38d239

Please sign in to comment.