Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from tommy351/web-playground
Playground
- Loading branch information
Showing
132 changed files
with
3,464 additions
and
855 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Parcel 1 Example | ||
|
||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://githubbox.com/tommy351/kosko/tree/master/examples/web-parcel-1) | ||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/tommy351/kosko/tree/master/examples/web-parcel-1) | ||
|
||
See [docs](https://kosko.dev/docs/using-in-browser) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Static Site Example | ||
|
||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://githubbox.com/tommy351/kosko/tree/master/examples/web-static) | ||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/tommy351/kosko/tree/master/examples/web-static) | ||
|
||
See [docs](https://kosko.dev/docs/using-in-browser) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Sync Environment Example | ||
|
||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/tommy351/kosko/tree/master/examples/web-sync-environment) | ||
|
||
See [docs](https://kosko.dev/docs/using-in-browser) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@kosko-example/web-sync-environment", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"start": "webpack serve", | ||
"build": "webpack" | ||
}, | ||
"dependencies": { | ||
"@kosko/env": "^2.0.0", | ||
"@kosko/generate": "^1.2.0", | ||
"kubernetes-models": "^1.5.2" | ||
}, | ||
"devDependencies": { | ||
"html-webpack-plugin": "^5.3.1", | ||
"webpack": "^5.31.0", | ||
"webpack-cli": "^4.6.0", | ||
"webpack-dev-server": "^3.11.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"template": "node", | ||
"view": "browser", | ||
"node": 14 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Deployment } from "kubernetes-models/apps/v1/Deployment"; | ||
import { Service } from "kubernetes-models/v1/Service"; | ||
import env from "../env"; | ||
|
||
const params = env.component("nginx"); | ||
const metadata = { name: "nginx" }; | ||
const labels = { app: "nginx" }; | ||
|
||
const deployment = new Deployment({ | ||
metadata, | ||
spec: { | ||
replicas: params.replicas, | ||
selector: { | ||
matchLabels: labels | ||
}, | ||
template: { | ||
metadata: { | ||
labels | ||
}, | ||
spec: { | ||
containers: [ | ||
{ | ||
image: `${params.imageRegistry}/nginx:${params.imageTag}`, | ||
name: "nginx", | ||
ports: [ | ||
{ | ||
containerPort: 80 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}); | ||
|
||
const service = new Service({ | ||
metadata, | ||
spec: { | ||
selector: labels, | ||
type: "ClusterIP", | ||
ports: [ | ||
{ | ||
port: 80, | ||
targetPort: 80 | ||
} | ||
] | ||
} | ||
}); | ||
|
||
export default [deployment, service]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createSyncEnvironment, createSyncLoaderReducers } from "@kosko/env"; | ||
|
||
const env = createSyncEnvironment(); | ||
const dev = require.context("./environments/dev"); | ||
|
||
env.setReducers((reducers) => [ | ||
...reducers, | ||
...createSyncLoaderReducers({ | ||
global: () => dev("./index").default, | ||
component: (name) => dev(`./${name}`).default | ||
}) | ||
]); | ||
|
||
export default env; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
imageRegistry: "gcr.io/image-dev" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
replicas: 1, | ||
imageTag: "latest" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-env browser */ | ||
import { resolve, print, PrintFormat } from "@kosko/generate"; | ||
|
||
(async () => { | ||
const manifests = await resolve( | ||
import("./components/nginx").then((mod) => mod.default) | ||
); | ||
|
||
console.log(manifests); | ||
|
||
const element = document.createElement("pre"); | ||
document.body.appendChild(element); | ||
|
||
print( | ||
{ manifests }, | ||
{ | ||
format: PrintFormat.YAML, | ||
writer: { | ||
write: (data) => { | ||
element.innerText += data; | ||
} | ||
} | ||
} | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable node/no-unpublished-require */ | ||
"use strict"; | ||
|
||
const HtmlWebpackPlugin = require("html-webpack-plugin"); | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
mode: "development", | ||
entry: { | ||
index: "./src/index.js" | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: "[name].js" | ||
}, | ||
plugins: [new HtmlWebpackPlugin()] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Webpack 5 Example | ||
|
||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://githubbox.com/tommy351/kosko/tree/master/examples/web-webpack-5) | ||
[![Edit on CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/tommy351/kosko/tree/master/examples/web-webpack-5) | ||
|
||
See [docs](https://kosko.dev/docs/using-in-browser) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.