Skip to content

Commit

Permalink
Update template for better publish to npm.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklehamster committed Jan 27, 2024
1 parent f972442 commit cd097bd
Show file tree
Hide file tree
Showing 28 changed files with 4,189 additions and 72 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,6 @@ dist

# IntelliJ based IDEs
.idea

dist/
*.tsbuildinfo
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find ./src \( -name "*.vert" -o -name "*.frag" \) -type f -exec bash -c 'mkdir -p "src/generated/$(dirname "{}")" && cp "{}" "src/generated/$(dirname "{}")/$(basename $(basename "{}" .vert) .frag).txt"' \;

bun run bundle
bun run build
bun run tsc
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions bundler/bundler.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
12 changes: 12 additions & 0 deletions bundler/bundler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
async function bundle() {
await Bun.build({
entrypoints: ['./index.ts'],
outdir: './buid',
minify: true,
sourcemap: 'external',
target: 'browser',
});
}
await bundle();
export {};
// # sourceMappingURL=bundler.js.map
1 change: 1 addition & 0 deletions bundler/bundler.js.map

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

4 changes: 2 additions & 2 deletions bundler/bundler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
async function bundle() {
await Bun.build({
entrypoints: ['./src/index.tsx'],
outdir: './build',
entrypoints: ['./src/index.ts'],
outdir: './dist',
minify: true,
sourcemap: "external",
target: "browser",
Expand Down
10 changes: 10 additions & 0 deletions commit-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Add all changes to the staging area
git add .

# Commit with a default message
git commit -m "Auto-commit: $(date +"%Y-%m-%d %H:%M:%S")"

# Print a message indicating the successful commit
echo "Changes committed successfully."
1 change: 0 additions & 1 deletion example/build

This file was deleted.

Binary file modified example/bun.lockb
Binary file not shown.
15 changes: 3 additions & 12 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
<head>
<title>Bun Template</title>
</head>
<style>
#root {
width: 100%;
height: 100%;
}
</style>
<body>
<canvas id="root"> </canvas>
</body>
<script>
window.global = globalThis;
</script>
<script type="module">
import { hello } from './build/index.js';
import { hello } from './dist/index.js';

hello();
const h1 = document.body.appendChild(document.createElement("h1"));
h1.textContent = hello();
</script>
</html>
2 changes: 1 addition & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hello } from "../build/index";
import { hello } from "bun-template";
import Bao from "baojs";
import serveStatic from "serve-static-bun";

Expand Down
151 changes: 151 additions & 0 deletions example/package-lock.json

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

10 changes: 6 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "example",
"module": "index.ts",
"module": "src/index.ts",
"type": "module",
"scripts": {
"start": "bun run build-icon && bun run index.ts --watch",
"start": "bun run build && bun run index.ts --watch",
"build": "bun i && bun run build-icon && bun build --target=node ./src/index.ts --outfile=dist/index.js",
"build-icon": "png-to-ico ../icon.png > favicon.ico"
},
"devDependencies": {
Expand All @@ -15,6 +16,7 @@
"dependencies": {
"baojs": "^0.2.1",
"png-to-ico": "^2.1.8",
"serve-static-bun": "^0.5.3"
"serve-static-bun": "^0.5.3",
"bun-template": "file:.."
}
}
}
3 changes: 3 additions & 0 deletions example/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { hello } from "bun-template";

export { hello };
9 changes: 4 additions & 5 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"compilerOptions": {
"outDir": "dist",
"rootDirs": ["example"],
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
Expand All @@ -15,12 +17,9 @@
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
"types": [ "bun-types" ]
},
"include": [
"example/**/*.ts",
"build/*.js"
"**/*.ts",
]
}
1 change: 0 additions & 1 deletion index.ts

This file was deleted.

21 changes: 21 additions & 0 deletions make-repo-ssh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Get the current Git remote URL (origin)
CURRENT_URL=$(git config --get remote.origin.url)

# Verify if the URL is an HTTPS URL
if [[ $CURRENT_URL == https://* ]]; then
# Extract the repository name from the URL
REPO_NAME=$(basename "$CURRENT_URL" ".git")

# Update the Git remote URL to use SSH
NEW_URL="git@github.com:$(basename $(dirname "$CURRENT_URL"))/${REPO_NAME}.git"
git remote set-url origin "$NEW_URL"

# Verify the changes
git remote -v

echo "Git remote URL updated to SSH."
else
echo "The current Git remote URL is already using SSH."
fi
1 change: 1 addition & 0 deletions np.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bun run np
Loading

0 comments on commit cd097bd

Please sign in to comment.