-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved tests. Added walkDir to node
- Loading branch information
1 parent
95397e7
commit e1d0e90
Showing
6 changed files
with
119 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { init, Wasmer, walkDir } from "@wasmer/sdk/node"; | ||
|
||
const WASMER_TOKEN = process.env.WASMER_TOKEN; | ||
const APP_OWNER = process.env.APP_OWNER; | ||
const APP_NAME = process.env.APP_NAME || "my-echo-env-app"; | ||
if (!WASMER_TOKEN) { | ||
throw new Error( | ||
"Please set the `WASMER_TOKEN` environment variable.\nYou can create a token in https://wasmer.io/settings/access-tokens", | ||
); | ||
} | ||
if (!APP_OWNER) { | ||
throw new Error( | ||
"Please set the `APP_OWNER` to your username in Wasmer (or a namespace you own).", | ||
); | ||
} | ||
|
||
await init({ | ||
// registryUrl: process.env.WASMER_REGISTRY, | ||
token: WASMER_TOKEN, | ||
}); | ||
|
||
const php_file = `<?php | ||
echo "PHP app created from @wasmer/sdk!<br />"; | ||
var_dump($_ENV);`; | ||
|
||
const manifest = { | ||
command: [ | ||
{ | ||
module: "wasmer/static-web-server:webserver", | ||
name: "script", | ||
runner: "https://webc.org/runner/wasi", | ||
annotations: { | ||
wasi: { | ||
"main-args": ["--directory-listing=true"], | ||
}, | ||
}, | ||
}, | ||
], | ||
dependencies: { | ||
"wasmer/static-web-server": "^1", | ||
}, | ||
fs: { | ||
"/public": { | ||
"myfile.txt": "My file", | ||
"other": await walkDir("./static"), | ||
}, | ||
}, | ||
}; | ||
|
||
// console.log(JSON.stringify(manifest.fs, null, 2)); | ||
|
||
console.log("Creating Package..."); | ||
let wasmerPackage = await Wasmer.createPackage(manifest); | ||
|
||
let appConfig = { | ||
name: APP_NAME, | ||
owner: APP_OWNER, | ||
package: wasmerPackage, | ||
}; | ||
|
||
console.log("Deploying app..."); | ||
let res = await Wasmer.deployApp(appConfig); | ||
console.log(`Deployed successfully: ${res.url}`); |
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
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
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