Skip to content

Commit

Permalink
Merge pull request #48 from golemfactory/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
grisha87 authored Oct 20, 2023
2 parents bc76808 + 1959c86 commit 5e284d7
Show file tree
Hide file tree
Showing 50 changed files with 2,453 additions and 923 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ jobs:
npm run build
npm ln
golem-sdk --version
golem-sdk new test-app -t js-node -d 'Test App' -a 'Golem' -v '1.0.0'
cd test-app/node_modules
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ Golem SDK CLI is a companion tool for the [Golem SDK](https://github.com/golemfa

If you see a feature missing or a possible Golem SDK user experience improvement we could implement, please open an issue or a pull request.

### Create a new Golem Application

The fastest way to get started with Golem Network is to use `golem-sdk new` to create a new application from a template.

```shell
golem-sdk new
```

You will be asked a series of questions about your application and the CLI will use your answers to generate a new Golem Application.

The first question will be the project name. The CLI will use it to create a new directory for your application in the current directory. You can use the `--path` option to override this behaviour.

Note: The command will abort if the directory already exists.

You can provide all the needed information from command line too. Type `golem-sdk new --help` to see the list of available options.

### Golem Manifest

[Golem Manifest](https://docs.golem.network/docs/golem/payload-manifest) is a JSON document that describes your Golem application. While it is not necessary for simple applications, you will need it if you want to access advanced features of the Golem SDK, like access to the Internet (outbound).
Expand Down
25 changes: 25 additions & 0 deletions data/project-templates/js-node-esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "nodejs-golem-app",
"version": "1.0.0",
"description": "NodeJS script using Golem Network",
"main": "src/index.js",
"type": "module",
"scripts": {
"start": "node src/",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"keywords": [
"golem",
"network",
"application"
],
"dependencies": {
"@golem-sdk/golem-js": "^0.11.2",
"dotenv": "^16.3.1"
},
"devDependencies": {
"@golem-sdk/cli": "^1.0.0"
}
}
41 changes: 41 additions & 0 deletions data/project-templates/js-node-esm/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as dotenv from "dotenv";
import { LogLevel, ProposalFilters, TaskExecutor } from "@golem-sdk/golem-js";

dotenv.config();

(async function main() {
const executor = await TaskExecutor.create({
// What do you want to run
package: "golem/node:20-alpine",

// How much you wish to spend
budget: 0.5,
proposalFilter: ProposalFilters.limitPriceFilter({
start: 0.1,
cpuPerSec: 0.1 / 3600,
envPerSec: 0.1 / 3600,
}),

// Where you want to spend
payment: {
network: "polygon",
},

// Control the execution of tasks
maxTaskRetries: 0,

// Useful for debugging
logLevel: LogLevel.Info,
taskTimeout: 5 * 60 * 1000,
});

try {
// Your code goes here
const result = await executor.run((ctx) => ctx.run("node -v"));
console.log("Version of NodeJS on Provider:", result.stdout.trim());
} catch (err) {
console.error("Running the task on Golem failed due to", err);
} finally {
await executor.end();
}
})();
132 changes: 132 additions & 0 deletions data/project-templates/js-node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Source: https://github.com/github/gitignore/blob/main/Node.gitignore

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
5 changes: 2 additions & 3 deletions data/project-templates/js-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "1.0.0",
"description": "NodeJS script using Golem Network",
"main": "src/index.js",
"type": "module",
"scripts": {
"run": "node src/index.js",
"start": "node src/",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
Expand All @@ -20,6 +19,6 @@
"dotenv": "^16.3.1"
},
"devDependencies": {
"@golem-sdk/cli": "^1.0.0-beta.1"
"@golem-sdk/cli": "^1.0.0"
}
}
6 changes: 4 additions & 2 deletions data/project-templates/js-node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as dotenv from "dotenv";
import { LogLevel, ProposalFilters, TaskExecutor } from "@golem-sdk/golem-js";
const dotenv = require("dotenv");
const { LogLevel, ProposalFilters, TaskExecutor } = require("@golem-sdk/golem-js");

dotenv.config();

Expand Down Expand Up @@ -31,6 +31,8 @@ dotenv.config();

try {
// Your code goes here
const result = await executor.run((ctx) => ctx.run("node -v"));
console.log("Version of NodeJS on Provider:", result.stdout.trim());
} catch (err) {
console.error("Running the task on Golem failed due to", err);
} finally {
Expand Down
17 changes: 17 additions & 0 deletions data/project-templates/react-js/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: "18.2" } },
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
};
24 changes: 24 additions & 0 deletions data/project-templates/react-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
5 changes: 5 additions & 0 deletions data/project-templates/react-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Golem + React + Vite

This is a modified version of the [React + Vite](https://vite.new/react) template provided by Vite with the `@golem-sdk/react` package added and some basic instructions on how to connect to yagna.

It's important that you set the `VITE_YAGNA_APPKEY` environment variable to your yagna appkey before running the project. You can find your appkey by running `yagna app-key list` in your terminal.
12 changes: 12 additions & 0 deletions data/project-templates/react-js/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Golem + Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
27 changes: 27 additions & 0 deletions data/project-templates/react-js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "react-template",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@golem-sdk/react": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
"@vitejs/plugin-react": "^4.0.4",
"eslint": "^8.46.0",
"eslint-plugin-react": "^7.33.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"vite": "^4.4.8"
}
}
32 changes: 32 additions & 0 deletions data/project-templates/react-js/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

.installation-instructions {
max-width: 32em;
text-align: left;
}
Loading

0 comments on commit 5e284d7

Please sign in to comment.