Skip to content

Commit bbaccfc

Browse files
committed
feat: new templates
1 parent 02e6d63 commit bbaccfc

File tree

13 files changed

+121
-45
lines changed

13 files changed

+121
-45
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ jobs:
77
release:
88
name: release
99
runs-on: ubuntu-latest
10+
timeout-minutes: 3
1011
steps:
11-
- uses: actions/checkout@master
12-
- uses: actions/setup-node@v2
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-node@v3
1314
with:
1415
node-version: "16"
15-
cache: "yarn"
16-
- run: yarn install --frozen-lockfile
16+
- run: yarn install
1717
- run: yarn build
1818
- run: yarn release
1919
env:

.github/workflows/test.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check blog
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
- synchronize
7+
- reopened
8+
branches:
9+
- main
10+
jobs:
11+
build-cli:
12+
name: Package CLI
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 2
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: "16"
22+
- run: yarn install
23+
- run: yarn build

bin/faable

Lines changed: 0 additions & 3 deletions
This file was deleted.

bin/faable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
import "../dist/index.js";

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"main": "dist/index.js",
55
"license": "MIT",
66
"author": "Marc Pomar <marc@faable.com>",
7+
"type": "module",
78
"types": "./dist/index.d.ts",
89
"bugs": {
910
"url": "https://github.com/faablecloud/faable/issues"
@@ -32,12 +33,13 @@
3233
"@types/yargs": "^17.0.17",
3334
"rimraf": "^3.0.2",
3435
"rollup": "^3.7.5",
36+
"rollup-plugin-auto-external": "^2.0.0",
3537
"semantic-release": "^19.0.5",
36-
"ts-node": "^10.5.0",
38+
"ts-node": "^10.9.1",
3739
"typescript": "^4.5.5"
3840
},
3941
"scripts": {
40-
"cli": "ts-node src/index.ts",
42+
"cli": "ts-node --esm --experimental-specifier-resolution=node src/index.ts",
4143
"build": "rimraf pkg && rollup --config rollup.config.mjs",
4244
"release": "yarn build && semantic-release"
4345
},

rollup.config.mjs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ import commonjs from "@rollup/plugin-commonjs";
44
import { nodeResolve } from "@rollup/plugin-node-resolve";
55
import copy from "rollup-plugin-copy";
66
import generatePackageJson from "rollup-plugin-generate-package-json";
7+
import autoExternal from "rollup-plugin-auto-external";
78

89
export default {
910
input: "src/index.ts",
1011
output: {
11-
file: "pkg/dist/faable.js",
12-
format: "cjs",
12+
dir: "pkg/dist",
13+
format: "esm",
1314
exports: "named",
14-
preserveModules: false,
15+
preserveModules: true,
1516
preserveModulesRoot: "src",
1617
},
1718
plugins: [
19+
autoExternal(),
1820
json(),
1921
typescript(),
20-
commonjs(),
21-
nodeResolve(),
22+
// commonjs(),
23+
// nodeResolve(),
2224
copy({
2325
targets: [
2426
{ src: "README.md", dest: "pkg" },
2527
{ src: "bin/*", dest: "pkg/bin" },
28+
{ src: "templates/**/*", dest: "pkg/templates" },
2629
],
2730
}),
2831
generatePackageJson({
@@ -32,8 +35,9 @@ export default {
3235
main: pkg.main,
3336
dependencies: pkg.dependencies,
3437
bin: {
35-
faable: "bin/faable",
38+
faable: "bin/faable.js",
3639
},
40+
type: "module",
3741
license: "MIT",
3842
author: "Marc Pomar <marc@faable.com>",
3943
types: "./dist/index.d.ts",

src/commands/deploy/prepare.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import * as fs from "fs-extra";
1+
import fs from "fs-extra";
22
import Handlebars from "handlebars";
33
import * as path from "path";
44
import { log } from "../../log";
5+
import { fileURLToPath } from "url";
56

6-
const templates_dir = path.join(__dirname, "./templates");
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
const templates_dir = path.join(__dirname, "../../../templates");
711
const dockerfile = fs.readFileSync(`${templates_dir}/Dockerfile`).toString();
812

913
// Docker template file

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import yargs from "yargs";
22
import { hideBin } from "yargs/helpers";
3-
import { deploy } from "./commands/deploy";
3+
import { deploy } from "./commands/deploy/deploy";
44

55
yargs(hideBin(process.argv))
66
.scriptName("faable")

0 commit comments

Comments
 (0)