From b0d5e973383df8c4c229dab676091276ea00d5ac Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 21 Apr 2023 16:19:12 -0600 Subject: [PATCH 001/120] initial refactor, wip --- .gitignore | 3 +- icon.png => assets/icon.png | Bin instructions.md => assets/instructions.md | 0 docker_entrypoint.sh | 3 - manifest.yaml | 146 -------------------- package-lock.json | 97 +++++++++++++ package.json | 21 +++ scripts/deps.ts | 2 - scripts/embassy.ts | 5 - scripts/procedures/getConfig.ts | 5 - scripts/procedures/main.ts | 7 - scripts/procedures/migrations.ts | 4 - scripts/procedures/properties.ts | 3 - scripts/procedures/setConfig.ts | 5 - startos/manifest.ts | 119 ++++++++++++++++ startos/procedures/actions/index.ts | 4 + startos/procedures/actions/nameToConsole.ts | 28 ++++ startos/procedures/autoConfig.ts | 4 + startos/procedures/backups.ts | 6 + startos/procedures/config/index.ts | 6 + startos/procedures/config/inputSpec.ts | 19 +++ startos/procedures/config/inputSpecRaw.ts | 25 ++++ startos/procedures/config/read.ts | 13 ++ startos/procedures/config/save.ts | 11 ++ startos/procedures/index.ts | 7 + startos/procedures/main.ts | 110 +++++++++++++++ startos/procedures/migrations.ts | 4 + startos/procedures/properties.ts | 26 ++++ startos/wrapperData.ts | 5 + tsconfig.json | 12 ++ 30 files changed, 519 insertions(+), 181 deletions(-) rename icon.png => assets/icon.png (100%) rename instructions.md => assets/instructions.md (100%) delete mode 100755 docker_entrypoint.sh delete mode 100644 manifest.yaml create mode 100644 package-lock.json create mode 100644 package.json delete mode 100644 scripts/deps.ts delete mode 100644 scripts/embassy.ts delete mode 100644 scripts/procedures/getConfig.ts delete mode 100644 scripts/procedures/main.ts delete mode 100644 scripts/procedures/migrations.ts delete mode 100644 scripts/procedures/properties.ts delete mode 100644 scripts/procedures/setConfig.ts create mode 100644 startos/manifest.ts create mode 100644 startos/procedures/actions/index.ts create mode 100644 startos/procedures/actions/nameToConsole.ts create mode 100644 startos/procedures/autoConfig.ts create mode 100644 startos/procedures/backups.ts create mode 100644 startos/procedures/config/index.ts create mode 100644 startos/procedures/config/inputSpec.ts create mode 100644 startos/procedures/config/inputSpecRaw.ts create mode 100644 startos/procedures/config/read.ts create mode 100644 startos/procedures/config/save.ts create mode 100644 startos/procedures/index.ts create mode 100644 startos/procedures/main.ts create mode 100644 startos/procedures/migrations.ts create mode 100644 startos/procedures/properties.ts create mode 100644 startos/wrapperData.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index df89f86..5f7cf1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ hello-world.s9pk image.tar -scripts/*.js +procedures/*.js +node_modules/ .DS_Store .vscode/ docker-images \ No newline at end of file diff --git a/icon.png b/assets/icon.png similarity index 100% rename from icon.png rename to assets/icon.png diff --git a/instructions.md b/assets/instructions.md similarity index 100% rename from instructions.md rename to assets/instructions.md diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh deleted file mode 100755 index aab61f3..0000000 --- a/docker_entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec tini hello-world diff --git a/manifest.yaml b/manifest.yaml deleted file mode 100644 index afe4b68..0000000 --- a/manifest.yaml +++ /dev/null @@ -1,146 +0,0 @@ -# Example written in yaml (toml and json are also acceptable) - -# The package identifier used by the OS. This must be unique amongst all other known packages -id: hello-world - # A human readable service title -title: "Hello World" -# Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service. -version: 1.0.0.1 -# Release notes for the update - can be a string, paragraph or URL -release-notes: "Revamped for EmabssyOS 0.3.3" -# The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. -license: mit -# The Start9 wrapper repository URL for the package. This repo contains the manifest file (this), any scripts necessary for configuration, backups, actions, or health checks (more below). This key must exist. But could be embedded into the source repository. -wrapper-repo: "https://github.com/Start9Labs/hello-world-wrapper" -# The original project repository URL. There is no upstream repo in this example -upstream-repo: "https://github.com/Start9Labs/hello-world" -# URL to the support site / channel for the project. This key can be omitted if none exists, or it can link to the original project repository issues. -support-site: "https://docs.start9.com/" -# URL to the marketing site for the project. This key can be omitted if none exists, or it can link to the original project repository. -marketing-site: "https://start9.com/" -# The series of commands to build the project into an s9pk for arm64/v8. In this case we are using a Makefile with the simple build command "make". -build: ["make"] -# Human readable descriptors for the service. These are used throughout the EmbassyOS user interface, primarily in the marketplace. -description: - # This is the first description visible to the user in the marketplace. - short: Example service - # This description will display with additional details in the service's individual marketplace page - long: | - Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more. -# These assets are static files necessary for packaging the service for Start9 (into an s9pk). Each value is a path to the specified asset. If an asset is missing from this list, or otherwise denoted, it will be defaulted to the values denoted below. -assets: - # Default = LICENSE.md - license: LICENSE - # Default = icon.png (.svg allowed) - icon: icon.png - # Default = INSTRUCTIONS.md - instructions: instructions.md - # Default = image.tar - # docker-images: image.tar -# ----- This section commented out until we support long-running containers ----- -# The main action for initializing the service. This can be script to utilize the eOS scripting apis, or docker. -# main: -# type: script -# # Defines the containers needed to run the main and mounted volumes -# containers: -# main: -# # Identifier for the main image volume, which will be used when other actions need to mount to this volume. -# image: main -# # Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. -# mounts: -# # Specifies where on the service's file system its persistence directory should be mounted prior to service startup -# main: /root -# ----- END commented section ----- -main: - # Docker is currently the only action implementation - type: docker - # Identifier for the main image volume, which will be used when other actions need to mount to this volume. - image: main - # The executable binary for starting the initialization action. For docker actions, this is typically a "docker_entrypoint.sh" file. See the Dockerfile and the docker_entrypoint.sh in this project for additional details. - entrypoint: "docker_entrypoint.sh" - # Any arguments that should be passed into the entrypoint executable - args: [] - # Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. - mounts: - # Specifies where on the service's file system its persistence directory should be mounted prior to service startup - main: /root -# This is where health checks would be defined - see a more advanced example in https://github.com/Start9Labs/embassy-pages-wrapper -health-checks: {} -config: ~ -properties: ~ -# type: script -# This denotes any data, asset, or pointer volumes that should be connected when the "docker run" command is invoked -volumes: - # This is the image where files from the project asset directory will go - main: - type: data -# This specifies how to configure the port mapping for exposing the service over TOR and LAN (if applicable). Many interfaces can be specified depending on the needs of the service. If it can be launched over a Local Area Network connection, specify a `lan-config`. Otherwise, at minimum, a `tor-config` must be specified. -interfaces: - # This key is the internal name that the OS will use to configure the interface - main: - # A human readable name for display in the UI - name: User Interface - # A descriptive description of what the interface does - description: A simple user interface that is expected to display the text "Hello Word" - tor-config: - # Port mappings are from the external port to the internal container port - port-mapping: - 80: "80" - # Port mappings are from the external port to the internal container port - lan-config: - 443: - ssl: true - internal: 80 - # Denotes if the service has a user interface to display - ui: true - # Denotes the protocol specifications used by this interface - protocols: - - tcp - - http -dependencies: {} -# Specifies how backups should be run for this service. The default EmbassyOS provided option is to use the duplicity backup library on a system image (compat) -backup: - create: - # Currently, only docker actions are supported. - type: docker - # The docker image to use. In this case, a pre-loaded system image called compat - image: compat - # Required if the action uses a system image. The default value is false. - system: true - # The executable to run the command to begin the backup create process - entrypoint: compat - # Arguments to pass into the entrypoint executable. In this example, the full command run will be: `compat duplicity hello-world /mnt/backup /root/data` - args: - - duplicity - - create - - /mnt/backup - # For duplicity, the backup mount point needs to be something other than `/root`, so we default to `/root/data` - - /root/data - mounts: - # BACKUP is the default volume that is used for backups. This is whatever backup drive is mounted to the device, or a network filesystem. - # The value here donates where the mount point will be. The backup drive is mounted to this location. - BACKUP: "/mnt/backup" - main: "/root/data" - # The action to execute the backup restore functionality. Details for the keys below are the same as above. - restore: - type: docker - image: compat - system: true - entrypoint: compat - args: - - duplicity - - restore - - /mnt/backup - - /root/data - mounts: - BACKUP: "/mnt/backup" - main: "/root/data" -migrations: - from: - "*": - type: script - args: ["from"] - to: - "*": - type: script - args: ["to"] diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..9b05787 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,97 @@ +{ + "name": "hello-world-wrapper", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "start-sdk": "0.4.0-lib0.charlie33" + }, + "devDependencies": { + "@vercel/ncc": "^0.36.1", + "prettier": "^2.8.4", + "typescript": "^4.9.5" + } + }, + "node_modules/@iarna/toml": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", + "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" + }, + "node_modules/@vercel/ncc": { + "version": "0.36.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", + "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", + "dev": true, + "bin": { + "ncc": "dist/ncc/cli.js" + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/prettier": { + "version": "2.8.7", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", + "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/start-sdk": { + "version": "0.4.0-lib0.charlie33", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie33.tgz", + "integrity": "sha512-Lx3QAuRCZTA6zXdjsKN3LjCTY1NQgEHY9uOyxKSTnWtaVXdOSp1GqiZYs3c7/ZStPzzTZ19kSnCcVBE125lUHA==", + "dependencies": { + "@iarna/toml": "^2.2.5", + "deepmerge": "^4.3.1", + "lodash": "^4.17.21", + "ts-matches": "^5.4.1", + "yaml": "^2.2.1" + } + }, + "node_modules/ts-matches": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", + "integrity": "sha512-kXrY75F0s0WD15N2bWKDScKlKgwnusN6dTRzGs1N7LlxQRnazrsBISC1HL4sy2adsyk65Zbx3Ui3IGN8leAFOQ==" + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/yaml": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.1.tgz", + "integrity": "sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==", + "engines": { + "node": ">= 14" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b562f31 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "scripts": { + "build": "ncc build procedures/index.ts -o ./", + "prettier": "prettier --write procedures", + "check": "tsc --noEmit" + }, + "dependencies": { + "start-sdk": "0.4.0-lib0.charlie33" + }, + "devDependencies": { + "@vercel/ncc": "^0.36.1", + "prettier": "^2.8.4", + "typescript": "^4.9.5" + }, + "prettier": { + "trailingComma": "all", + "tabWidth": 2, + "semi": false, + "singleQuote": true + } +} diff --git a/scripts/deps.ts b/scripts/deps.ts deleted file mode 100644 index 6519c00..0000000 --- a/scripts/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.5/mod.ts"; -export * from "https://deno.land/x/embassyd_sdk@v0.3.3.0.5/util.ts"; \ No newline at end of file diff --git a/scripts/embassy.ts b/scripts/embassy.ts deleted file mode 100644 index 74f56eb..0000000 --- a/scripts/embassy.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { setConfig } from "./procedures/setConfig.ts"; -export { getConfig } from "./procedures/getConfig.ts"; -export { properties } from "./procedures/properties.ts"; -export { migration } from "./procedures/migrations.ts"; -export { main } from "./procedures/main.ts"; \ No newline at end of file diff --git a/scripts/procedures/getConfig.ts b/scripts/procedures/getConfig.ts deleted file mode 100644 index d90ab5d..0000000 --- a/scripts/procedures/getConfig.ts +++ /dev/null @@ -1,5 +0,0 @@ -// To utilize the default config system built, this file is required. It defines the *structure* of the configuration file. These structured options display as changeable UI elements within the "Config" section of the service details page in the Embassy UI. - -import { compat, types as T } from "../deps.ts"; - -export const getConfig: T.ExpectedExports.getConfig = compat.getConfig({}); diff --git a/scripts/procedures/main.ts b/scripts/procedures/main.ts deleted file mode 100644 index a426122..0000000 --- a/scripts/procedures/main.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { types as T, util } from "../deps.ts"; - -export const main = async (effects: T.Effects) => { - // args defaulted to [] - not necessary to include if empty - await effects.runDaemon({ command: "docker_entrypoint.sh", args: [] }).wait(); - return util.ok; -} \ No newline at end of file diff --git a/scripts/procedures/migrations.ts b/scripts/procedures/migrations.ts deleted file mode 100644 index 14691a8..0000000 --- a/scripts/procedures/migrations.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { compat, types as T } from "../deps.ts"; - -export const migration: T.ExpectedExports.migration = compat.migrations - .fromMapping({}, "1.0.0.1" ); diff --git a/scripts/procedures/properties.ts b/scripts/procedures/properties.ts deleted file mode 100644 index dff99aa..0000000 --- a/scripts/procedures/properties.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { compat, types as T } from "../deps.ts"; - -export const properties: T.ExpectedExports.properties = compat.properties; diff --git a/scripts/procedures/setConfig.ts b/scripts/procedures/setConfig.ts deleted file mode 100644 index 43d308f..0000000 --- a/scripts/procedures/setConfig.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This is where any configuration rules related to the configuration would go. These ensure that the user can only create a valid config. - -import { compat, } from "../deps.ts"; - -export const setConfig = compat.setConfig; diff --git a/startos/manifest.ts b/startos/manifest.ts new file mode 100644 index 0000000..45878d7 --- /dev/null +++ b/startos/manifest.ts @@ -0,0 +1,119 @@ +export interface Container { + image: string + mounts: Record + shmSizeMb?: number // if greater + sigtermTimeout?: string // if more than 30s to shutdown +} + +export interface GenericManifest { + id: string + title: string + version: string + releaseNotes: string + license: string // name of license + replaces: string[] + wrapperRepo: string + upstreamRepo: string + supportSite: string + marketingSite: string + donationUrl: string | null + description: { + short: string + long: string + } + assets: { + icon: string // file path + instructions: string // file path + license: string // file path + } + containers: Record + volumes: Record + alerts: { + install: string | null + uninstall: string | null + restore: string | null + start: string | null + stop: string | null + } + dependencies: Record +} + +export interface Dependency { + version: string + description: string | null + requirement: + | { + type: 'opt-in' + how: string + } + | { + type: 'opt-out' + how: string + } + | { + type: 'required' + } +} + +export const manifest: GenericManifest = { + // The package identifier used by the OS. This must be unique amongst all other known packages + id: 'hello-world', + // A human readable service title + title: 'Hello World', + // Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service + version: '4.0.0.0', + // Release notes for the update - can be a string, paragraph or URL + releaseNotes: "Revamped for StartOS 0.4.0", + // The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. + license: 'mit', + // A list of normie (hosted, SaaS, custodial, etc) services this services intends to replace + replaces: [], + // The Start9 wrapper repository URL for the package. This repo contains the manifest file (this), any scripts necessary for configuration, backups, actions, or health checks (more below). This key must exist. But could be embedded into the source repository + wrapperRepo: "https://github.com/Start9Labs/hello-world-wrapper", + // The original project repository URL. There is no upstream repo in this example + upstreamRepo: "https://github.com/Start9Labs/hello-world", + // URL to the support site / channel for the project. This key can be omitted if none exists, or it can link to the original project repository issues + supportSite: "https://docs.start9.com/", + // URL to the marketing site for the project. This key can be omitted if none exists, or it can link to the original project repository + marketingSite: "https://start9.com/", + // URL where users can donate to the upstream project + donationUrl: "https://donate.start9.com/", + // Human readable descriptors for the service. These are used throughout the EmbassyOS user interface, primarily in the marketplace. + description: { + // This is the first description visible to the user in the marketplace + short: 'Example service', + // This description will display with additional details in the service's individual marketplace page + long: 'Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more.' + }, + // These assets are static files necessary for packaging the service for Start9 (into an s9pk). Each value is a path to the specified asset. If an asset is missing from this list, or otherwise denoted, it will be defaulted to the values denoted below. + assets: { + license: 'LICENSE', + icon: 'assets/icon.png', + instructions: 'assets/instructions.md' + }, + // This denotes any data, asset, or pointer volumes that should be connected when the "docker run" command is invoked + volumes: { + // This is the image where files from the project asset directory will go + main: 'data' + }, + // Defines the containers needed to run the main and mounted volumes + containers: { + main: { + // Identifier for the main image volume, which will be used when other actions need to mount to this volume. + image: 'main', + // Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. + mounts: { + // Specifies where on the service's file system its persistence directory should be mounted prior to service startup + main: '/data' + } + } + }, + alerts: { + install: 'Optional alert to display before installing the service', + uninstall: 'Optional alert to display before uninstalling the service', + restore: 'Optional alert to display before restoring the service from backup', + start: 'Optional alert to display before starting the service', + stop: 'Optional alert to display before stopping the service', + }, + dependencies: {} +} diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts new file mode 100644 index 0000000..9201253 --- /dev/null +++ b/startos/procedures/actions/index.ts @@ -0,0 +1,4 @@ +import { ExpectedExports } from "start-sdk/lib/types"; +import { nameToConsole } from "./nameToConsole"; + +export const { actions, manifestActions }: ExpectedExports.action = setupActions(nameToConsole) diff --git a/startos/procedures/actions/nameToConsole.ts b/startos/procedures/actions/nameToConsole.ts new file mode 100644 index 0000000..3335714 --- /dev/null +++ b/startos/procedures/actions/nameToConsole.ts @@ -0,0 +1,28 @@ +import { Config, Value } from "start-sdk/lib/config/builder"; + +export const inputBuilder = Config.of({ + name: Value.text( + { + name: 'Name to Print', + required: false, + default: null, + patterns: [], + }, + ), +}); +const matchConfigSpec = inputBuilder.validator(); +type InputSpec = typeof matchConfigSpec._TYPE; + +export const nameToConsole = createAction( + { + name: 'Name to Console', + description: 'Prints the provided name to console or, if left blank, the saved name from config.', + id: 'nameToConsole', + input: inputBuilder.build(), + runningOnly: false, + }, + async ({ effects, utils, input }) => { + const { name } = await utils.getWrapperData('/config').first() + effects.runCommand(`echo "Hello ${input.name || name}"`) + } +) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts new file mode 100644 index 0000000..47cbda7 --- /dev/null +++ b/startos/procedures/autoConfig.ts @@ -0,0 +1,4 @@ +import { setupAutoConfig } from "start-sdk/lib/autoconfig"; +import { InputSpec } from "./config/inputSpec"; + +export const autoConfig = setupAutoConfig({}); \ No newline at end of file diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts new file mode 100644 index 0000000..e6acc20 --- /dev/null +++ b/startos/procedures/backups.ts @@ -0,0 +1,6 @@ +import { setupBackups } from "start-sdk/lib/backup"; + +/** + * Here we define what volumes to include in backups + */ +export const { createBackup, restoreBackup } = setupBackups("main") \ No newline at end of file diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts new file mode 100644 index 0000000..0f6cb84 --- /dev/null +++ b/startos/procedures/config/index.ts @@ -0,0 +1,6 @@ +import { inputSpec } from "./inputSpec"; +import { read } from "./read"; +import { save } from "./save"; +import { setupConfig } from "start-sdk/lib/config"; + +export const { getConfig, setConfig } = setupConfig(inputSpec, read, save); \ No newline at end of file diff --git a/startos/procedures/config/inputSpec.ts b/startos/procedures/config/inputSpec.ts new file mode 100644 index 0000000..722d39a --- /dev/null +++ b/startos/procedures/config/inputSpec.ts @@ -0,0 +1,19 @@ +import { configBuilder } from "start-sdk/lib"; +const { Config, Value } = configBuilder; + +/** + * This file is required. It can be composed manually or generated from inputSpecRaw.ts, depending on your syntactic preference for writing input specs +*/ +export const inputSpec = Config.of({ + name: Value.text( + { + name: "Name", + description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', + required: false, + }, + ), +}); + +export const matchConfigSpec = inputSpec.validator(); +export type InputSpec = typeof matchConfigSpec._TYPE; + diff --git a/startos/procedures/config/inputSpecRaw.ts b/startos/procedures/config/inputSpecRaw.ts new file mode 100644 index 0000000..74a4b24 --- /dev/null +++ b/startos/procedures/config/inputSpecRaw.ts @@ -0,0 +1,25 @@ +import { InputSpec } from "start-sdk/lib/config/configTypes"; + +/** + * This file is optional. Use it to define the input spec in a single structure + * + * Once complete, run "npm run gen-input-spec" to generate inputSpec.ts from this file + * + * Hint: use "ctrl + space" inside any given key to see the set of possible attributes for that key's type +*/ +export const spec: InputSpec = { + name: { + type: "text", + name: "Name", + description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', + required: false, + default: "World", + placeholder: "Enter your name", + warning: null, + minLength: null, + maxLength: null, + inputmode: "email", + masked: false, + patterns: [], + }, +}; diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts new file mode 100644 index 0000000..592bdbd --- /dev/null +++ b/startos/procedures/config/read.ts @@ -0,0 +1,13 @@ +import { InputSpec } from "./inputSpec"; +import { WrapperData } from "../../wrapperData"; +import { Read } from "start-sdk/lib/config/setupConfigExports"; + +/** + * This function executes on config fetch + * + * Use this function to gather data from various files and assemble into a valid config +*/ + +export const read: Read = async ({ utils }) => { + return utils.getWrapperData({ path: '/config' }); +} diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts new file mode 100644 index 0000000..4e04289 --- /dev/null +++ b/startos/procedures/config/save.ts @@ -0,0 +1,11 @@ +import { InputSpec } from "./inputSpec"; +import { WrapperData } from "../../wrapperData"; + +/** + * Use this function to persist config data to various files and to establish current dependencies +*/ + +export const save: Save = async ({ effects, utils, input }) => { + await utils.setWrapperData('/config', input); + return effects.setDependencies([]); +} diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts new file mode 100644 index 0000000..e55d745 --- /dev/null +++ b/startos/procedures/index.ts @@ -0,0 +1,7 @@ +export { getConfig, setConfig } from "./config"; +export { createBackup, restoreBackup } from "./backups"; +export { properties } from "./properties" +export { main } from './main'; +export { init, uninit } from "./migrations"; +export { actions } from "./actions"; +export { autoConfig } from "./autoConfig"; diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts new file mode 100644 index 0000000..79e3028 --- /dev/null +++ b/startos/procedures/main.ts @@ -0,0 +1,110 @@ +import { HealthReceipt } from "start-sdk/lib/health"; +import { checkPortListening } from "start-sdk/lib/health/checkFns"; +import { Daemons, NetworkBuilder, NetworkInterfaceBuilder } from "start-sdk/lib/mainFn"; +import exportInterfaces from "start-sdk/lib/mainFn/exportInterfaces"; +import { ExpectedExports } from "start-sdk/lib/types"; + +export const main: ExpectedExports.main = setupMain(async ({ effects, utils, started }) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + await effects.runCommand("echo starting Hello World!"); + + /** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + * + * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location + */ + + // ------------ Network Builder ------------ + + // Create a Network Builder to be used for finding or creating Tor hostnames and LAN ports + const networkBuilder = NetworkBuilder.of(effects); + + // ------------ Tor ------------ + + // Find or generate a random Tor hostname by ID + const torHostname1 = networkBuilder.getTorHostName("torHostname1"); + + // Create a Tor host with the assigned port mapping + const torHost1 = await torHostname1.bindTor(8080, 80); + // Assign the Tor host a web protocol (e.g. "http", "ws") + const torOrigin1 = torHost1.createOrigin("http"); + + // Create another Tor host with the assigned port mapping + const torHost2 = await torHostname1.bindTor(8080, 443); + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOrigin2 = torHost2.createOrigin("https"); + + // ------------ LAN ------------ + + // Find or generate a random port by ID + const lanPort1 = networkBuilder.getPort("lanPort1"); + // Create a LAN host with the assigned internal port + const lanHost1 = await lanPort1.bindLan(8080); + // Assign the LAN host a web protocol (e.g. "https", "wss") + const lanOrigins1 = lanHost1.createOrigins("https"); + + // ------------ Interface ---------------- + + // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). + // Addresses are different "routes" to the same destination + + // Define the Interface for user display and consumption + const interface1 = new NetworkInterfaceBuilder({ + effects, + name: "Web UI", + id: "webui", + description: "The web interface of Hello World", + ui: false, + basic: null, + path: "", + search: {}, + }); + + // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) + const addressReceipt1 = await interface1.exportAddresses([ + torOrigin1, + torOrigin2, + lanOrigins1.ip, + lanOrigins1.local + ]); + + // Export all address receipts for all interfaces to obtain interface receipt + const interfaceReceipt = exportInterfaces(addressReceipt1); + + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define additional health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] + + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return Daemons.of({ + effects, + started, + interfaceReceipt, // Provide the interfaceReceipt to prove it was completed + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon({ + id: "webui", // The ID of the daemon + command: "./hello-world", // The command to start the daemon + ready: { + display: { // Optional. If present, the health check will display to the user + name: "Web Interface", + message: "The web interface is ready", + }, + fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon + }, + }); +}); diff --git a/startos/procedures/migrations.ts b/startos/procedures/migrations.ts new file mode 100644 index 0000000..5ce13ac --- /dev/null +++ b/startos/procedures/migrations.ts @@ -0,0 +1,4 @@ +import { setupMigrations } from "start-sdk/lib/migrations"; +import { WrapperData } from "../wrapperData"; + +export const { init, uninit } = setupMigrations(async ({ effects, utils }) => {}) \ No newline at end of file diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts new file mode 100644 index 0000000..716fa08 --- /dev/null +++ b/startos/procedures/properties.ts @@ -0,0 +1,26 @@ +import { setupProperties } from "start-sdk/lib/properties"; +import { PropertyString } from "start-sdk/lib/properties"; +import { WrapperData } from "../wrapperData"; + +/** + * In this example, we use the "name" value from Hello World wrapper data to compose a secret phrase and display it to the user in Properties + */ +export const properties = setupProperties(async ({ wrapperData }) => { + const name = wrapperData.name + return [ + PropertyString.of({ + // The display label of the property + name: 'Secret Phrase', + // A human-readable description of the property + description: "This secret phrase will get you access to a secret place.", + // The value of the property + value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, + // optionally display a copy button with the property + copyable: true, + // optionally permit displaying the property as a QR code + qr: false, + // optionally mask the value of the property + masked: false, + }), + ] +}); diff --git a/startos/wrapperData.ts b/startos/wrapperData.ts new file mode 100644 index 0000000..4460244 --- /dev/null +++ b/startos/wrapperData.ts @@ -0,0 +1,5 @@ +export interface WrapperData { + config: { + name: string + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..ba73a93 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "include": ["startos/**/*.ts", "startos/index.ts"], + "files": ["startos/manifest.ts"], + "compilerOptions": { + "target": "es2022", + "module": "None", + "moduleResolution": "node", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true + } +} From b23475edcd25dc6cd8db0ce65ac5e8908d555942 Mon Sep 17 00:00:00 2001 From: BluJ Date: Mon, 24 Apr 2023 15:54:45 -0600 Subject: [PATCH 002/120] chore: Update with the latest api's and make sure we match the sdk --- package-lock.json | 8 +- package.json | 2 +- startos/manifest.ts | 104 +++------ startos/procedures/actions/index.ts | 7 +- startos/procedures/actions/nameToConsole.ts | 39 ++-- startos/procedures/autoConfig.ts | 7 +- startos/procedures/backups.ts | 5 +- startos/procedures/config/index.ts | 14 +- startos/procedures/config/read.ts | 12 +- startos/procedures/config/save.ts | 17 +- startos/procedures/main.ts | 224 ++++++++++---------- startos/procedures/migrations.ts | 10 +- startos/procedures/properties.ts | 46 ++-- 13 files changed, 240 insertions(+), 255 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b05787..b1408f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.charlie33" + "start-sdk": "0.4.0-lib0.charlie34" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.charlie33", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie33.tgz", - "integrity": "sha512-Lx3QAuRCZTA6zXdjsKN3LjCTY1NQgEHY9uOyxKSTnWtaVXdOSp1GqiZYs3c7/ZStPzzTZ19kSnCcVBE125lUHA==", + "version": "0.4.0-lib0.charlie34", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie34.tgz", + "integrity": "sha512-NwXyl12+XjYhHye0YtTCLjcndWTCUPbZ+pNTokVZhGHJrRn3BztM2t8JBJ/g3wK6tafHDurOSCN0082qzmS8Uw==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index b562f31..5bfb1f4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.charlie33" + "start-sdk": "0.4.0-lib0.charlie34" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index 45878d7..c420dce 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,61 +1,6 @@ -export interface Container { - image: string - mounts: Record - shmSizeMb?: number // if greater - sigtermTimeout?: string // if more than 30s to shutdown -} +import { setupManifest } from 'start-sdk/lib/manifest' -export interface GenericManifest { - id: string - title: string - version: string - releaseNotes: string - license: string // name of license - replaces: string[] - wrapperRepo: string - upstreamRepo: string - supportSite: string - marketingSite: string - donationUrl: string | null - description: { - short: string - long: string - } - assets: { - icon: string // file path - instructions: string // file path - license: string // file path - } - containers: Record - volumes: Record - alerts: { - install: string | null - uninstall: string | null - restore: string | null - start: string | null - stop: string | null - } - dependencies: Record -} - -export interface Dependency { - version: string - description: string | null - requirement: - | { - type: 'opt-in' - how: string - } - | { - type: 'opt-out' - how: string - } - | { - type: 'required' - } -} - -export const manifest: GenericManifest = { +export const manifest = setupManifest({ // The package identifier used by the OS. This must be unique amongst all other known packages id: 'hello-world', // A human readable service title @@ -63,57 +8,66 @@ export const manifest: GenericManifest = { // Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service version: '4.0.0.0', // Release notes for the update - can be a string, paragraph or URL - releaseNotes: "Revamped for StartOS 0.4.0", + releaseNotes: 'Revamped for StartOS 0.4.0', // The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. license: 'mit', // A list of normie (hosted, SaaS, custodial, etc) services this services intends to replace - replaces: [], + replaces: Array(), // The Start9 wrapper repository URL for the package. This repo contains the manifest file (this), any scripts necessary for configuration, backups, actions, or health checks (more below). This key must exist. But could be embedded into the source repository - wrapperRepo: "https://github.com/Start9Labs/hello-world-wrapper", + wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', // The original project repository URL. There is no upstream repo in this example - upstreamRepo: "https://github.com/Start9Labs/hello-world", + upstreamRepo: 'https://github.com/Start9Labs/hello-world', // URL to the support site / channel for the project. This key can be omitted if none exists, or it can link to the original project repository issues - supportSite: "https://docs.start9.com/", + supportSite: 'https://docs.start9.com/', // URL to the marketing site for the project. This key can be omitted if none exists, or it can link to the original project repository - marketingSite: "https://start9.com/", + marketingSite: 'https://start9.com/', // URL where users can donate to the upstream project - donationUrl: "https://donate.start9.com/", + donationUrl: 'https://donate.start9.com/', // Human readable descriptors for the service. These are used throughout the EmbassyOS user interface, primarily in the marketplace. description: { // This is the first description visible to the user in the marketplace short: 'Example service', // This description will display with additional details in the service's individual marketplace page - long: 'Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more.' + long: 'Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more.', }, - // These assets are static files necessary for packaging the service for Start9 (into an s9pk). Each value is a path to the specified asset. If an asset is missing from this list, or otherwise denoted, it will be defaulted to the values denoted below. + // These assets are static files necessary for packaging the service for Start9 (into an s9pk). Each value is a path to the specified asset. If an asset is missing from this list, or otherwise denoted, it will be defaulted to the values denoted below. assets: { license: 'LICENSE', icon: 'assets/icon.png', - instructions: 'assets/instructions.md' + instructions: 'assets/instructions.md', }, // This denotes any data, asset, or pointer volumes that should be connected when the "docker run" command is invoked volumes: { // This is the image where files from the project asset directory will go - main: 'data' + main: 'data', }, // Defines the containers needed to run the main and mounted volumes containers: { main: { // Identifier for the main image volume, which will be used when other actions need to mount to this volume. image: 'main', - // Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. + // Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. mounts: { // Specifies where on the service's file system its persistence directory should be mounted prior to service startup - main: '/data' - } - } + main: '/data', + }, + }, }, alerts: { install: 'Optional alert to display before installing the service', uninstall: 'Optional alert to display before uninstalling the service', - restore: 'Optional alert to display before restoring the service from backup', + restore: + 'Optional alert to display before restoring the service from backup', start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, - dependencies: {} -} + dependencies: { + Test: { + version: '1234', + description: '', + requirement: { type: 'opt-out', how: 'During config' }, + }, + }, +}) + +export type Manifest = typeof manifest diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 9201253..55c95c9 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,4 +1,5 @@ -import { ExpectedExports } from "start-sdk/lib/types"; -import { nameToConsole } from "./nameToConsole"; +import { ExpectedExports } from 'start-sdk/lib/types' +import { nameToConsole } from './nameToConsole' +import { setupActions } from 'start-sdk/lib/actions/setupActions' -export const { actions, manifestActions }: ExpectedExports.action = setupActions(nameToConsole) +export const { actions, initializeActions } = setupActions(nameToConsole) diff --git a/startos/procedures/actions/nameToConsole.ts b/startos/procedures/actions/nameToConsole.ts index 3335714..0e7678f 100644 --- a/startos/procedures/actions/nameToConsole.ts +++ b/startos/procedures/actions/nameToConsole.ts @@ -1,28 +1,35 @@ -import { Config, Value } from "start-sdk/lib/config/builder"; +import { Config, Value } from 'start-sdk/lib/config/builder' +import { WrapperData } from '../../wrapperData' +import { createAction } from 'start-sdk/lib/actions/createAction' export const inputBuilder = Config.of({ - name: Value.text( - { - name: 'Name to Print', - required: false, - default: null, - patterns: [], - }, - ), -}); -const matchConfigSpec = inputBuilder.validator(); -type InputSpec = typeof matchConfigSpec._TYPE; + name: Value.text({ + name: 'Name to Print', + required: false, + default: null, + patterns: [], + }), +}) +const matchConfigSpec = inputBuilder.validator() +type InputSpec = typeof matchConfigSpec._TYPE export const nameToConsole = createAction( { name: 'Name to Console', - description: 'Prints the provided name to console or, if left blank, the saved name from config.', + description: + 'Prints the provided name to console or, if left blank, the saved name from config.', id: 'nameToConsole', input: inputBuilder.build(), runningOnly: false, }, async ({ effects, utils, input }) => { - const { name } = await utils.getWrapperData('/config').first() - effects.runCommand(`echo "Hello ${input.name || name}"`) - } + const name = + input.name || (await utils.getWrapperData('/config/name').first()) + effects.runCommand(`echo "Hello ${name}"`) + return { + message: `Echoed name (${name}) to console`, + copyable: true, + qr: false, + } + }, ) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 47cbda7..f38f806 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,4 +1,5 @@ -import { setupAutoConfig } from "start-sdk/lib/autoconfig"; -import { InputSpec } from "./config/inputSpec"; +import { setupAutoConfig } from 'start-sdk/lib/autoconfig' +import { InputSpec } from './config/inputSpec' +import { WrapperData } from '../wrapperData' -export const autoConfig = setupAutoConfig({}); \ No newline at end of file +export const autoConfig = setupAutoConfig({}) diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index e6acc20..65880ed 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,6 +1,7 @@ -import { setupBackups } from "start-sdk/lib/backup"; +import { setupBackups } from 'start-sdk/lib/backup' +import { Manifest } from '../manifest' /** * Here we define what volumes to include in backups */ -export const { createBackup, restoreBackup } = setupBackups("main") \ No newline at end of file +export const { createBackup, restoreBackup } = setupBackups('main') diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 0f6cb84..c146e3b 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,6 +1,10 @@ -import { inputSpec } from "./inputSpec"; -import { read } from "./read"; -import { save } from "./save"; -import { setupConfig } from "start-sdk/lib/config"; +import { WrapperData } from '../../wrapperData' +import { inputSpec } from './inputSpec' +import { read } from './read' +import { save } from './save' +import { setupConfig } from 'start-sdk/lib/config' -export const { getConfig, setConfig } = setupConfig(inputSpec, read, save); \ No newline at end of file +export const { getConfig, setConfig } = setupConfig< + WrapperData, + typeof inputSpec +>(inputSpec, save, read) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 592bdbd..57e2624 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,13 +1,13 @@ -import { InputSpec } from "./inputSpec"; -import { WrapperData } from "../../wrapperData"; -import { Read } from "start-sdk/lib/config/setupConfigExports"; +import { InputSpec } from './inputSpec' +import { WrapperData } from '../../wrapperData' +import { Read } from 'start-sdk/lib/config/setupConfig' /** * This function executes on config fetch - * + * * Use this function to gather data from various files and assemble into a valid config -*/ + */ export const read: Read = async ({ utils }) => { - return utils.getWrapperData({ path: '/config' }); + return utils.getWrapperData('/config').first() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 4e04289..1710936 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,11 +1,16 @@ -import { InputSpec } from "./inputSpec"; -import { WrapperData } from "../../wrapperData"; +import { InputSpec } from './inputSpec' +import { WrapperData } from '../../wrapperData' +import { Save } from 'start-sdk/lib/config/setupConfig' /** * Use this function to persist config data to various files and to establish current dependencies -*/ + */ -export const save: Save = async ({ effects, utils, input }) => { - await utils.setWrapperData('/config', input); - return effects.setDependencies([]); +export const save: Save = async ({ + effects, + utils, + input, +}) => { + await utils.setWrapperData('/config', input) + return effects.setDependencies([]) } diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 79e3028..69e9a91 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,110 +1,116 @@ -import { HealthReceipt } from "start-sdk/lib/health"; -import { checkPortListening } from "start-sdk/lib/health/checkFns"; -import { Daemons, NetworkBuilder, NetworkInterfaceBuilder } from "start-sdk/lib/mainFn"; -import exportInterfaces from "start-sdk/lib/mainFn/exportInterfaces"; -import { ExpectedExports } from "start-sdk/lib/types"; - -export const main: ExpectedExports.main = setupMain(async ({ effects, utils, started }) => { - /** - * ======================== Setup ======================== - * - * In this section, you will fetch any resources or run any commands necessary to run the service - */ - await effects.runCommand("echo starting Hello World!"); - - /** - * ======================== Interfaces ======================== - * - * In this section, you will decide how the service will be exposed to the outside world - * - * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location - */ - - // ------------ Network Builder ------------ - - // Create a Network Builder to be used for finding or creating Tor hostnames and LAN ports - const networkBuilder = NetworkBuilder.of(effects); - - // ------------ Tor ------------ - - // Find or generate a random Tor hostname by ID - const torHostname1 = networkBuilder.getTorHostName("torHostname1"); - - // Create a Tor host with the assigned port mapping - const torHost1 = await torHostname1.bindTor(8080, 80); - // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOrigin1 = torHost1.createOrigin("http"); - - // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8080, 443); - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOrigin2 = torHost2.createOrigin("https"); - - // ------------ LAN ------------ - - // Find or generate a random port by ID - const lanPort1 = networkBuilder.getPort("lanPort1"); - // Create a LAN host with the assigned internal port - const lanHost1 = await lanPort1.bindLan(8080); - // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOrigins1 = lanHost1.createOrigins("https"); - - // ------------ Interface ---------------- - - // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). - // Addresses are different "routes" to the same destination - - // Define the Interface for user display and consumption - const interface1 = new NetworkInterfaceBuilder({ - effects, - name: "Web UI", - id: "webui", - description: "The web interface of Hello World", - ui: false, - basic: null, - path: "", - search: {}, - }); - - // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const addressReceipt1 = await interface1.exportAddresses([ - torOrigin1, - torOrigin2, - lanOrigins1.ip, - lanOrigins1.local - ]); - - // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(addressReceipt1); - - /** - * ======================== Additional Health Checks (optional) ======================== - * - * In this section, you will define additional health checks beyond those associated with daemons - */ - const healthReceipts: HealthReceipt[] = [] - - /** - * ======================== Daemons ======================== - * - * In this section, you will create one or more daemons that define the service runtime - * - * Each daemon defines its own health check, which can optionally be exposed to the user - */ - return Daemons.of({ - effects, - started, - interfaceReceipt, // Provide the interfaceReceipt to prove it was completed - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered - }).addDaemon({ - id: "webui", // The ID of the daemon - command: "./hello-world", // The command to start the daemon - ready: { - display: { // Optional. If present, the health check will display to the user - name: "Web Interface", - message: "The web interface is ready", +import { HealthReceipt } from 'start-sdk/lib/health' +import { checkPortListening } from 'start-sdk/lib/health/checkFns' +import { + Daemons, + NetworkBuilder, + NetworkInterfaceBuilder, + setupMain, +} from 'start-sdk/lib/mainFn' +import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' +import { ExpectedExports } from 'start-sdk/lib/types' +import { WrapperData } from '../wrapperData' + +export const main: ExpectedExports.main = setupMain( + async ({ effects, utils, started }) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + await effects.runCommand('echo starting Hello World!') + + /** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + * + * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location + */ + + // ------------ Network Builder ------------ + + // ------------ Tor ------------ + + // Find or generate a random Tor hostname by ID + const torHostname1 = utils.torHostName('torHostname1') + + // Create a Tor host with the assigned port mapping + const torHost1 = await torHostname1.bindTor(8080, 80) + // Assign the Tor host a web protocol (e.g. "http", "ws") + const torOrigin1 = torHost1.createOrigin('http') + + // Create another Tor host with the assigned port mapping + const torHost2 = await torHostname1.bindTor(8080, 443) + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOrigin2 = torHost2.createOrigin('https') + + // ------------ LAN ------------ + + // Find or generate a random port by ID + const lanPort1 = utils.localPort('lanPort1') + // Create a LAN host with the assigned internal port + const lanHost1 = await lanPort1.bindLan(8080) + // Assign the LAN host a web protocol (e.g. "https", "wss") + const lanOrigins1 = lanHost1.createOrigins('https') + + // ------------ Interface ---------------- + + // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). + // Addresses are different "routes" to the same destination + + // Define the Interface for user display and consumption + const interface1 = new NetworkInterfaceBuilder({ + effects, + name: 'Web UI', + id: 'webui', + description: 'The web interface of Hello World', + ui: false, + basic: null, + path: '', + search: {}, + }) + + // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) + const addressReceipt1 = await interface1.exportAddresses([ + torOrigin1, + torOrigin2, + lanOrigins1.ip, + lanOrigins1.local, + ]) + + // Export all address receipts for all interfaces to obtain interface receipt + const interfaceReceipt = exportInterfaces(addressReceipt1) + + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define additional health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] + + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return Daemons.of({ + effects, + started, + interfaceReceipt, // Provide the interfaceReceipt to prove it was completed + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon({ + id: 'webui', // The ID of the daemon + command: './hello-world', // The command to start the daemon + ready: { + display: { + // Optional. If present, the health check will display to the user + name: 'Web Interface', + message: 'The web interface is ready', + }, + fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon }, - fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon - }, - }); -}); + }) + }, +) diff --git a/startos/procedures/migrations.ts b/startos/procedures/migrations.ts index 5ce13ac..e00cd76 100644 --- a/startos/procedures/migrations.ts +++ b/startos/procedures/migrations.ts @@ -1,4 +1,8 @@ -import { setupMigrations } from "start-sdk/lib/migrations"; -import { WrapperData } from "../wrapperData"; +import { manifest } from '../manifest' +import { initializeActions } from './actions' +import { setupMigrations } from 'start-sdk/lib/migrations/setupMigrations' -export const { init, uninit } = setupMigrations(async ({ effects, utils }) => {}) \ No newline at end of file +export const { init, uninit } = setupMigrations( + manifest, + initializeActions /*, ...,migrationsGoHere */, +) diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index 716fa08..8718ac9 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -1,26 +1,28 @@ -import { setupProperties } from "start-sdk/lib/properties"; -import { PropertyString } from "start-sdk/lib/properties"; -import { WrapperData } from "../wrapperData"; +import { PropertyString, setupProperties } from 'start-sdk/lib/properties' +import { WrapperData } from '../wrapperData' /** * In this example, we use the "name" value from Hello World wrapper data to compose a secret phrase and display it to the user in Properties */ -export const properties = setupProperties(async ({ wrapperData }) => { - const name = wrapperData.name - return [ - PropertyString.of({ - // The display label of the property - name: 'Secret Phrase', - // A human-readable description of the property - description: "This secret phrase will get you access to a secret place.", - // The value of the property - value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, - // optionally display a copy button with the property - copyable: true, - // optionally permit displaying the property as a QR code - qr: false, - // optionally mask the value of the property - masked: false, - }), - ] -}); +export const properties = setupProperties( + async ({ wrapperData }) => { + const name = wrapperData.config.name + return [ + PropertyString.of({ + // The display label of the property + name: 'Secret Phrase', + // A human-readable description of the property + description: + 'This secret phrase will get you access to a secret place.', + // The value of the property + value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, + // optionally display a copy button with the property + copyable: true, + // optionally permit displaying the property as a QR code + qr: false, + // optionally mask the value of the property + masked: false, + }), + ] + }, +) From 83b2f3e605036ae390f0ac272219a90af924eb59 Mon Sep 17 00:00:00 2001 From: BluJ Date: Mon, 24 Apr 2023 18:16:06 -0600 Subject: [PATCH 003/120] chore: Update something --- startos/manifest.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/startos/manifest.ts b/startos/manifest.ts index c420dce..bb82a30 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -36,12 +36,10 @@ export const manifest = setupManifest({ icon: 'assets/icon.png', instructions: 'assets/instructions.md', }, - // This denotes any data, asset, or pointer volumes that should be connected when the "docker run" command is invoked volumes: { // This is the image where files from the project asset directory will go main: 'data', }, - // Defines the containers needed to run the main and mounted volumes containers: { main: { // Identifier for the main image volume, which will be used when other actions need to mount to this volume. From 40767d7b2ae1c195d3c084203e10de88c0bc6c68 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 24 Apr 2023 22:17:01 -0600 Subject: [PATCH 004/120] progress --- package-lock.json | 8 ++-- package.json | 2 +- startos/manifest.ts | 35 +++++---------- startos/procedures/actions/index.ts | 8 ++-- startos/procedures/actions/nameToConsole.ts | 35 --------------- startos/procedures/actions/nameToLogs.ts | 49 +++++++++++++++++++++ startos/procedures/autoConfig.ts | 9 +++- startos/procedures/backups.ts | 2 +- startos/procedures/config/index.ts | 10 ++--- startos/procedures/config/inputSpec.ts | 19 -------- startos/procedures/config/inputSpecRaw.ts | 25 ----------- startos/procedures/config/read.ts | 9 ++-- startos/procedures/config/save.ts | 9 ++-- startos/procedures/config/spec.ts | 20 +++++++++ startos/procedures/index.ts | 12 ++--- startos/procedures/main.ts | 1 - startos/procedures/migrations.ts | 8 ---- startos/procedures/migrations/4.0.0.0.ts | 14 ++++++ startos/procedures/migrations/index.ts | 10 +++++ startos/procedures/properties.ts | 5 +-- startos/wrapperData.ts | 5 +++ tsconfig.json | 3 +- 22 files changed, 149 insertions(+), 149 deletions(-) delete mode 100644 startos/procedures/actions/nameToConsole.ts create mode 100644 startos/procedures/actions/nameToLogs.ts delete mode 100644 startos/procedures/config/inputSpec.ts delete mode 100644 startos/procedures/config/inputSpecRaw.ts create mode 100644 startos/procedures/config/spec.ts delete mode 100644 startos/procedures/migrations.ts create mode 100644 startos/procedures/migrations/4.0.0.0.ts create mode 100644 startos/procedures/migrations/index.ts diff --git a/package-lock.json b/package-lock.json index b1408f9..a64a38b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.charlie34" + "start-sdk": "0.4.0-lib0.charlie35" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.charlie34", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie34.tgz", - "integrity": "sha512-NwXyl12+XjYhHye0YtTCLjcndWTCUPbZ+pNTokVZhGHJrRn3BztM2t8JBJ/g3wK6tafHDurOSCN0082qzmS8Uw==", + "version": "0.4.0-lib0.charlie35", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie35.tgz", + "integrity": "sha512-H61dEpsAtWfCzkYjHYd/JnWjSIHcF5p75QBzFUdPW5g+sB+rGW4B2q2x/0uCkEE2RIv44QMCMfTA+LkbsglB0w==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index 5bfb1f4..8d91890 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.charlie34" + "start-sdk": "0.4.0-lib0.charlie35" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index bb82a30..89e2907 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,36 +1,25 @@ import { setupManifest } from 'start-sdk/lib/manifest' +import { actionsMetadata } from './procedures/actions' +/** + * In this function you define static properties of the service +*/ export const manifest = setupManifest({ - // The package identifier used by the OS. This must be unique amongst all other known packages id: 'hello-world', - // A human readable service title title: 'Hello World', - // Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service version: '4.0.0.0', - // Release notes for the update - can be a string, paragraph or URL releaseNotes: 'Revamped for StartOS 0.4.0', - // The type of license for the project. Include the LICENSE in the root of the project directory. A license is required for a Start9 package. license: 'mit', - // A list of normie (hosted, SaaS, custodial, etc) services this services intends to replace replaces: Array(), - // The Start9 wrapper repository URL for the package. This repo contains the manifest file (this), any scripts necessary for configuration, backups, actions, or health checks (more below). This key must exist. But could be embedded into the source repository wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', - // The original project repository URL. There is no upstream repo in this example upstreamRepo: 'https://github.com/Start9Labs/hello-world', - // URL to the support site / channel for the project. This key can be omitted if none exists, or it can link to the original project repository issues supportSite: 'https://docs.start9.com/', - // URL to the marketing site for the project. This key can be omitted if none exists, or it can link to the original project repository marketingSite: 'https://start9.com/', - // URL where users can donate to the upstream project donationUrl: 'https://donate.start9.com/', - // Human readable descriptors for the service. These are used throughout the EmbassyOS user interface, primarily in the marketplace. description: { - // This is the first description visible to the user in the marketplace - short: 'Example service', - // This description will display with additional details in the service's individual marketplace page + short: 'Example service for s9pk highlighting basic features', long: 'Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more.', }, - // These assets are static files necessary for packaging the service for Start9 (into an s9pk). Each value is a path to the specified asset. If an asset is missing from this list, or otherwise denoted, it will be defaulted to the values denoted below. assets: { license: 'LICENSE', icon: 'assets/icon.png', @@ -51,21 +40,17 @@ export const manifest = setupManifest({ }, }, }, + actions: actionsMetadata, alerts: { install: 'Optional alert to display before installing the service', + update: 'Optional alert to display before updating the service', uninstall: 'Optional alert to display before uninstalling the service', - restore: - 'Optional alert to display before restoring the service from backup', + restore: 'Optional alert to display before restoring the service from backup', start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, - dependencies: { - Test: { - version: '1234', - description: '', - requirement: { type: 'opt-out', how: 'During config' }, - }, - }, + // See "Hello Moon" for an example with dependencies + dependencies: {}, }) export type Manifest = typeof manifest diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 55c95c9..1897f90 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,5 +1,7 @@ -import { ExpectedExports } from 'start-sdk/lib/types' -import { nameToConsole } from './nameToConsole' +import { nameToLogs } from './nameToLogs' import { setupActions } from 'start-sdk/lib/actions/setupActions' -export const { actions, initializeActions } = setupActions(nameToConsole) +/** + * Add each new Action as the next argument to this function + */ +export const { actions, actionsMetadata } = setupActions(nameToLogs) diff --git a/startos/procedures/actions/nameToConsole.ts b/startos/procedures/actions/nameToConsole.ts deleted file mode 100644 index 0e7678f..0000000 --- a/startos/procedures/actions/nameToConsole.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Config, Value } from 'start-sdk/lib/config/builder' -import { WrapperData } from '../../wrapperData' -import { createAction } from 'start-sdk/lib/actions/createAction' - -export const inputBuilder = Config.of({ - name: Value.text({ - name: 'Name to Print', - required: false, - default: null, - patterns: [], - }), -}) -const matchConfigSpec = inputBuilder.validator() -type InputSpec = typeof matchConfigSpec._TYPE - -export const nameToConsole = createAction( - { - name: 'Name to Console', - description: - 'Prints the provided name to console or, if left blank, the saved name from config.', - id: 'nameToConsole', - input: inputBuilder.build(), - runningOnly: false, - }, - async ({ effects, utils, input }) => { - const name = - input.name || (await utils.getWrapperData('/config/name').first()) - effects.runCommand(`echo "Hello ${name}"`) - return { - message: `Echoed name (${name}) to console`, - copyable: true, - qr: false, - } - }, -) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts new file mode 100644 index 0000000..b79bc99 --- /dev/null +++ b/startos/procedures/actions/nameToLogs.ts @@ -0,0 +1,49 @@ +import { Config, Value } from 'start-sdk/lib/config/builder' +import { WrapperData } from '../../wrapperData' +import { createAction } from 'start-sdk/lib/actions/createAction' + +/** + * This is an example Action + * + * By convention, each action receives its own file + * + * Actions optionally take an arbitrary config form as input + */ +const inputBuilder = Config.of({ + nameToPrint: Value.text({ + name: 'Temp Name', + description: 'If no name is provided, the name from config will be used', + required: false, + default: null, + patterns: [], + }), +}) +const matchConfigSpec = inputBuilder.validator() +type InputSpec = typeof matchConfigSpec._TYPE + +/** + * This function defines the Action, including the FormSpec (if any) + * + * The first argument is the Action metadata. The second argument is the Action function + * + * If no input is required, FormSpec would be null + */ +export const nameToLogs = createAction( + { + name: 'Name to Logs', + description: 'Prints "Hello [Name]" to the service logs.', + id: 'nameToLogs', + input: inputBuilder.build(), + runningOnly: false, + }, + async ({ effects, utils, input }) => { + const name = input.nameToPrint || (await utils.getWrapperData('/config/name').first()) + await effects.runCommand(`echo "Hello ${name}"`) + return { + message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, + value: null, + copyable: true, + qr: false, + } + }, +) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index f38f806..422ae3e 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,5 +1,10 @@ import { setupAutoConfig } from 'start-sdk/lib/autoconfig' -import { InputSpec } from './config/inputSpec' +import { ConfigSpec } from './config/spec' import { WrapperData } from '../wrapperData' -export const autoConfig = setupAutoConfig({}) +/** + * In this function, you establish rules for auto configuring service dependencies + * + * See "Hello Moon" for an example + */ +export const autoConfig = setupAutoConfig({}) diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 65880ed..b4181eb 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -2,6 +2,6 @@ import { setupBackups } from 'start-sdk/lib/backup' import { Manifest } from '../manifest' /** - * Here we define what volumes to include in backups + * Here we define what volumes from the Manifest to include in backups */ export const { createBackup, restoreBackup } = setupBackups('main') diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index c146e3b..7e28650 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,10 +1,10 @@ import { WrapperData } from '../../wrapperData' -import { inputSpec } from './inputSpec' +import { configSpec } from './spec' import { read } from './read' import { save } from './save' import { setupConfig } from 'start-sdk/lib/config' -export const { getConfig, setConfig } = setupConfig< - WrapperData, - typeof inputSpec ->(inputSpec, save, read) +/** + * This is a static file. There is no need to make changes here + */ +export const { getConfig, setConfig } = setupConfig(configSpec, save, read) diff --git a/startos/procedures/config/inputSpec.ts b/startos/procedures/config/inputSpec.ts deleted file mode 100644 index 722d39a..0000000 --- a/startos/procedures/config/inputSpec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { configBuilder } from "start-sdk/lib"; -const { Config, Value } = configBuilder; - -/** - * This file is required. It can be composed manually or generated from inputSpecRaw.ts, depending on your syntactic preference for writing input specs -*/ -export const inputSpec = Config.of({ - name: Value.text( - { - name: "Name", - description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: false, - }, - ), -}); - -export const matchConfigSpec = inputSpec.validator(); -export type InputSpec = typeof matchConfigSpec._TYPE; - diff --git a/startos/procedures/config/inputSpecRaw.ts b/startos/procedures/config/inputSpecRaw.ts deleted file mode 100644 index 74a4b24..0000000 --- a/startos/procedures/config/inputSpecRaw.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { InputSpec } from "start-sdk/lib/config/configTypes"; - -/** - * This file is optional. Use it to define the input spec in a single structure - * - * Once complete, run "npm run gen-input-spec" to generate inputSpec.ts from this file - * - * Hint: use "ctrl + space" inside any given key to see the set of possible attributes for that key's type -*/ -export const spec: InputSpec = { - name: { - type: "text", - name: "Name", - description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: false, - default: "World", - placeholder: "Enter your name", - warning: null, - minLength: null, - maxLength: null, - inputmode: "email", - masked: false, - patterns: [], - }, -}; diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 57e2624..5d2c3d0 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,13 +1,12 @@ -import { InputSpec } from './inputSpec' +import { ConfigSpec } from './spec' import { WrapperData } from '../../wrapperData' import { Read } from 'start-sdk/lib/config/setupConfig' /** - * This function executes on config fetch + * This function executes on config get * - * Use this function to gather data from various files and assemble into a valid config + * Use this function to gather data from various files and assemble into a valid config to display to the user */ - -export const read: Read = async ({ utils }) => { +export const read: Read = async ({ utils }) => { return utils.getWrapperData('/config').first() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 1710936..5b65809 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,12 +1,13 @@ -import { InputSpec } from './inputSpec' +import { ConfigSpec } from './spec' import { WrapperData } from '../../wrapperData' import { Save } from 'start-sdk/lib/config/setupConfig' /** - * Use this function to persist config data to various files and to establish current dependencies + * This function executes on config save + * + * Use it to persist config data to various files and to establish any resulting dependencies */ - -export const save: Save = async ({ +export const save: Save = async ({ effects, utils, input, diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts new file mode 100644 index 0000000..d975129 --- /dev/null +++ b/startos/procedures/config/spec.ts @@ -0,0 +1,20 @@ +import { configBuilder } from "start-sdk/lib" +const { Config, Value } = configBuilder + +/** + * Here you define the config specification that will ultimately present to the user as validated form inputs + * + * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) +*/ +export const configSpec = Config.of({ + name: Value.text( + { + name: "Name", + description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', + required: false, + }, + ), +}) +// These two lines are necessary to satisfy Typescript typings +export const matchConfigSpec = configSpec.validator() +export type ConfigSpec = typeof matchConfigSpec._TYPE diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index e55d745..f0a6301 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -1,7 +1,7 @@ -export { getConfig, setConfig } from "./config"; -export { createBackup, restoreBackup } from "./backups"; +export { getConfig, setConfig } from "./config" +export { createBackup, restoreBackup } from "./backups" export { properties } from "./properties" -export { main } from './main'; -export { init, uninit } from "./migrations"; -export { actions } from "./actions"; -export { autoConfig } from "./autoConfig"; +export { main } from './main' +export { init, uninit } from "./migrations" +export { actions } from "./actions" +export { autoConfig } from "./autoConfig" diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 69e9a91..f721ae4 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -2,7 +2,6 @@ import { HealthReceipt } from 'start-sdk/lib/health' import { checkPortListening } from 'start-sdk/lib/health/checkFns' import { Daemons, - NetworkBuilder, NetworkInterfaceBuilder, setupMain, } from 'start-sdk/lib/mainFn' diff --git a/startos/procedures/migrations.ts b/startos/procedures/migrations.ts deleted file mode 100644 index e00cd76..0000000 --- a/startos/procedures/migrations.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { manifest } from '../manifest' -import { initializeActions } from './actions' -import { setupMigrations } from 'start-sdk/lib/migrations/setupMigrations' - -export const { init, uninit } = setupMigrations( - manifest, - initializeActions /*, ...,migrationsGoHere */, -) diff --git a/startos/procedures/migrations/4.0.0.0.ts b/startos/procedures/migrations/4.0.0.0.ts new file mode 100644 index 0000000..1bb8dfe --- /dev/null +++ b/startos/procedures/migrations/4.0.0.0.ts @@ -0,0 +1,14 @@ +import { Migration } from "start-sdk/lib/migrations/Migration" + +/** + * This is an example migration file + * + * By convention, each version service requiring a migration receives its own file + * + * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts + */ +export const v4000 = new Migration({ + version: '4.0.0', + up: async ({ effects }) => await effects.setConfigured(false), + down: async ({ effects }) => {} +}) diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts new file mode 100644 index 0000000..a424460 --- /dev/null +++ b/startos/procedures/migrations/index.ts @@ -0,0 +1,10 @@ +import { manifest } from '../../manifest' +import { setupMigrations } from 'start-sdk/lib/migrations/setupMigrations' +import { v4000 } from './4.0.0.0' + +/** + * Add each new migration as the next argument to this function + */ +export const { init, uninit } = setupMigrations(manifest, + v4000, +) diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index 8718ac9..052485b 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -2,7 +2,7 @@ import { PropertyString, setupProperties } from 'start-sdk/lib/properties' import { WrapperData } from '../wrapperData' /** - * In this example, we use the "name" value from Hello World wrapper data to compose a secret phrase and display it to the user in Properties + * With access to WrapperData, in this function you determine what to include in the Properties section of the UI */ export const properties = setupProperties( async ({ wrapperData }) => { @@ -12,8 +12,7 @@ export const properties = setupProperties( // The display label of the property name: 'Secret Phrase', // A human-readable description of the property - description: - 'This secret phrase will get you access to a secret place.', + description: 'This secret phrase will get you access to a secret place', // The value of the property value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, // optionally display a copy button with the property diff --git a/startos/wrapperData.ts b/startos/wrapperData.ts index 4460244..584d195 100644 --- a/startos/wrapperData.ts +++ b/startos/wrapperData.ts @@ -1,3 +1,8 @@ +/** + * Here you define the set of data that the service wrapper will persist for self consumption or export to users and other services + * + * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords +*/ export interface WrapperData { config: { name: string diff --git a/tsconfig.json b/tsconfig.json index ba73a93..b814af3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,5 @@ { - "include": ["startos/**/*.ts", "startos/index.ts"], - "files": ["startos/manifest.ts"], + "include": ["startos/**/*.ts"], "compilerOptions": { "target": "es2022", "module": "None", From 8c30c5af980db6602f09f9fb09790d2bac90619c Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 25 Apr 2023 10:33:51 -0600 Subject: [PATCH 005/120] chore: Update the version --- startos/procedures/autoConfig.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 422ae3e..12cfa8d 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,10 +1,16 @@ import { setupAutoConfig } from 'start-sdk/lib/autoconfig' import { ConfigSpec } from './config/spec' import { WrapperData } from '../wrapperData' +import { Manifest } from '../manifest' /** * In this function, you establish rules for auto configuring service dependencies - * + * * See "Hello Moon" for an example */ -export const autoConfig = setupAutoConfig({}) +export const autoConfig = setupAutoConfig< + WrapperData, + ConfigSpec, + Manifest, + {} +>({}) From 11d43a8e4304039efc5124b9c56eddb1b3222fc9 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 25 Apr 2023 10:59:32 -0600 Subject: [PATCH 006/120] update latest --- package-lock.json | 8 ++++---- package.json | 2 +- startos/manifest.ts | 6 +++--- startos/procedures/autoConfig.ts | 9 ++------- startos/procedures/main.ts | 2 +- startos/procedures/migrations/{4.0.0.0.ts => 4.0.0.ts} | 2 +- startos/procedures/migrations/index.ts | 4 ++-- startos/wrapperData.ts | 2 +- 8 files changed, 15 insertions(+), 20 deletions(-) rename startos/procedures/migrations/{4.0.0.0.ts => 4.0.0.ts} (91%) diff --git a/package-lock.json b/package-lock.json index a64a38b..6f4e2b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.charlie35" + "start-sdk": "0.4.0-lib0.charlie38" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.charlie35", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie35.tgz", - "integrity": "sha512-H61dEpsAtWfCzkYjHYd/JnWjSIHcF5p75QBzFUdPW5g+sB+rGW4B2q2x/0uCkEE2RIv44QMCMfTA+LkbsglB0w==", + "version": "0.4.0-lib0.charlie38", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie38.tgz", + "integrity": "sha512-QGbJPbFbsXMsk1nUSp+ZTuz1cBi1IDY6E+rlBJJVbgLDYYk5cv+hx1mEvc3IV/nZ+M9bIk99nf885cBrg8haQg==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index 8d91890..a1d0fd8 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.charlie35" + "start-sdk": "0.4.0-lib0.charlie38" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index 89e2907..54e04e9 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -7,10 +7,10 @@ import { actionsMetadata } from './procedures/actions' export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', - version: '4.0.0.0', + version: '4.0.0', releaseNotes: 'Revamped for StartOS 0.4.0', license: 'mit', - replaces: Array(), + replaces: Array('Hello World (hosted)', 'Goodbye World'), wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', upstreamRepo: 'https://github.com/Start9Labs/hello-world', supportSite: 'https://docs.start9.com/', @@ -49,7 +49,7 @@ export const manifest = setupManifest({ start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, - // See "Hello Moon" for an example with dependencies + /** See Hello Moon for an example with dependencies */ dependencies: {}, }) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 12cfa8d..124b8e7 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -6,11 +6,6 @@ import { Manifest } from '../manifest' /** * In this function, you establish rules for auto configuring service dependencies * - * See "Hello Moon" for an example + * See Hello Moon for an example */ -export const autoConfig = setupAutoConfig< - WrapperData, - ConfigSpec, - Manifest, - {} ->({}) +export const autoConfig = setupAutoConfig({}) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index f721ae4..b3f7d49 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -16,7 +16,7 @@ export const main: ExpectedExports.main = setupMain( * * In this section, you will fetch any resources or run any commands necessary to run the service */ - await effects.runCommand('echo starting Hello World!') + await effects.runCommand('echo "Starting Hello World!"') /** * ======================== Interfaces ======================== diff --git a/startos/procedures/migrations/4.0.0.0.ts b/startos/procedures/migrations/4.0.0.ts similarity index 91% rename from startos/procedures/migrations/4.0.0.0.ts rename to startos/procedures/migrations/4.0.0.ts index 1bb8dfe..e29a5ef 100644 --- a/startos/procedures/migrations/4.0.0.0.ts +++ b/startos/procedures/migrations/4.0.0.ts @@ -7,7 +7,7 @@ import { Migration } from "start-sdk/lib/migrations/Migration" * * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts */ -export const v4000 = new Migration({ +export const v4_0_0 = new Migration({ version: '4.0.0', up: async ({ effects }) => await effects.setConfigured(false), down: async ({ effects }) => {} diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index a424460..54e581e 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,10 +1,10 @@ import { manifest } from '../../manifest' import { setupMigrations } from 'start-sdk/lib/migrations/setupMigrations' -import { v4000 } from './4.0.0.0' +import { v4_0_0 } from './4.0.0' /** * Add each new migration as the next argument to this function */ export const { init, uninit } = setupMigrations(manifest, - v4000, + v4_0_0, ) diff --git a/startos/wrapperData.ts b/startos/wrapperData.ts index 584d195..c07824e 100644 --- a/startos/wrapperData.ts +++ b/startos/wrapperData.ts @@ -1,5 +1,5 @@ /** - * Here you define the set of data that the service wrapper will persist for self consumption or export to users and other services + * Here you define the set of data that the service wrapper will persist for self consumption and for exporting to users and other services * * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords */ From 609cad3c2a245c10c81771a102ef6506e70655b2 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 25 Apr 2023 15:04:17 -0600 Subject: [PATCH 007/120] intro setupInit --- package-lock.json | 8 ++++---- package.json | 2 +- startos/procedures/index.ts | 3 ++- startos/procedures/init.ts | 18 ++++++++++++++++++ startos/procedures/migrations/4.0.0.ts | 2 +- startos/procedures/migrations/index.ts | 6 +++--- 6 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 startos/procedures/init.ts diff --git a/package-lock.json b/package-lock.json index 6f4e2b5..2e4147b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.charlie38" + "start-sdk": "0.4.0-lib0.charlie39" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.charlie38", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie38.tgz", - "integrity": "sha512-QGbJPbFbsXMsk1nUSp+ZTuz1cBi1IDY6E+rlBJJVbgLDYYk5cv+hx1mEvc3IV/nZ+M9bIk99nf885cBrg8haQg==", + "version": "0.4.0-lib0.charlie39", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie39.tgz", + "integrity": "sha512-CQ+YFah3/jG7hLTLV5QEfApuCnZdRqxQ3dAaWI6hwlrM/EcP9WiRezA/izfe6NTBDxhGArZojSLK8H9KCv0YfA==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index a1d0fd8..1dd52f9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.charlie38" + "start-sdk": "0.4.0-lib0.charlie39" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index f0a6301..ffd8a3e 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -2,6 +2,7 @@ export { getConfig, setConfig } from "./config" export { createBackup, restoreBackup } from "./backups" export { properties } from "./properties" export { main } from './main' -export { init, uninit } from "./migrations" +export { init, uninit } from "./init" export { actions } from "./actions" export { autoConfig } from "./autoConfig" + diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts new file mode 100644 index 0000000..f3a4522 --- /dev/null +++ b/startos/procedures/init.ts @@ -0,0 +1,18 @@ +import { setupInit, setupInstall, setupUninstall } from "start-sdk/lib/inits" +import { WrapperData } from "../wrapperData" +import { migrations } from "./migrations" + +/** + * Here you define arbitrary code that runs once, on fresh install only + */ +const install = setupInstall(async ({ effects, utils }) => {}) + +/** + * Here you define arbitrary code that runs once, on uninstall only + */ +const uninstall = setupUninstall(async ({ effects, utils }) => {}) + +/** + * This is a static function. There is no need to make changes here + */ +export const { init, uninit } = setupInit(migrations, install, uninstall) \ No newline at end of file diff --git a/startos/procedures/migrations/4.0.0.ts b/startos/procedures/migrations/4.0.0.ts index e29a5ef..3b008f7 100644 --- a/startos/procedures/migrations/4.0.0.ts +++ b/startos/procedures/migrations/4.0.0.ts @@ -1,4 +1,4 @@ -import { Migration } from "start-sdk/lib/migrations/Migration" +import { Migration } from "start-sdk/lib/inits/migrations/Migration"; /** * This is an example migration file diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index 54e581e..848da22 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,10 +1,10 @@ +import { setupMigrations } from 'start-sdk/lib/inits/migrations/setupMigrations' import { manifest } from '../../manifest' -import { setupMigrations } from 'start-sdk/lib/migrations/setupMigrations' import { v4_0_0 } from './4.0.0' /** * Add each new migration as the next argument to this function */ -export const { init, uninit } = setupMigrations(manifest, +export const migrations = setupMigrations(manifest, v4_0_0, -) +) \ No newline at end of file From dbcc460875b939846ed1de5c19e3da00763fa00e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 25 Apr 2023 15:49:27 -0600 Subject: [PATCH 008/120] minor formatting --- startos/procedures/main.ts | 206 ++++++++++++++++++------------------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index b3f7d49..2669025 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -9,107 +9,107 @@ import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from 'start-sdk/lib/types' import { WrapperData } from '../wrapperData' -export const main: ExpectedExports.main = setupMain( - async ({ effects, utils, started }) => { - /** - * ======================== Setup ======================== - * - * In this section, you will fetch any resources or run any commands necessary to run the service - */ - await effects.runCommand('echo "Starting Hello World!"') - - /** - * ======================== Interfaces ======================== - * - * In this section, you will decide how the service will be exposed to the outside world - * - * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location - */ - - // ------------ Network Builder ------------ - - // ------------ Tor ------------ - - // Find or generate a random Tor hostname by ID - const torHostname1 = utils.torHostName('torHostname1') - - // Create a Tor host with the assigned port mapping - const torHost1 = await torHostname1.bindTor(8080, 80) - // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOrigin1 = torHost1.createOrigin('http') - - // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8080, 443) - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOrigin2 = torHost2.createOrigin('https') - - // ------------ LAN ------------ - - // Find or generate a random port by ID - const lanPort1 = utils.localPort('lanPort1') - // Create a LAN host with the assigned internal port - const lanHost1 = await lanPort1.bindLan(8080) - // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOrigins1 = lanHost1.createOrigins('https') - - // ------------ Interface ---------------- - - // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). - // Addresses are different "routes" to the same destination - - // Define the Interface for user display and consumption - const interface1 = new NetworkInterfaceBuilder({ - effects, - name: 'Web UI', - id: 'webui', - description: 'The web interface of Hello World', - ui: false, - basic: null, - path: '', - search: {}, - }) - - // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const addressReceipt1 = await interface1.exportAddresses([ - torOrigin1, - torOrigin2, - lanOrigins1.ip, - lanOrigins1.local, - ]) - - // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(addressReceipt1) - - /** - * ======================== Additional Health Checks (optional) ======================== - * - * In this section, you will define additional health checks beyond those associated with daemons - */ - const healthReceipts: HealthReceipt[] = [] - - /** - * ======================== Daemons ======================== - * - * In this section, you will create one or more daemons that define the service runtime - * - * Each daemon defines its own health check, which can optionally be exposed to the user - */ - return Daemons.of({ - effects, - started, - interfaceReceipt, // Provide the interfaceReceipt to prove it was completed - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered - }).addDaemon({ - id: 'webui', // The ID of the daemon - command: './hello-world', // The command to start the daemon - ready: { - display: { - // Optional. If present, the health check will display to the user - name: 'Web Interface', - message: 'The web interface is ready', - }, - fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon +export const main: ExpectedExports.main = setupMain(async ({ + effects, + utils, + started +}) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + await effects.runCommand('echo "Starting Hello World!"') + + /** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + * + * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location + */ + + // ------------ Tor ------------ + + // Find or generate a random Tor hostname by ID + const torHostname1 = utils.torHostName('torHostname1') + + // Create a Tor host with the assigned port mapping + const torHost1 = await torHostname1.bindTor(8080, 80) + // Assign the Tor host a web protocol (e.g. "http", "ws") + const torOrigin1 = torHost1.createOrigin('http') + + // Create another Tor host with the assigned port mapping + const torHost2 = await torHostname1.bindTor(8080, 443) + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOrigin2 = torHost2.createOrigin('https') + + // ------------ LAN ------------ + + // Find or generate a random port by ID + const lanPort1 = utils.localPort('lanPort1') + // Create a LAN host with the assigned internal port + const lanHost1 = await lanPort1.bindLan(8080) + // Assign the LAN host a web protocol (e.g. "https", "wss") + const lanOrigins1 = lanHost1.createOrigins('https') + + // ------------ Interface ---------------- + + // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). + // Addresses are different "routes" to the same destination + + // Define the Interface for user display and consumption + const iFace1 = new NetworkInterfaceBuilder({ + effects, + name: 'Web UI', + id: 'webui', + description: 'The web interface of Hello World', + ui: false, + basic: null, + path: '', + search: {}, + }) + + // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) + const addressReceipt1 = await iFace1.exportAddresses([ + torOrigin1, + torOrigin2, + lanOrigins1.ip, + lanOrigins1.local, + ]) + + // Export all address receipts for all interfaces to obtain interface receipt + const interfaceReceipt = exportInterfaces(addressReceipt1) + + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define additional health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] + + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return Daemons.of({ + effects, + started, + interfaceReceipt, // Provide the interfaceReceipt to prove it was completed + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon({ + id: 'webui', // The ID of the daemon + command: './hello-world', // The command to start the daemon + ready: { + display: { + // Optional. If present, the health check will display to the user + name: 'Web Interface', + message: 'The web interface is ready', }, - }) - }, -) + fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon + }, + }) +}) From ebc4e187e7c1d35822769b1cceb80755ccf662cf Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 26 Apr 2023 10:11:42 -0600 Subject: [PATCH 009/120] SDK RC1 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e4147b..4764b5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.charlie39" + "start-sdk": "0.4.0-lib0.rc1" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.charlie39", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.charlie39.tgz", - "integrity": "sha512-CQ+YFah3/jG7hLTLV5QEfApuCnZdRqxQ3dAaWI6hwlrM/EcP9WiRezA/izfe6NTBDxhGArZojSLK8H9KCv0YfA==", + "version": "0.4.0-lib0.rc1", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc1.tgz", + "integrity": "sha512-jx8VB+Qyt6VqisfC3XE1ERIkKZ7o7wWWdymeDC8jmzR4GZhdpU3TxX42Jmon5uU4FESeVcixQL0dv2KLHlORig==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index 1dd52f9..25afdd0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.charlie39" + "start-sdk": "0.4.0-lib0.rc1" }, "devDependencies": { "@vercel/ncc": "^0.36.1", From ca05df4b8259a3fcff5d475f68ec51f9489d94ed Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 26 Apr 2023 13:05:13 -0600 Subject: [PATCH 010/120] minor changes --- .gitignore | 3 +-- startos/procedures/actions/nameToLogs.ts | 18 +++++++------- startos/procedures/config/read.ts | 2 +- startos/procedures/config/save.ts | 3 ++- startos/procedures/config/spec.ts | 4 ++-- startos/procedures/main.ts | 24 +++++++++---------- startos/procedures/migrations/index.ts | 2 +- .../migrations/{4.0.0.ts => v4_0_0.ts} | 0 8 files changed, 27 insertions(+), 29 deletions(-) rename startos/procedures/migrations/{4.0.0.ts => v4_0_0.ts} (100%) diff --git a/.gitignore b/.gitignore index 5f7cf1a..ca256b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -hello-world.s9pk -image.tar +*.s9pk procedures/*.js node_modules/ .DS_Store diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index b79bc99..d7ff46c 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -9,7 +9,7 @@ import { createAction } from 'start-sdk/lib/actions/createAction' * * Actions optionally take an arbitrary config form as input */ -const inputBuilder = Config.of({ +const input = Config.of({ nameToPrint: Value.text({ name: 'Temp Name', description: 'If no name is provided, the name from config will be used', @@ -18,8 +18,6 @@ const inputBuilder = Config.of({ patterns: [], }), }) -const matchConfigSpec = inputBuilder.validator() -type InputSpec = typeof matchConfigSpec._TYPE /** * This function defines the Action, including the FormSpec (if any) @@ -28,22 +26,24 @@ type InputSpec = typeof matchConfigSpec._TYPE * * If no input is required, FormSpec would be null */ -export const nameToLogs = createAction( +export const nameToLogs = createAction( { name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', id: 'nameToLogs', - input: inputBuilder.build(), + input, runningOnly: false, }, async ({ effects, utils, input }) => { const name = input.nameToPrint || (await utils.getWrapperData('/config/name').first()) - await effects.runCommand(`echo "Hello ${name}"`) + effects.info(`Hello ${name}`) return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, - value: null, - copyable: true, - qr: false, + value: { + value: null, + copyable: true, + qr: false, + } } }, ) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 5d2c3d0..9b1c2e2 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -7,6 +7,6 @@ import { Read } from 'start-sdk/lib/config/setupConfig' * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read: Read = async ({ utils }) => { +export const read: Read = async ({ effects, utils }) => { return utils.getWrapperData('/config').first() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 5b65809..cf61388 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -7,10 +7,11 @@ import { Save } from 'start-sdk/lib/config/setupConfig' * * Use it to persist config data to various files and to establish any resulting dependencies */ -export const save: Save = async ({ +export const save: Save = async ({ effects, utils, input, + dependencies, }) => { await utils.setWrapperData('/config', input) return effects.setDependencies([]) diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index d975129..c7b144f 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -11,10 +11,10 @@ export const configSpec = Config.of({ { name: "Name", description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: false, + required: true, }, ), }) -// These two lines are necessary to satisfy Typescript typings +// These two lines are necessary to satisfy Typescript typings. Do not touch them export const matchConfigSpec = configSpec.validator() export type ConfigSpec = typeof matchConfigSpec._TYPE diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 2669025..3611250 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -19,7 +19,7 @@ export const main: ExpectedExports.main = setupMain(async ({ * * In this section, you will fetch any resources or run any commands necessary to run the service */ - await effects.runCommand('echo "Starting Hello World!"') + effects.info('Starting Hello World!') /** * ======================== Interfaces ======================== @@ -40,16 +40,14 @@ export const main: ExpectedExports.main = setupMain(async ({ const torOrigin1 = torHost1.createOrigin('http') // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8080, 443) + const torHost2 = await torHostname1.bindTor(8443, 443) // Assign the Tor host a web protocol (e.g. "https", "wss") const torOrigin2 = torHost2.createOrigin('https') // ------------ LAN ------------ - // Find or generate a random port by ID - const lanPort1 = utils.localPort('lanPort1') // Create a LAN host with the assigned internal port - const lanHost1 = await lanPort1.bindLan(8080) + const lanHost1 = await utils.bindLan(8080) // Assign the LAN host a web protocol (e.g. "https", "wss") const lanOrigins1 = lanHost1.createOrigins('https') @@ -64,7 +62,7 @@ export const main: ExpectedExports.main = setupMain(async ({ name: 'Web UI', id: 'webui', description: 'The web interface of Hello World', - ui: false, + ui: true, basic: null, path: '', search: {}, @@ -102,14 +100,14 @@ export const main: ExpectedExports.main = setupMain(async ({ healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered }).addDaemon({ id: 'webui', // The ID of the daemon - command: './hello-world', // The command to start the daemon + command: 'hello-world', // The command to start the daemon ready: { - display: { - // Optional. If present, the health check will display to the user - name: 'Web Interface', - message: 'The web interface is ready', - }, - fn: () => checkPortListening(effects, 8080, {}), // The function to run to determine the health status of the daemon + display: 'Web Interface', + // The function to run to determine the health status of the daemon + fn: () => checkPortListening(effects, 8080, { + timeout: 10_000, + successMessage: 'The web interface is ready', + }), }, }) }) diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index 848da22..c0e9da9 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,6 +1,6 @@ import { setupMigrations } from 'start-sdk/lib/inits/migrations/setupMigrations' import { manifest } from '../../manifest' -import { v4_0_0 } from './4.0.0' +import { v4_0_0 } from './v4_0_0' /** * Add each new migration as the next argument to this function diff --git a/startos/procedures/migrations/4.0.0.ts b/startos/procedures/migrations/v4_0_0.ts similarity index 100% rename from startos/procedures/migrations/4.0.0.ts rename to startos/procedures/migrations/v4_0_0.ts From f07e35480fcaea5956b79bc1b38d49e13b12b6c7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 26 Apr 2023 13:09:39 -0600 Subject: [PATCH 011/120] effects console --- startos/procedures/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 3611250..8b15322 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -19,7 +19,7 @@ export const main: ExpectedExports.main = setupMain(async ({ * * In this section, you will fetch any resources or run any commands necessary to run the service */ - effects.info('Starting Hello World!') + await effects.console.info('Starting Hello World!') /** * ======================== Interfaces ======================== From 5c7b89a2bdfbcf5e3c5fec081fc619ca37fbc60a Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 26 Apr 2023 20:39:07 -0600 Subject: [PATCH 012/120] prettier --- package.json | 2 +- startos/manifest.ts | 7 +- startos/procedures/actions/nameToLogs.ts | 13 +- startos/procedures/autoConfig.ts | 7 +- startos/procedures/config/index.ts | 5 +- startos/procedures/config/read.ts | 5 +- startos/procedures/config/save.ts | 2 +- startos/procedures/config/spec.ts | 19 ++- startos/procedures/index.ts | 13 +- startos/procedures/init.ts | 8 +- startos/procedures/main.ts | 175 +++++++++++------------ startos/procedures/migrations/index.ts | 4 +- startos/procedures/migrations/v4_0_0.ts | 8 +- startos/wrapperData.ts | 6 +- 14 files changed, 141 insertions(+), 133 deletions(-) diff --git a/package.json b/package.json index 25afdd0..cc4f125 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "scripts": { "build": "ncc build procedures/index.ts -o ./", - "prettier": "prettier --write procedures", + "prettier": "prettier --write startos", "check": "tsc --noEmit" }, "dependencies": { diff --git a/startos/manifest.ts b/startos/manifest.ts index 54e04e9..32559e8 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,9 +1,9 @@ import { setupManifest } from 'start-sdk/lib/manifest' import { actionsMetadata } from './procedures/actions' -/** +/** * In this function you define static properties of the service -*/ + */ export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', @@ -45,7 +45,8 @@ export const manifest = setupManifest({ install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', uninstall: 'Optional alert to display before uninstalling the service', - restore: 'Optional alert to display before restoring the service from backup', + restore: + 'Optional alert to display before restoring the service from backup', start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index d7ff46c..f2aa593 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -4,9 +4,9 @@ import { createAction } from 'start-sdk/lib/actions/createAction' /** * This is an example Action - * + * * By convention, each action receives its own file - * + * * Actions optionally take an arbitrary config form as input */ const input = Config.of({ @@ -21,9 +21,9 @@ const input = Config.of({ /** * This function defines the Action, including the FormSpec (if any) - * + * * The first argument is the Action metadata. The second argument is the Action function - * + * * If no input is required, FormSpec would be null */ export const nameToLogs = createAction( @@ -35,7 +35,8 @@ export const nameToLogs = createAction( runningOnly: false, }, async ({ effects, utils, input }) => { - const name = input.nameToPrint || (await utils.getWrapperData('/config/name').first()) + const name = + input.nameToPrint || (await utils.getWrapperData('/config/name').first()) effects.info(`Hello ${name}`) return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, @@ -43,7 +44,7 @@ export const nameToLogs = createAction( value: null, copyable: true, qr: false, - } + }, } }, ) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 124b8e7..37a2d93 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -8,4 +8,9 @@ import { Manifest } from '../manifest' * * See Hello Moon for an example */ -export const autoConfig = setupAutoConfig({}) +export const autoConfig = setupAutoConfig< + WrapperData, + ConfigSpec, + Manifest, + {} +>({}) diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 7e28650..1b46a31 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -7,4 +7,7 @@ import { setupConfig } from 'start-sdk/lib/config' /** * This is a static file. There is no need to make changes here */ -export const { getConfig, setConfig } = setupConfig(configSpec, save, read) +export const { getConfig, setConfig } = setupConfig< + WrapperData, + typeof configSpec +>(configSpec, save, read) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 9b1c2e2..e9683f0 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -7,6 +7,9 @@ import { Read } from 'start-sdk/lib/config/setupConfig' * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read: Read = async ({ effects, utils }) => { +export const read: Read = async ({ + effects, + utils, +}) => { return utils.getWrapperData('/config').first() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index cf61388..42bfb1b 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -4,7 +4,7 @@ import { Save } from 'start-sdk/lib/config/setupConfig' /** * This function executes on config save - * + * * Use it to persist config data to various files and to establish any resulting dependencies */ export const save: Save = async ({ diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index c7b144f..047989b 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,19 +1,18 @@ -import { configBuilder } from "start-sdk/lib" +import { configBuilder } from 'start-sdk/lib' const { Config, Value } = configBuilder /** * Here you define the config specification that will ultimately present to the user as validated form inputs - * + * * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) -*/ + */ export const configSpec = Config.of({ - name: Value.text( - { - name: "Name", - description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: true, - }, - ), + name: Value.text({ + name: 'Name', + description: + 'When you launch the Hello World UI, it will display "Hello [First Name]"', + required: true, + }), }) // These two lines are necessary to satisfy Typescript typings. Do not touch them export const matchConfigSpec = configSpec.validator() diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index ffd8a3e..5f499df 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -1,8 +1,7 @@ -export { getConfig, setConfig } from "./config" -export { createBackup, restoreBackup } from "./backups" -export { properties } from "./properties" +export { getConfig, setConfig } from './config' +export { createBackup, restoreBackup } from './backups' +export { properties } from './properties' export { main } from './main' -export { init, uninit } from "./init" -export { actions } from "./actions" -export { autoConfig } from "./autoConfig" - +export { init, uninit } from './init' +export { actions } from './actions' +export { autoConfig } from './autoConfig' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index f3a4522..a4ae1b2 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,6 +1,6 @@ -import { setupInit, setupInstall, setupUninstall } from "start-sdk/lib/inits" -import { WrapperData } from "../wrapperData" -import { migrations } from "./migrations" +import { setupInit, setupInstall, setupUninstall } from 'start-sdk/lib/inits' +import { WrapperData } from '../wrapperData' +import { migrations } from './migrations' /** * Here you define arbitrary code that runs once, on fresh install only @@ -15,4 +15,4 @@ const uninstall = setupUninstall(async ({ effects, utils }) => {}) /** * This is a static function. There is no need to make changes here */ -export const { init, uninit } = setupInit(migrations, install, uninstall) \ No newline at end of file +export const { init, uninit } = setupInit(migrations, install, uninstall) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 8b15322..1d56153 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -9,105 +9,104 @@ import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from 'start-sdk/lib/types' import { WrapperData } from '../wrapperData' -export const main: ExpectedExports.main = setupMain(async ({ - effects, - utils, - started -}) => { - /** - * ======================== Setup ======================== - * - * In this section, you will fetch any resources or run any commands necessary to run the service - */ - await effects.console.info('Starting Hello World!') +export const main: ExpectedExports.main = setupMain( + async ({ effects, utils, started }) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + await effects.console.info('Starting Hello World!') - /** - * ======================== Interfaces ======================== - * - * In this section, you will decide how the service will be exposed to the outside world - * - * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location - */ + /** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + * + * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location + */ - // ------------ Tor ------------ + // ------------ Tor ------------ - // Find or generate a random Tor hostname by ID - const torHostname1 = utils.torHostName('torHostname1') + // Find or generate a random Tor hostname by ID + const torHostname1 = utils.torHostName('torHostname1') - // Create a Tor host with the assigned port mapping - const torHost1 = await torHostname1.bindTor(8080, 80) - // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOrigin1 = torHost1.createOrigin('http') + // Create a Tor host with the assigned port mapping + const torHost1 = await torHostname1.bindTor(8080, 80) + // Assign the Tor host a web protocol (e.g. "http", "ws") + const torOrigin1 = torHost1.createOrigin('http') - // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8443, 443) - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOrigin2 = torHost2.createOrigin('https') + // Create another Tor host with the assigned port mapping + const torHost2 = await torHostname1.bindTor(8443, 443) + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOrigin2 = torHost2.createOrigin('https') - // ------------ LAN ------------ + // ------------ LAN ------------ - // Create a LAN host with the assigned internal port - const lanHost1 = await utils.bindLan(8080) - // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOrigins1 = lanHost1.createOrigins('https') + // Create a LAN host with the assigned internal port + const lanHost1 = await utils.bindLan(8080) + // Assign the LAN host a web protocol (e.g. "https", "wss") + const lanOrigins1 = lanHost1.createOrigins('https') - // ------------ Interface ---------------- + // ------------ Interface ---------------- - // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). - // Addresses are different "routes" to the same destination + // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). + // Addresses are different "routes" to the same destination - // Define the Interface for user display and consumption - const iFace1 = new NetworkInterfaceBuilder({ - effects, - name: 'Web UI', - id: 'webui', - description: 'The web interface of Hello World', - ui: true, - basic: null, - path: '', - search: {}, - }) + // Define the Interface for user display and consumption + const iFace1 = new NetworkInterfaceBuilder({ + effects, + name: 'Web UI', + id: 'webui', + description: 'The web interface of Hello World', + ui: true, + basic: null, + path: '', + search: {}, + }) - // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const addressReceipt1 = await iFace1.exportAddresses([ - torOrigin1, - torOrigin2, - lanOrigins1.ip, - lanOrigins1.local, - ]) + // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) + const addressReceipt1 = await iFace1.exportAddresses([ + torOrigin1, + torOrigin2, + lanOrigins1.ip, + lanOrigins1.local, + ]) - // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(addressReceipt1) + // Export all address receipts for all interfaces to obtain interface receipt + const interfaceReceipt = exportInterfaces(addressReceipt1) - /** - * ======================== Additional Health Checks (optional) ======================== - * - * In this section, you will define additional health checks beyond those associated with daemons - */ - const healthReceipts: HealthReceipt[] = [] + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define additional health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] - /** - * ======================== Daemons ======================== - * - * In this section, you will create one or more daemons that define the service runtime - * - * Each daemon defines its own health check, which can optionally be exposed to the user - */ - return Daemons.of({ - effects, - started, - interfaceReceipt, // Provide the interfaceReceipt to prove it was completed - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered - }).addDaemon({ - id: 'webui', // The ID of the daemon - command: 'hello-world', // The command to start the daemon - ready: { - display: 'Web Interface', - // The function to run to determine the health status of the daemon - fn: () => checkPortListening(effects, 8080, { - timeout: 10_000, - successMessage: 'The web interface is ready', - }), - }, - }) -}) + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return Daemons.of({ + effects, + started, + interfaceReceipt, // Provide the interfaceReceipt to prove it was completed + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon({ + id: 'webui', // The ID of the daemon + command: 'hello-world', // The command to start the daemon + ready: { + display: 'Web Interface', + // The function to run to determine the health status of the daemon + fn: () => + checkPortListening(effects, 8080, { + timeout: 10_000, + successMessage: 'The web interface is ready', + }), + }, + }) + }, +) diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index c0e9da9..41b26d4 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -5,6 +5,4 @@ import { v4_0_0 } from './v4_0_0' /** * Add each new migration as the next argument to this function */ -export const migrations = setupMigrations(manifest, - v4_0_0, -) \ No newline at end of file +export const migrations = setupMigrations(manifest, v4_0_0) diff --git a/startos/procedures/migrations/v4_0_0.ts b/startos/procedures/migrations/v4_0_0.ts index 3b008f7..955b3dc 100644 --- a/startos/procedures/migrations/v4_0_0.ts +++ b/startos/procedures/migrations/v4_0_0.ts @@ -1,14 +1,14 @@ -import { Migration } from "start-sdk/lib/inits/migrations/Migration"; +import { Migration } from 'start-sdk/lib/inits/migrations/Migration' /** * This is an example migration file - * + * * By convention, each version service requiring a migration receives its own file - * + * * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts */ export const v4_0_0 = new Migration({ version: '4.0.0', up: async ({ effects }) => await effects.setConfigured(false), - down: async ({ effects }) => {} + down: async ({ effects }) => {}, }) diff --git a/startos/wrapperData.ts b/startos/wrapperData.ts index c07824e..7e9d3c5 100644 --- a/startos/wrapperData.ts +++ b/startos/wrapperData.ts @@ -1,10 +1,10 @@ /** * Here you define the set of data that the service wrapper will persist for self consumption and for exporting to users and other services - * + * * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords -*/ + */ export interface WrapperData { config: { name: string } -} \ No newline at end of file +} From e8148eb9ca00e7057d13f283498c9c23cf59be25 Mon Sep 17 00:00:00 2001 From: BluJ Date: Thu, 27 Apr 2023 13:01:32 -0600 Subject: [PATCH 013/120] chore: Update to rc2 --- package-lock.json | 8 +- package.json | 2 +- startos/manifest.ts | 7 +- startos/procedures/actions/nameToLogs.ts | 20 +-- startos/procedures/backups.ts | 1 - startos/procedures/config/index.ts | 7 +- startos/procedures/config/read.ts | 7 +- startos/procedures/config/save.ts | 5 +- startos/procedures/config/spec.ts | 19 ++- startos/procedures/main.ts | 176 +++++++++++------------ 10 files changed, 130 insertions(+), 122 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4764b5b..26090a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.rc1" + "start-sdk": "0.4.0-lib0.rc2" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.rc1", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc1.tgz", - "integrity": "sha512-jx8VB+Qyt6VqisfC3XE1ERIkKZ7o7wWWdymeDC8jmzR4GZhdpU3TxX42Jmon5uU4FESeVcixQL0dv2KLHlORig==", + "version": "0.4.0-lib0.rc2", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc2.tgz", + "integrity": "sha512-hT9MbMGzbU7rrVX4Vo/iWShtjOMBvRyeO6q23+HWH+8JrTYP2kCdCDrSkFk1TXtuNZ4gFhjGFF9eczjAdG2SeQ==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index 25afdd0..5b517d9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.rc1" + "start-sdk": "0.4.0-lib0.rc2" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index 54e04e9..32559e8 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,9 +1,9 @@ import { setupManifest } from 'start-sdk/lib/manifest' import { actionsMetadata } from './procedures/actions' -/** +/** * In this function you define static properties of the service -*/ + */ export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', @@ -45,7 +45,8 @@ export const manifest = setupManifest({ install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', uninstall: 'Optional alert to display before uninstalling the service', - restore: 'Optional alert to display before restoring the service from backup', + restore: + 'Optional alert to display before restoring the service from backup', start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index d7ff46c..0e6e914 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -4,9 +4,9 @@ import { createAction } from 'start-sdk/lib/actions/createAction' /** * This is an example Action - * + * * By convention, each action receives its own file - * + * * Actions optionally take an arbitrary config form as input */ const input = Config.of({ @@ -14,16 +14,14 @@ const input = Config.of({ name: 'Temp Name', description: 'If no name is provided, the name from config will be used', required: false, - default: null, - patterns: [], }), }) /** * This function defines the Action, including the FormSpec (if any) - * + * * The first argument is the Action metadata. The second argument is the Action function - * + * * If no input is required, FormSpec would be null */ export const nameToLogs = createAction( @@ -35,15 +33,17 @@ export const nameToLogs = createAction( runningOnly: false, }, async ({ effects, utils, input }) => { - const name = input.nameToPrint || (await utils.getWrapperData('/config/name').first()) - effects.info(`Hello ${name}`) + const name = + input.nameToPrint || + (await utils.getOwnWrapperData('/config/name').once()) + effects.console.log(`Hello ${name}`) return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, value: { - value: null, + value: name, copyable: true, qr: false, - } + }, } }, ) diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index b4181eb..24a3996 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,6 +1,5 @@ import { setupBackups } from 'start-sdk/lib/backup' import { Manifest } from '../manifest' - /** * Here we define what volumes from the Manifest to include in backups */ diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 7e28650..1ab29a6 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -3,8 +3,13 @@ import { configSpec } from './spec' import { read } from './read' import { save } from './save' import { setupConfig } from 'start-sdk/lib/config' +import { Manifest } from '../../manifest' /** * This is a static file. There is no need to make changes here */ -export const { getConfig, setConfig } = setupConfig(configSpec, save, read) +export const { getConfig, setConfig } = setupConfig< + WrapperData, + typeof configSpec, + Manifest +>(configSpec, save, read) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 9b1c2e2..8eb42c2 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -7,6 +7,9 @@ import { Read } from 'start-sdk/lib/config/setupConfig' * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read: Read = async ({ effects, utils }) => { - return utils.getWrapperData('/config').first() +export const read: Read = async ({ + effects, + utils, +}) => { + return utils.getOwnWrapperData('/config').once() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index cf61388..6ab365b 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,10 +1,11 @@ import { ConfigSpec } from './spec' import { WrapperData } from '../../wrapperData' import { Save } from 'start-sdk/lib/config/setupConfig' +import { Manifest } from '../../manifest' /** * This function executes on config save - * + * * Use it to persist config data to various files and to establish any resulting dependencies */ export const save: Save = async ({ @@ -13,6 +14,6 @@ export const save: Save = async ({ input, dependencies, }) => { - await utils.setWrapperData('/config', input) + await utils.setOwnWrapperData('/config', input) return effects.setDependencies([]) } diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index c7b144f..3f8fd6c 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,19 +1,18 @@ -import { configBuilder } from "start-sdk/lib" +import { configBuilder } from 'start-sdk/lib' const { Config, Value } = configBuilder /** * Here you define the config specification that will ultimately present to the user as validated form inputs - * + * * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) -*/ + */ export const configSpec = Config.of({ - name: Value.text( - { - name: "Name", - description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: true, - }, - ), + name: Value.text({ + name: 'Name', + description: + 'When you launch the Hello World UI, it will display "Hello [First Name]"', + required: { default: null }, + }), }) // These two lines are necessary to satisfy Typescript typings. Do not touch them export const matchConfigSpec = configSpec.validator() diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 8b15322..9778d5b 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -9,105 +9,105 @@ import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from 'start-sdk/lib/types' import { WrapperData } from '../wrapperData' -export const main: ExpectedExports.main = setupMain(async ({ - effects, - utils, - started -}) => { - /** - * ======================== Setup ======================== - * - * In this section, you will fetch any resources or run any commands necessary to run the service - */ - await effects.console.info('Starting Hello World!') +export const main: ExpectedExports.main = setupMain( + async ({ effects, utils, started }) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + await effects.console.info('Starting Hello World!') - /** - * ======================== Interfaces ======================== - * - * In this section, you will decide how the service will be exposed to the outside world - * - * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location - */ + /** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + * + * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location + */ - // ------------ Tor ------------ + // ------------ Tor ------------ - // Find or generate a random Tor hostname by ID - const torHostname1 = utils.torHostName('torHostname1') + // Find or generate a random Tor hostname by ID + const torHostname1 = utils.torHostName('torHostname1') - // Create a Tor host with the assigned port mapping - const torHost1 = await torHostname1.bindTor(8080, 80) - // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOrigin1 = torHost1.createOrigin('http') + // Create a Tor host with the assigned port mapping + const torHost1 = await torHostname1.bindTor(8080, 80) + // Assign the Tor host a web protocol (e.g. "http", "ws") + const torOrigin1 = torHost1.createOrigin('http') - // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8443, 443) - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOrigin2 = torHost2.createOrigin('https') + // Create another Tor host with the assigned port mapping + const torHost2 = await torHostname1.bindTor(8443, 443) + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOrigin2 = torHost2.createOrigin('https') - // ------------ LAN ------------ + // ------------ LAN ------------ - // Create a LAN host with the assigned internal port - const lanHost1 = await utils.bindLan(8080) - // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOrigins1 = lanHost1.createOrigins('https') + // Create a LAN host with the assigned internal port + const lanHost1 = await utils.bindLan(8080) + // Assign the LAN host a web protocol (e.g. "https", "wss") + const lanOrigins1 = lanHost1.createOrigins('https') - // ------------ Interface ---------------- + // ------------ Interface ---------------- - // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). - // Addresses are different "routes" to the same destination + // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). + // Addresses are different "routes" to the same destination - // Define the Interface for user display and consumption - const iFace1 = new NetworkInterfaceBuilder({ - effects, - name: 'Web UI', - id: 'webui', - description: 'The web interface of Hello World', - ui: true, - basic: null, - path: '', - search: {}, - }) + // Define the Interface for user display and consumption + const iFace1 = new NetworkInterfaceBuilder({ + effects, + name: 'Web UI', + id: 'webui', + description: 'The web interface of Hello World', + ui: true, + basic: null, + path: '', + search: {}, + }) - // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const addressReceipt1 = await iFace1.exportAddresses([ - torOrigin1, - torOrigin2, - lanOrigins1.ip, - lanOrigins1.local, - ]) + // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) + const addressReceipt1 = await iFace1.exportAddresses([ + torOrigin1, + torOrigin2, + ...lanOrigins1.ip, + lanOrigins1.local, + ]) - // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(addressReceipt1) + // Export all address receipts for all interfaces to obtain interface receipt + const interfaceReceipt = exportInterfaces(addressReceipt1) - /** - * ======================== Additional Health Checks (optional) ======================== - * - * In this section, you will define additional health checks beyond those associated with daemons - */ - const healthReceipts: HealthReceipt[] = [] + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define additional health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] - /** - * ======================== Daemons ======================== - * - * In this section, you will create one or more daemons that define the service runtime - * - * Each daemon defines its own health check, which can optionally be exposed to the user - */ - return Daemons.of({ - effects, - started, - interfaceReceipt, // Provide the interfaceReceipt to prove it was completed - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered - }).addDaemon({ - id: 'webui', // The ID of the daemon - command: 'hello-world', // The command to start the daemon - ready: { - display: 'Web Interface', - // The function to run to determine the health status of the daemon - fn: () => checkPortListening(effects, 8080, { - timeout: 10_000, - successMessage: 'The web interface is ready', - }), - }, - }) -}) + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return Daemons.of({ + effects, + started, + interfaceReceipt, // Provide the interfaceReceipt to prove it was completed + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon('webui', { + command: 'hello-world', // The command to start the daemon + ready: { + display: 'Web Interface', + // The function to run to determine the health status of the daemon + fn: () => + checkPortListening(effects, 8080, { + timeout: 10_000, + successMessage: 'The web interface is ready', + errorMessage: 'The web interface is not ready', + }), + }, + requires: [], + }) + }, +) From 5ad1547fc57661582918060a19c2c51450a11642 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 27 Apr 2023 14:57:32 -0600 Subject: [PATCH 014/120] rc3 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 26090a8..98f76fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.rc2" + "start-sdk": "0.4.0-lib0.rc3" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -56,9 +56,9 @@ } }, "node_modules/start-sdk": { - "version": "0.4.0-lib0.rc2", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc2.tgz", - "integrity": "sha512-hT9MbMGzbU7rrVX4Vo/iWShtjOMBvRyeO6q23+HWH+8JrTYP2kCdCDrSkFk1TXtuNZ4gFhjGFF9eczjAdG2SeQ==", + "version": "0.4.0-lib0.rc3", + "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc3.tgz", + "integrity": "sha512-PAExAKEw0AUhk0UYu25o/UfAwclLt8tvQIDqzv4MaiFg4stPSzWYyFFBBX2kIKlBDlIMlzC6Fj0/8qoxzqq8iQ==", "dependencies": { "@iarna/toml": "^2.2.5", "deepmerge": "^4.3.1", diff --git a/package.json b/package.json index 38bdbbc..68871f6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.rc2" + "start-sdk": "0.4.0-lib0.rc3" }, "devDependencies": { "@vercel/ncc": "^0.36.1", From 85196395a463acf4ba4b783382d69e8ddc8ced8f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 29 Apr 2023 20:21:28 -0600 Subject: [PATCH 015/120] use configspec type in wrapper data --- startos/wrapperData.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/startos/wrapperData.ts b/startos/wrapperData.ts index 7e9d3c5..0379908 100644 --- a/startos/wrapperData.ts +++ b/startos/wrapperData.ts @@ -1,10 +1,10 @@ +import { ConfigSpec } from './procedures/config/spec' + /** * Here you define the set of data that the service wrapper will persist for self consumption and for exporting to users and other services * * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords */ export interface WrapperData { - config: { - name: string - } + config: ConfigSpec } From 596a684703c923a563355b6babdcc7f47ab3b945 Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Mon, 1 May 2023 18:11:13 +0200 Subject: [PATCH 016/120] Update Makefile --- Makefile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2d6e598..61cb38a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -PKG_ID := $(shell yq e ".id" manifest.yaml) -PKG_VERSION := $(shell yq e ".version" manifest.yaml) +PKG_ID := $(shell grep ".id:" startos/manifest.ts | grep -o "'[^']*'" | sed "s/'//g") +PKG_VERSION := $(shell grep ".version:" startos/manifest.ts | grep -o "'[^']*'" | sed "s/'//g") TS_FILES := $(shell find ./ -name \*.ts) HELLO_WORLD_SRC := $(shell find ./hello-world/src) hello-world/Cargo.toml hello-world/Cargo.lock # delete the target of a rule if it has changed and its recipe exits with a nonzero exit status .DELETE_ON_ERROR: -all: verify +all: submodule-update verify verify: $(PKG_ID).s9pk @embassy-sdk verify s9pk $(PKG_ID).s9pk @@ -22,13 +22,16 @@ endif clean: rm -rf docker-images - rm -f image.tar rm -f $(PKG_ID).s9pk rm -f scripts/*.js -clean-manifest: - @sed -i '' '/^[[:blank:]]*#/d;s/#.*//' manifest.yaml - @echo; echo "Comments successfully removed from manifest.yaml file."; echo +submodule-update: + @if [ -z "$(shell git submodule status | egrep -v '^ '|awk '{print $$2}')" ]; then \ + echo "Submodules are up to date."; \ + else \ + echo "\nUpdating submodules...\n"; \ + git submodule update --init --progress; \ + fi # BEGIN REBRANDING rebranding: @@ -44,6 +47,14 @@ rebranding: scripts/embassy.js: $(TS_FILES) deno bundle scripts/embassy.ts scripts/embassy.js +arm: + @rm -f docker-images/x86_64.tar + ARCH=aarch64 $(MAKE) + +x86: + @rm -f docker-images/aarch64.tar + ARCH=x86_64 $(MAKE) + docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh hello-world/target/aarch64-unknown-linux-musl/release/hello-world ifeq ($(ARCH),x86_64) else @@ -58,7 +69,7 @@ else docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --build-arg ARCH=x86_64 --platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar . endif -$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar +$(PKG_ID).s9pk: assets/instructions.md assets/icon.png LICENSE scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar ifeq ($(ARCH),aarch64) @echo "embassy-sdk: Preparing aarch64 package ..." else ifeq ($(ARCH),x86_64) From 1708d7e99fbb5dc6ee00570822a98449f17f9d40 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 2 May 2023 09:17:28 -0600 Subject: [PATCH 017/120] chore: update to use latest of sdk --- package-lock.json | 21 +++------------------ package.json | 2 +- startos/procedures/actions/nameToLogs.ts | 2 +- startos/procedures/config/index.ts | 2 +- startos/procedures/config/spec.ts | 5 +++-- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 98f76fa..eeb4794 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "0.4.0-lib0.rc3" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#3547cb6" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -27,19 +27,6 @@ "ncc": "dist/ncc/cli.js" } }, - "node_modules/deepmerge": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" - }, "node_modules/prettier": { "version": "2.8.7", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", @@ -57,12 +44,10 @@ }, "node_modules/start-sdk": { "version": "0.4.0-lib0.rc3", - "resolved": "https://registry.npmjs.org/start-sdk/-/start-sdk-0.4.0-lib0.rc3.tgz", - "integrity": "sha512-PAExAKEw0AUhk0UYu25o/UfAwclLt8tvQIDqzv4MaiFg4stPSzWYyFFBBX2kIKlBDlIMlzC6Fj0/8qoxzqq8iQ==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#3547cb67cca7505e2f20f250eb24fecdd21cf535", + "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", - "deepmerge": "^4.3.1", - "lodash": "^4.17.21", "ts-matches": "^5.4.1", "yaml": "^2.2.1" } diff --git a/package.json b/package.json index 68871f6..489f63c 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "0.4.0-lib0.rc3" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#3547cb6" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 0e6e914..7de65cc 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -9,7 +9,7 @@ import { createAction } from 'start-sdk/lib/actions/createAction' * * Actions optionally take an arbitrary config form as input */ -const input = Config.of({ +const input = Config.withWrapperData().of({ nameToPrint: Value.text({ name: 'Temp Name', description: 'If no name is provided, the name from config will be used', diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 1ab29a6..9ebb335 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,5 +1,5 @@ import { WrapperData } from '../../wrapperData' -import { configSpec } from './spec' +import { ConfigSpec, configSpec } from './spec' import { read } from './read' import { save } from './save' import { setupConfig } from 'start-sdk/lib/config' diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 3f8fd6c..f04bd50 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,4 +1,5 @@ import { configBuilder } from 'start-sdk/lib' +import { WrapperData } from '../../wrapperData' const { Config, Value } = configBuilder /** @@ -6,7 +7,7 @@ const { Config, Value } = configBuilder * * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) */ -export const configSpec = Config.of({ +export const configSpec = Config.withWrapperData().of({ name: Value.text({ name: 'Name', description: @@ -15,5 +16,5 @@ export const configSpec = Config.of({ }), }) // These two lines are necessary to satisfy Typescript typings. Do not touch them -export const matchConfigSpec = configSpec.validator() +export const matchConfigSpec = configSpec.validator export type ConfigSpec = typeof matchConfigSpec._TYPE From e9330577b4588035aca798da1b04011e8f0fedd3 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 2 May 2023 17:04:56 -0600 Subject: [PATCH 018/120] update to latest --- package-lock.json | 5 +++-- package.json | 2 +- startos/procedures/actions/nameToLogs.ts | 4 +++- startos/procedures/config/index.ts | 2 +- startos/procedures/config/save.ts | 7 ++++++- startos/procedures/config/spec.ts | 11 +++++------ startos/procedures/main.ts | 6 ------ startos/procedures/properties.ts | 6 +++++- 8 files changed, 24 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index eeb4794..5da3730 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#3547cb6" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -44,7 +44,8 @@ }, "node_modules/start-sdk": { "version": "0.4.0-lib0.rc3", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#3547cb67cca7505e2f20f250eb24fecdd21cf535", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b", + "integrity": "sha512-fESJtsaN3+shMLLQHmPsxTQgMUeVmRwDvf6E1RbHp68uzMZF3Mf3DqLci7GtiICFNDRhE2GC0zR0ltX3uo/y7A==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 489f63c..67056ad 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#3547cb6" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 7de65cc..f22e3b3 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -36,7 +36,9 @@ export const nameToLogs = createAction( const name = input.nameToPrint || (await utils.getOwnWrapperData('/config/name').once()) - effects.console.log(`Hello ${name}`) + + await effects.console.log(`Hello ${name}`) + return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, value: { diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 9ebb335..1ab29a6 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,5 +1,5 @@ import { WrapperData } from '../../wrapperData' -import { ConfigSpec, configSpec } from './spec' +import { configSpec } from './spec' import { read } from './read' import { save } from './save' import { setupConfig } from 'start-sdk/lib/config' diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 6ab365b..c41fcfa 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -15,5 +15,10 @@ export const save: Save = async ({ dependencies, }) => { await utils.setOwnWrapperData('/config', input) - return effects.setDependencies([]) + const dependenciesReceipt = await effects.setDependencies([]) + + return { + dependenciesReceipt, + restart: true, + } } diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index f04bd50..6320911 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,13 +1,12 @@ -import { configBuilder } from 'start-sdk/lib' +import { Value, topConfig } from 'start-sdk/lib/config/builder' import { WrapperData } from '../../wrapperData' -const { Config, Value } = configBuilder /** * Here you define the config specification that will ultimately present to the user as validated form inputs * * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) */ -export const configSpec = Config.withWrapperData().of({ +export const configSpec = topConfig()({ name: Value.text({ name: 'Name', description: @@ -15,6 +14,6 @@ export const configSpec = Config.withWrapperData().of({ required: { default: null }, }), }) -// These two lines are necessary to satisfy Typescript typings. Do not touch them -export const matchConfigSpec = configSpec.validator -export type ConfigSpec = typeof matchConfigSpec._TYPE + +// This line is necessary to satisfy Typescript typings. Do not touch it +export type ConfigSpec = typeof configSpec.validator._TYPE diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 9778d5b..ba3ccb6 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -36,11 +36,6 @@ export const main: ExpectedExports.main = setupMain( // Assign the Tor host a web protocol (e.g. "http", "ws") const torOrigin1 = torHost1.createOrigin('http') - // Create another Tor host with the assigned port mapping - const torHost2 = await torHostname1.bindTor(8443, 443) - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOrigin2 = torHost2.createOrigin('https') - // ------------ LAN ------------ // Create a LAN host with the assigned internal port @@ -68,7 +63,6 @@ export const main: ExpectedExports.main = setupMain( // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) const addressReceipt1 = await iFace1.exportAddresses([ torOrigin1, - torOrigin2, ...lanOrigins1.ip, lanOrigins1.local, ]) diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index 052485b..85ad413 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -1,4 +1,8 @@ -import { PropertyString, setupProperties } from 'start-sdk/lib/properties' +import { + PropertyGroup, + PropertyString, + setupProperties, +} from 'start-sdk/lib/properties' import { WrapperData } from '../wrapperData' /** From ba68ea30afda6e893873f147ec568cecd9476a44 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 3 May 2023 07:59:50 -0600 Subject: [PATCH 019/120] update to latest --- package-lock.json | 6 +++--- package.json | 2 +- startos/manifest.ts | 2 +- startos/procedures/actions/nameToLogs.ts | 5 +++-- startos/procedures/autoConfig.ts | 2 +- startos/procedures/backups.ts | 2 +- startos/procedures/config/index.ts | 2 +- startos/procedures/config/spec.ts | 5 +++-- startos/procedures/init.ts | 4 +++- startos/procedures/main.ts | 10 ++++------ startos/procedures/properties.ts | 7 ++----- 11 files changed, 23 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5da3730..ed20399 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -44,8 +44,8 @@ }, "node_modules/start-sdk": { "version": "0.4.0-lib0.rc3", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b", - "integrity": "sha512-fESJtsaN3+shMLLQHmPsxTQgMUeVmRwDvf6E1RbHp68uzMZF3Mf3DqLci7GtiICFNDRhE2GC0zR0ltX3uo/y7A==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9", + "integrity": "sha512-uXhL9KTeQvETL2bFzUvpNjQJTPKRaKf4nZtUjQ5XSxS0r+TMZKF6E0yQvQPhn6FmZbyJV4rWW92B9uKzkySBUA==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 67056ad..4fef405 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#29a0bf4981792f5e6afa9b72a91d9af582864f7b" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index 32559e8..3296937 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,4 +1,4 @@ -import { setupManifest } from 'start-sdk/lib/manifest' +import { setupManifest } from 'start-sdk/lib/manifest/setupManifest' import { actionsMetadata } from './procedures/actions' /** diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index f22e3b3..a8205ee 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -1,6 +1,7 @@ -import { Config, Value } from 'start-sdk/lib/config/builder' +import { Config } from 'start-sdk/lib/config/builder/config' import { WrapperData } from '../../wrapperData' import { createAction } from 'start-sdk/lib/actions/createAction' +import { Value } from 'start-sdk/lib/config/builder/value' /** * This is an example Action @@ -9,7 +10,7 @@ import { createAction } from 'start-sdk/lib/actions/createAction' * * Actions optionally take an arbitrary config form as input */ -const input = Config.withWrapperData().of({ +const input = Config.of({ nameToPrint: Value.text({ name: 'Temp Name', description: 'If no name is provided, the name from config will be used', diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 37a2d93..d5bcac1 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,7 +1,7 @@ -import { setupAutoConfig } from 'start-sdk/lib/autoconfig' import { ConfigSpec } from './config/spec' import { WrapperData } from '../wrapperData' import { Manifest } from '../manifest' +import { setupAutoConfig } from 'start-sdk/lib/autoconfig/setupAutoConfig' /** * In this function, you establish rules for auto configuring service dependencies diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 24a3996..68119cc 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,4 +1,4 @@ -import { setupBackups } from 'start-sdk/lib/backup' +import { setupBackups } from 'start-sdk/lib/backup/setupBackups' import { Manifest } from '../manifest' /** * Here we define what volumes from the Manifest to include in backups diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 1ab29a6..a01e259 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -2,8 +2,8 @@ import { WrapperData } from '../../wrapperData' import { configSpec } from './spec' import { read } from './read' import { save } from './save' -import { setupConfig } from 'start-sdk/lib/config' import { Manifest } from '../../manifest' +import setupConfig from 'start-sdk/lib/config/setupConfig' /** * This is a static file. There is no need to make changes here diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 6320911..7ab8817 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,12 +1,13 @@ -import { Value, topConfig } from 'start-sdk/lib/config/builder' +import { Config } from 'start-sdk/lib/config/builder/config' import { WrapperData } from '../../wrapperData' +import { Value } from 'start-sdk/lib/config/builder/value' /** * Here you define the config specification that will ultimately present to the user as validated form inputs * * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) */ -export const configSpec = topConfig()({ +export const configSpec = Config.of({ name: Value.text({ name: 'Name', description: diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index a4ae1b2..5dcc475 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,6 +1,8 @@ -import { setupInit, setupInstall, setupUninstall } from 'start-sdk/lib/inits' +import { setupInstall } from 'start-sdk/lib/inits/setupInstall' import { WrapperData } from '../wrapperData' import { migrations } from './migrations' +import { setupUninstall } from 'start-sdk/lib/inits/setupUninstall' +import { setupInit } from 'start-sdk/lib/inits/setupInit' /** * Here you define arbitrary code that runs once, on fresh install only diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index ba3ccb6..4134423 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,13 +1,11 @@ -import { HealthReceipt } from 'start-sdk/lib/health' import { checkPortListening } from 'start-sdk/lib/health/checkFns' -import { - Daemons, - NetworkInterfaceBuilder, - setupMain, -} from 'start-sdk/lib/mainFn' +import { setupMain } from 'start-sdk/lib/mainFn' import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from 'start-sdk/lib/types' import { WrapperData } from '../wrapperData' +import { NetworkInterfaceBuilder } from 'start-sdk/lib/mainFn/NetworkInterfaceBuilder' +import { HealthReceipt } from 'start-sdk/lib/health/HealthReceipt' +import { Daemons } from 'start-sdk/lib/mainFn/Daemons' export const main: ExpectedExports.main = setupMain( async ({ effects, utils, started }) => { diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index 85ad413..c8e5660 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -1,9 +1,6 @@ -import { - PropertyGroup, - PropertyString, - setupProperties, -} from 'start-sdk/lib/properties' +import { setupProperties } from 'start-sdk/lib/properties' import { WrapperData } from '../wrapperData' +import { PropertyString } from 'start-sdk/lib/properties/PropertyString' /** * With access to WrapperData, in this function you determine what to include in the Properties section of the UI From a7a9921e04f3418988b0b687a8d87961aca83994 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 3 May 2023 11:34:16 -0600 Subject: [PATCH 020/120] reverse proxy WIP --- startos/procedures/main.ts | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 4134423..24ebbbd 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -24,22 +24,40 @@ export const main: ExpectedExports.main = setupMain( * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location */ + // ------------ Reverse Proxy ---------------- + + // set up a reverse proxy to enable https for Tor/LAN + await effects.reverseProxy({ + bind: { + port: 443, + ssl: true, + }, + dst: { + port: 80, + ssl: false, + }, + }) + // ------------ Tor ------------ // Find or generate a random Tor hostname by ID - const torHostname1 = utils.torHostName('torHostname1') + const torHostname = utils.torHostName('torHostname') // Create a Tor host with the assigned port mapping - const torHost1 = await torHostname1.bindTor(8080, 80) + const torHostTcp = await torHostname.bindTor(80, 80) // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOrigin1 = torHost1.createOrigin('http') + const torOriginHttp = torHostTcp.createOrigin('http') + // Create a Tor host with the assigned port mapping + const torHostSsl = await torHostname.bindTor(443, 443) + // Assign the Tor host a web protocol (e.g. "https", "wss") + const torOriginHttps = torHostSsl.createOrigin('https') // ------------ LAN ------------ // Create a LAN host with the assigned internal port - const lanHost1 = await utils.bindLan(8080) + const lanHostSsl = await utils.bindLan(443) // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOrigins1 = lanHost1.createOrigins('https') + const lanOriginsHttps = lanHostSsl.createOrigins('https') // ------------ Interface ---------------- @@ -47,7 +65,7 @@ export const main: ExpectedExports.main = setupMain( // Addresses are different "routes" to the same destination // Define the Interface for user display and consumption - const iFace1 = new NetworkInterfaceBuilder({ + const webInterface = new NetworkInterfaceBuilder({ effects, name: 'Web UI', id: 'webui', @@ -59,14 +77,15 @@ export const main: ExpectedExports.main = setupMain( }) // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const addressReceipt1 = await iFace1.exportAddresses([ - torOrigin1, - ...lanOrigins1.ip, - lanOrigins1.local, + const webReceipt = await webInterface.exportAddresses([ + torOriginHttp, + torOriginHttps, + ...lanOriginsHttps.ip, + lanOriginsHttps.local, ]) // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(addressReceipt1) + const interfaceReceipt = exportInterfaces(webReceipt) /** * ======================== Additional Health Checks (optional) ======================== @@ -93,8 +112,7 @@ export const main: ExpectedExports.main = setupMain( display: 'Web Interface', // The function to run to determine the health status of the daemon fn: () => - checkPortListening(effects, 8080, { - timeout: 10_000, + checkPortListening(effects, 80, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), From d5d2811c8962dad9bd26eb56f8bb1099d6406545 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 3 May 2023 11:38:04 -0600 Subject: [PATCH 021/120] update sdk --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index ed20399..1548421 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -44,8 +44,8 @@ }, "node_modules/start-sdk": { "version": "0.4.0-lib0.rc3", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9", - "integrity": "sha512-uXhL9KTeQvETL2bFzUvpNjQJTPKRaKf4nZtUjQ5XSxS0r+TMZKF6E0yQvQPhn6FmZbyJV4rWW92B9uKzkySBUA==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb", + "integrity": "sha512-0ABSpsuvOGRVv58FT8rP9vZlwAx/DcjI3C4ikJ//KtDgJwcTXuNdIvih03AOR/sdjoh11u6gCkJO9uFGbPnj0g==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 4fef405..6222a84 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#31c2131ca990072361751ca961b816c43c21e5e9" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb" }, "devDependencies": { "@vercel/ncc": "^0.36.1", From ea6263b9223418ed171484707e25dedb02726cda Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 3 May 2023 13:27:44 -0600 Subject: [PATCH 022/120] error free --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1548421..afa29ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -44,8 +44,8 @@ }, "node_modules/start-sdk": { "version": "0.4.0-lib0.rc3", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb", - "integrity": "sha512-0ABSpsuvOGRVv58FT8rP9vZlwAx/DcjI3C4ikJ//KtDgJwcTXuNdIvih03AOR/sdjoh11u6gCkJO9uFGbPnj0g==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb", + "integrity": "sha512-/1fYxuSsCBsFz3vqjzr7pn9QjumVK4GURF2LeJ9FBud2t0e3hK2P0RmuqOXLLSvq69DEDxcWlQJjQN7IzTaCmw==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 6222a84..25885b7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#f4c93438f8a4d0e8f57024898f450c63b14554fb" + "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb" }, "devDependencies": { "@vercel/ncc": "^0.36.1", From 3695aff09f1fe2acf93bc1d3ba70dc43ff999167 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 3 May 2023 20:43:58 -0600 Subject: [PATCH 023/120] switch to startlabs sdk --- package-lock.json | 23 +++++++-------- package.json | 2 +- startos/manifest.ts | 2 +- startos/procedures/actions/index.ts | 2 +- startos/procedures/actions/nameToLogs.ts | 6 ++-- startos/procedures/autoConfig.ts | 2 +- startos/procedures/backups.ts | 2 +- startos/procedures/config/index.ts | 2 +- startos/procedures/config/read.ts | 2 +- startos/procedures/config/save.ts | 2 +- startos/procedures/config/spec.ts | 4 +-- startos/procedures/init.ts | 6 ++-- startos/procedures/main.ts | 16 +++++----- startos/procedures/migrations/index.ts | 2 +- startos/procedures/migrations/v4_0_0.ts | 2 +- startos/procedures/properties.ts | 37 ++++++++++++++---------- 16 files changed, 59 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index afa29ce..0e1b89f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc1" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -18,6 +18,16 @@ "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, + "node_modules/@start9labs/start-sdk": { + "version": "0.4.0-rev0.lib0.rc1", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc1.tgz", + "integrity": "sha512-0+7yCu25RLgNhJnGJue24VIO542aCcVgYoVIUvjgufgkmu3MqhbO+JUd84QMYeDeNaAi/WY3xbPpvqv+XLxw0g==", + "dependencies": { + "@iarna/toml": "^2.2.5", + "ts-matches": "^5.4.1", + "yaml": "^2.2.1" + } + }, "node_modules/@vercel/ncc": { "version": "0.36.1", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", @@ -42,17 +52,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/start-sdk": { - "version": "0.4.0-lib0.rc3", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb", - "integrity": "sha512-/1fYxuSsCBsFz3vqjzr7pn9QjumVK4GURF2LeJ9FBud2t0e3hK2P0RmuqOXLLSvq69DEDxcWlQJjQN7IzTaCmw==", - "license": "MIT", - "dependencies": { - "@iarna/toml": "^2.2.5", - "ts-matches": "^5.4.1", - "yaml": "^2.2.1" - } - }, "node_modules/ts-matches": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", diff --git a/package.json b/package.json index 25885b7..782229a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "start-sdk": "git+https://github.com/Start9Labs/start-sdk.git#185e34bcd17e91820b6f3dbd6b5a42edc9428bbb" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc1" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/manifest.ts b/startos/manifest.ts index 3296937..ed04f3d 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,4 +1,4 @@ -import { setupManifest } from 'start-sdk/lib/manifest/setupManifest' +import { setupManifest } from '@start9labs/start-sdk/lib/manifest/setupManifest' import { actionsMetadata } from './procedures/actions' /** diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 1897f90..428e06f 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,5 +1,5 @@ import { nameToLogs } from './nameToLogs' -import { setupActions } from 'start-sdk/lib/actions/setupActions' +import { setupActions } from '@start9labs/start-sdk/lib/actions/setupActions' /** * Add each new Action as the next argument to this function diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index a8205ee..a80ef80 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -1,7 +1,7 @@ -import { Config } from 'start-sdk/lib/config/builder/config' +import { Config } from '@start9labs/start-sdk/lib/config/builder/config' import { WrapperData } from '../../wrapperData' -import { createAction } from 'start-sdk/lib/actions/createAction' -import { Value } from 'start-sdk/lib/config/builder/value' +import { createAction } from '@start9labs/start-sdk/lib/actions/createAction' +import { Value } from '@start9labs/start-sdk/lib/config/builder/value' /** * This is an example Action diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index d5bcac1..52e61bf 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,7 +1,7 @@ import { ConfigSpec } from './config/spec' import { WrapperData } from '../wrapperData' import { Manifest } from '../manifest' -import { setupAutoConfig } from 'start-sdk/lib/autoconfig/setupAutoConfig' +import { setupAutoConfig } from '@start9labs/start-sdk/lib/autoconfig/setupAutoConfig' /** * In this function, you establish rules for auto configuring service dependencies diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 68119cc..346fa6f 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,4 +1,4 @@ -import { setupBackups } from 'start-sdk/lib/backup/setupBackups' +import { setupBackups } from '@start9labs/start-sdk/lib/backup/setupBackups' import { Manifest } from '../manifest' /** * Here we define what volumes from the Manifest to include in backups diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index a01e259..31f10a7 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -3,7 +3,7 @@ import { configSpec } from './spec' import { read } from './read' import { save } from './save' import { Manifest } from '../../manifest' -import setupConfig from 'start-sdk/lib/config/setupConfig' +import setupConfig from '@start9labs/start-sdk/lib/config/setupConfig' /** * This is a static file. There is no need to make changes here diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 8eb42c2..72f57c1 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,6 +1,6 @@ import { ConfigSpec } from './spec' import { WrapperData } from '../../wrapperData' -import { Read } from 'start-sdk/lib/config/setupConfig' +import { Read } from '@start9labs/start-sdk/lib/config/setupConfig' /** * This function executes on config get diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index c41fcfa..871509a 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,6 +1,6 @@ import { ConfigSpec } from './spec' import { WrapperData } from '../../wrapperData' -import { Save } from 'start-sdk/lib/config/setupConfig' +import { Save } from '@start9labs/start-sdk/lib/config/setupConfig' import { Manifest } from '../../manifest' /** diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 7ab8817..6a7d158 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,6 +1,6 @@ -import { Config } from 'start-sdk/lib/config/builder/config' +import { Config } from '@start9labs/start-sdk/lib/config/builder/config' import { WrapperData } from '../../wrapperData' -import { Value } from 'start-sdk/lib/config/builder/value' +import { Value } from '@start9labs/start-sdk/lib/config/builder/value' /** * Here you define the config specification that will ultimately present to the user as validated form inputs diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 5dcc475..03d66e0 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,8 +1,8 @@ -import { setupInstall } from 'start-sdk/lib/inits/setupInstall' +import { setupInstall } from '@start9labs/start-sdk/lib/inits/setupInstall' import { WrapperData } from '../wrapperData' import { migrations } from './migrations' -import { setupUninstall } from 'start-sdk/lib/inits/setupUninstall' -import { setupInit } from 'start-sdk/lib/inits/setupInit' +import { setupUninstall } from '@start9labs/start-sdk/lib/inits/setupUninstall' +import { setupInit } from '@start9labs/start-sdk/lib/inits/setupInit' /** * Here you define arbitrary code that runs once, on fresh install only diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 24ebbbd..f4fbcd1 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,11 +1,11 @@ -import { checkPortListening } from 'start-sdk/lib/health/checkFns' -import { setupMain } from 'start-sdk/lib/mainFn' -import exportInterfaces from 'start-sdk/lib/mainFn/exportInterfaces' -import { ExpectedExports } from 'start-sdk/lib/types' +import { checkPortListening } from '@start9labs/start-sdk/lib/health/checkFns' +import { setupMain } from '@start9labs/start-sdk/lib/mainFn' +import exportInterfaces from '@start9labs/start-sdk/lib/mainFn/exportInterfaces' +import { ExpectedExports } from '@start9labs/start-sdk/lib/types' import { WrapperData } from '../wrapperData' -import { NetworkInterfaceBuilder } from 'start-sdk/lib/mainFn/NetworkInterfaceBuilder' -import { HealthReceipt } from 'start-sdk/lib/health/HealthReceipt' -import { Daemons } from 'start-sdk/lib/mainFn/Daemons' +import { NetworkInterfaceBuilder } from '@start9labs/start-sdk/lib/mainFn/NetworkInterfaceBuilder' +import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' +import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' export const main: ExpectedExports.main = setupMain( async ({ effects, utils, started }) => { @@ -77,7 +77,7 @@ export const main: ExpectedExports.main = setupMain( }) // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const webReceipt = await webInterface.exportAddresses([ + const webReceipt = await webInterface.export([ torOriginHttp, torOriginHttps, ...lanOriginsHttps.ip, diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index 41b26d4..7073bb2 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,4 +1,4 @@ -import { setupMigrations } from 'start-sdk/lib/inits/migrations/setupMigrations' +import { setupMigrations } from '@start9labs/start-sdk/lib/inits/migrations/setupMigrations' import { manifest } from '../../manifest' import { v4_0_0 } from './v4_0_0' diff --git a/startos/procedures/migrations/v4_0_0.ts b/startos/procedures/migrations/v4_0_0.ts index 955b3dc..f3d6380 100644 --- a/startos/procedures/migrations/v4_0_0.ts +++ b/startos/procedures/migrations/v4_0_0.ts @@ -1,4 +1,4 @@ -import { Migration } from 'start-sdk/lib/inits/migrations/Migration' +import { Migration } from '@start9labs/start-sdk/lib/inits/migrations/Migration' /** * This is an example migration file diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index c8e5660..8be5217 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -1,6 +1,7 @@ -import { setupProperties } from 'start-sdk/lib/properties' +import { setupProperties } from '@start9labs/start-sdk/lib/properties' import { WrapperData } from '../wrapperData' -import { PropertyString } from 'start-sdk/lib/properties/PropertyString' +import { PropertyString } from '@start9labs/start-sdk/lib/properties/PropertyString' +import { PropertyGroup } from '@start9labs/start-sdk/lib/properties/PropertyGroup' /** * With access to WrapperData, in this function you determine what to include in the Properties section of the UI @@ -9,19 +10,25 @@ export const properties = setupProperties( async ({ wrapperData }) => { const name = wrapperData.config.name return [ - PropertyString.of({ - // The display label of the property - name: 'Secret Phrase', - // A human-readable description of the property - description: 'This secret phrase will get you access to a secret place', - // The value of the property - value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, - // optionally display a copy button with the property - copyable: true, - // optionally permit displaying the property as a QR code - qr: false, - // optionally mask the value of the property - masked: false, + PropertyGroup.of({ + header: null, + values: [ + PropertyString.of({ + // The display label of the property + name: 'Secret Phrase', + // A human-readable description of the property + description: + 'This secret phrase will get you access to a secret place', + // The value of the property + value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, + // optionally display a copy button with the property + copyable: true, + // optionally permit displaying the property as a QR code + qr: false, + // optionally mask the value of the property + masked: false, + }), + ], }), ] }, From c3e465840b0a459a3f4bc08c1720dd1d9fb9f077 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 4 May 2023 16:24:45 -0600 Subject: [PATCH 024/120] update sdk --- package-lock.json | 7 +++-- package.json | 2 +- startos/procedures/actions/nameToLogs.ts | 4 +-- startos/procedures/config/spec.ts | 1 - startos/procedures/index.ts | 1 - startos/procedures/main.ts | 2 +- startos/procedures/properties.ts | 35 ------------------------ 7 files changed, 8 insertions(+), 44 deletions(-) delete mode 100644 startos/procedures/properties.ts diff --git a/package-lock.json b/package-lock.json index 0e1b89f..3250cc8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc1" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#597aa485186dcd3246357dc1f8e3ad91f062e454" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -20,8 +20,9 @@ }, "node_modules/@start9labs/start-sdk": { "version": "0.4.0-rev0.lib0.rc1", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc1.tgz", - "integrity": "sha512-0+7yCu25RLgNhJnGJue24VIO542aCcVgYoVIUvjgufgkmu3MqhbO+JUd84QMYeDeNaAi/WY3xbPpvqv+XLxw0g==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#597aa485186dcd3246357dc1f8e3ad91f062e454", + "integrity": "sha512-j1e7j8kkIzSsZ+Evf5npD/uDUnbVi5YUeS/ZM6ooKnwm1VHj0rnNgGC23ysVQbFLWiS+ItrYvas32Op6MzB90w==", + "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", diff --git a/package.json b/package.json index 782229a..d0a0724 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc1" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#597aa485186dcd3246357dc1f8e3ad91f062e454" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index a80ef80..5e862cb 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -31,14 +31,14 @@ export const nameToLogs = createAction( description: 'Prints "Hello [Name]" to the service logs.', id: 'nameToLogs', input, - runningOnly: false, + allowedStatuses: 'only-running', }, async ({ effects, utils, input }) => { const name = input.nameToPrint || (await utils.getOwnWrapperData('/config/name').once()) - await effects.console.log(`Hello ${name}`) + await console.log(`Hello ${name}`) return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 6a7d158..d704913 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,5 +1,4 @@ import { Config } from '@start9labs/start-sdk/lib/config/builder/config' -import { WrapperData } from '../../wrapperData' import { Value } from '@start9labs/start-sdk/lib/config/builder/value' /** diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 5f499df..909e809 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -1,6 +1,5 @@ export { getConfig, setConfig } from './config' export { createBackup, restoreBackup } from './backups' -export { properties } from './properties' export { main } from './main' export { init, uninit } from './init' export { actions } from './actions' diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index f4fbcd1..55bd468 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -14,7 +14,7 @@ export const main: ExpectedExports.main = setupMain( * * In this section, you will fetch any resources or run any commands necessary to run the service */ - await effects.console.info('Starting Hello World!') + console.info('Starting Hello World!') /** * ======================== Interfaces ======================== diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts deleted file mode 100644 index 8be5217..0000000 --- a/startos/procedures/properties.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { setupProperties } from '@start9labs/start-sdk/lib/properties' -import { WrapperData } from '../wrapperData' -import { PropertyString } from '@start9labs/start-sdk/lib/properties/PropertyString' -import { PropertyGroup } from '@start9labs/start-sdk/lib/properties/PropertyGroup' - -/** - * With access to WrapperData, in this function you determine what to include in the Properties section of the UI - */ -export const properties = setupProperties( - async ({ wrapperData }) => { - const name = wrapperData.config.name - return [ - PropertyGroup.of({ - header: null, - values: [ - PropertyString.of({ - // The display label of the property - name: 'Secret Phrase', - // A human-readable description of the property - description: - 'This secret phrase will get you access to a secret place', - // The value of the property - value: `When I say "Hello", you say "${name}". Hello, ${name}! Hello, ${name}!`, - // optionally display a copy button with the property - copyable: true, - // optionally permit displaying the property as a QR code - qr: false, - // optionally mask the value of the property - masked: false, - }), - ], - }), - ] - }, -) From e30b0843dcfe9b2e119f714789500a9b43ca71d0 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 4 May 2023 20:56:22 -0600 Subject: [PATCH 025/120] latest sdk --- package-lock.json | 6 +++--- package.json | 2 +- startos/procedures/actions/nameToLogs.ts | 2 +- startos/procedures/main.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3250cc8..322c0ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#597aa485186dcd3246357dc1f8e3ad91f062e454" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#e32b768e5c95574555cb29020d414c814f5c4598" }, "devDependencies": { "@vercel/ncc": "^0.36.1", @@ -20,8 +20,8 @@ }, "node_modules/@start9labs/start-sdk": { "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#597aa485186dcd3246357dc1f8e3ad91f062e454", - "integrity": "sha512-j1e7j8kkIzSsZ+Evf5npD/uDUnbVi5YUeS/ZM6ooKnwm1VHj0rnNgGC23ysVQbFLWiS+ItrYvas32Op6MzB90w==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#e32b768e5c95574555cb29020d414c814f5c4598", + "integrity": "sha512-cShc2X2qHAgJARi7TzXh6ZpqMLnLKxkWRh65wQ/LV99+Pb3oIYtrODu9aj40+8fvy2h7Vpbw8co5CmGvXnrRIg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index d0a0724..4808561 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#597aa485186dcd3246357dc1f8e3ad91f062e454" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#e32b768e5c95574555cb29020d414c814f5c4598" }, "devDependencies": { "@vercel/ncc": "^0.36.1", diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 5e862cb..cd1f270 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -38,7 +38,7 @@ export const nameToLogs = createAction( input.nameToPrint || (await utils.getOwnWrapperData('/config/name').once()) - await console.log(`Hello ${name}`) + console.info(`Hello ${name}`) return { message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 55bd468..ff80c76 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -71,7 +71,7 @@ export const main: ExpectedExports.main = setupMain( id: 'webui', description: 'The web interface of Hello World', ui: true, - basic: null, + username: null, path: '', search: {}, }) From 35aea4ca9475a957470798d9daef1c3ab1ec8512 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 5 May 2023 14:57:03 -0600 Subject: [PATCH 026/120] node types and 4001 migration --- package-lock.json | 15 +++++++++++---- package.json | 2 ++ startos/manifest.ts | 2 +- startos/procedures/migrations/index.ts | 4 ++-- .../migrations/{v4_0_0.ts => v4_0_0_1.ts} | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) rename startos/procedures/migrations/{v4_0_0.ts => v4_0_0_1.ts} (86%) diff --git a/package-lock.json b/package-lock.json index 322c0ae..d686f14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,10 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#e32b768e5c95574555cb29020d414c814f5c4598" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#a0bc1eca02fa0e5f762c35350b7de33c9a4c7134" }, "devDependencies": { + "@types/node": "^20.0.0", "@vercel/ncc": "^0.36.1", "prettier": "^2.8.4", "typescript": "^4.9.5" @@ -19,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#e32b768e5c95574555cb29020d414c814f5c4598", - "integrity": "sha512-cShc2X2qHAgJARi7TzXh6ZpqMLnLKxkWRh65wQ/LV99+Pb3oIYtrODu9aj40+8fvy2h7Vpbw8co5CmGvXnrRIg==", + "version": "0.4.0-rev0.lib0.rc2", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#a0bc1eca02fa0e5f762c35350b7de33c9a4c7134", + "integrity": "sha512-fV+J7SD9xD7LzW4YnKnu5dZl6eQTFTJzoddfSoCNF/KnxWUOrMyIk3PPBX3uHOSEJjEIo3YYgrrGi8wn6jHkCw==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -29,6 +30,12 @@ "yaml": "^2.2.1" } }, + "node_modules/@types/node": { + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.0.0.tgz", + "integrity": "sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==", + "dev": true + }, "node_modules/@vercel/ncc": { "version": "0.36.1", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", diff --git a/package.json b/package.json index 4808561..ddc0cce 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,11 @@ "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#e32b768e5c95574555cb29020d414c814f5c4598" }, "devDependencies": { + "@types/node": "^20.0.0", "@vercel/ncc": "^0.36.1", "prettier": "^2.8.4", "typescript": "^4.9.5" + }, "prettier": { "trailingComma": "all", diff --git a/startos/manifest.ts b/startos/manifest.ts index ed04f3d..5181f85 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -7,7 +7,7 @@ import { actionsMetadata } from './procedures/actions' export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', - version: '4.0.0', + version: '4.0.0.1', releaseNotes: 'Revamped for StartOS 0.4.0', license: 'mit', replaces: Array('Hello World (hosted)', 'Goodbye World'), diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index 7073bb2..f1acc64 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,8 +1,8 @@ import { setupMigrations } from '@start9labs/start-sdk/lib/inits/migrations/setupMigrations' import { manifest } from '../../manifest' -import { v4_0_0 } from './v4_0_0' +import { v4_0_0_1 } from './v4_0_0_1' /** * Add each new migration as the next argument to this function */ -export const migrations = setupMigrations(manifest, v4_0_0) +export const migrations = setupMigrations(manifest, v4_0_0_1) diff --git a/startos/procedures/migrations/v4_0_0.ts b/startos/procedures/migrations/v4_0_0_1.ts similarity index 86% rename from startos/procedures/migrations/v4_0_0.ts rename to startos/procedures/migrations/v4_0_0_1.ts index f3d6380..4382e46 100644 --- a/startos/procedures/migrations/v4_0_0.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -7,8 +7,8 @@ import { Migration } from '@start9labs/start-sdk/lib/inits/migrations/Migration' * * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts */ -export const v4_0_0 = new Migration({ - version: '4.0.0', +export const v4_0_0_1 = new Migration({ + version: '4.0.0.1', up: async ({ effects }) => await effects.setConfigured(false), down: async ({ effects }) => {}, }) From ef3d6684430ad6beaaec7bcc7c0040d67b169de2 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 9 May 2023 14:37:43 -0600 Subject: [PATCH 027/120] chore: This is after the update --- .gitignore | 2 +- package-lock.json | 16 ++++++++-------- package.json | 3 +-- startos/manifest.ts | 2 -- startos/procedures/actions/index.ts | 3 ++- startos/procedures/actions/nameToLogs.ts | 11 ++++------- startos/procedures/autoConfig.ts | 11 ++--------- startos/procedures/backups.ts | 5 ++--- startos/procedures/config/index.ts | 10 ++-------- startos/procedures/config/read.ts | 9 +++------ startos/procedures/config/save.ts | 6 +++--- startos/procedures/config/spec.ts | 5 ++--- startos/procedures/index.ts | 2 +- startos/procedures/init.ts | 11 ++++------- startos/procedures/main.ts | 5 ++--- startos/procedures/migrations/index.ts | 5 ++--- startos/procedures/migrations/v4_0_0_1.ts | 4 ++-- startos/procedures/sdk.ts | 8 ++++++++ startos/{wrapperData.ts => store.ts} | 2 +- 19 files changed, 50 insertions(+), 70 deletions(-) create mode 100644 startos/procedures/sdk.ts rename startos/{wrapperData.ts => store.ts} (91%) diff --git a/.gitignore b/.gitignore index ca256b0..3c911c7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ procedures/*.js node_modules/ .DS_Store .vscode/ -docker-images \ No newline at end of file +docker-images diff --git a/package-lock.json b/package-lock.json index d686f14..f09fbbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#a0bc1eca02fa0e5f762c35350b7de33c9a4c7134" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#021c4d4503f02c6d7814f9c9614e2fd93a8142c0" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,14 +20,14 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc2", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#a0bc1eca02fa0e5f762c35350b7de33c9a4c7134", - "integrity": "sha512-fV+J7SD9xD7LzW4YnKnu5dZl6eQTFTJzoddfSoCNF/KnxWUOrMyIk3PPBX3uHOSEJjEIo3YYgrrGi8wn6jHkCw==", + "version": "0.4.0-rev0.lib0.rc1", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#021c4d4503f02c6d7814f9c9614e2fd93a8142c0", + "integrity": "sha512-Foufq8c2R2XKIeF1MbqfAkH59rmwbU3Mbn0p9Ji7eKGGP95STUzqIe5sLe+LrK9uSuHOZEJzNUHX6aLaGCfo4Q==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", - "yaml": "^2.2.1" + "yaml": "^2.2.2" } }, "node_modules/@types/node": { @@ -79,9 +79,9 @@ } }, "node_modules/yaml": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.1.tgz", - "integrity": "sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==", + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", "engines": { "node": ">= 14" } diff --git a/package.json b/package.json index ddc0cce..f1c68b1 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,13 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#e32b768e5c95574555cb29020d414c814f5c4598" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#021c4d4503f02c6d7814f9c9614e2fd93a8142c0" }, "devDependencies": { "@types/node": "^20.0.0", "@vercel/ncc": "^0.36.1", "prettier": "^2.8.4", "typescript": "^4.9.5" - }, "prettier": { "trailingComma": "all", diff --git a/startos/manifest.ts b/startos/manifest.ts index 5181f85..705e4cc 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,5 +1,4 @@ import { setupManifest } from '@start9labs/start-sdk/lib/manifest/setupManifest' -import { actionsMetadata } from './procedures/actions' /** * In this function you define static properties of the service @@ -40,7 +39,6 @@ export const manifest = setupManifest({ }, }, }, - actions: actionsMetadata, alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 428e06f..9f13b70 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,7 +1,8 @@ +import { sdk } from '../sdk' import { nameToLogs } from './nameToLogs' import { setupActions } from '@start9labs/start-sdk/lib/actions/setupActions' /** * Add each new Action as the next argument to this function */ -export const { actions, actionsMetadata } = setupActions(nameToLogs) +export const { actions, actionsMetaData } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index cd1f270..7e65379 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -1,7 +1,5 @@ -import { Config } from '@start9labs/start-sdk/lib/config/builder/config' -import { WrapperData } from '../../wrapperData' -import { createAction } from '@start9labs/start-sdk/lib/actions/createAction' -import { Value } from '@start9labs/start-sdk/lib/config/builder/value' +import { sdk } from '../sdk' +const { Config, Value } = sdk /** * This is an example Action @@ -25,7 +23,7 @@ const input = Config.of({ * * If no input is required, FormSpec would be null */ -export const nameToLogs = createAction( +export const nameToLogs = sdk.createAction( { name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', @@ -35,8 +33,7 @@ export const nameToLogs = createAction( }, async ({ effects, utils, input }) => { const name = - input.nameToPrint || - (await utils.getOwnWrapperData('/config/name').once()) + input.nameToPrint || (await utils.store.getOwn('/config/name').once()) console.info(`Hello ${name}`) diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 52e61bf..d47d5bf 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,16 +1,9 @@ import { ConfigSpec } from './config/spec' -import { WrapperData } from '../wrapperData' -import { Manifest } from '../manifest' -import { setupAutoConfig } from '@start9labs/start-sdk/lib/autoconfig/setupAutoConfig' +import { sdk } from './sdk' /** * In this function, you establish rules for auto configuring service dependencies * * See Hello Moon for an example */ -export const autoConfig = setupAutoConfig< - WrapperData, - ConfigSpec, - Manifest, - {} ->({}) +export const autoConfig = sdk.setupAutoConfig({}) diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 346fa6f..13e74bf 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,6 +1,5 @@ -import { setupBackups } from '@start9labs/start-sdk/lib/backup/setupBackups' -import { Manifest } from '../manifest' +import { sdk } from './sdk' /** * Here we define what volumes from the Manifest to include in backups */ -export const { createBackup, restoreBackup } = setupBackups('main') +export const { createBackup, restoreBackup } = sdk.setupBackups('main') diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 31f10a7..99f22c5 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,15 +1,9 @@ -import { WrapperData } from '../../wrapperData' import { configSpec } from './spec' import { read } from './read' import { save } from './save' -import { Manifest } from '../../manifest' -import setupConfig from '@start9labs/start-sdk/lib/config/setupConfig' +import { sdk } from '../sdk' /** * This is a static file. There is no need to make changes here */ -export const { getConfig, setConfig } = setupConfig< - WrapperData, - typeof configSpec, - Manifest ->(configSpec, save, read) +export const { getConfig, setConfig } = sdk.setupConfig(configSpec, save, read) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 72f57c1..9e61c28 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,5 +1,5 @@ +import { Store } from '../../store' import { ConfigSpec } from './spec' -import { WrapperData } from '../../wrapperData' import { Read } from '@start9labs/start-sdk/lib/config/setupConfig' /** @@ -7,9 +7,6 @@ import { Read } from '@start9labs/start-sdk/lib/config/setupConfig' * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read: Read = async ({ - effects, - utils, -}) => { - return utils.getOwnWrapperData('/config').once() +export const read: Read = async ({ effects, utils }) => { + return utils.store.getOwn('/config').once() } diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 871509a..09fab64 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,20 +1,20 @@ import { ConfigSpec } from './spec' -import { WrapperData } from '../../wrapperData' import { Save } from '@start9labs/start-sdk/lib/config/setupConfig' import { Manifest } from '../../manifest' +import { Store } from '../../store' /** * This function executes on config save * * Use it to persist config data to various files and to establish any resulting dependencies */ -export const save: Save = async ({ +export const save: Save = async ({ effects, utils, input, dependencies, }) => { - await utils.setOwnWrapperData('/config', input) + await utils.store.setOwn('/config', input) const dependenciesReceipt = await effects.setDependencies([]) return { diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index d704913..503e9b1 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,6 +1,5 @@ -import { Config } from '@start9labs/start-sdk/lib/config/builder/config' -import { Value } from '@start9labs/start-sdk/lib/config/builder/value' - +import { sdk } from '../sdk' +const { Config, Value } = sdk /** * Here you define the config specification that will ultimately present to the user as validated form inputs * diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 909e809..57bb610 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -2,5 +2,5 @@ export { getConfig, setConfig } from './config' export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' -export { actions } from './actions' +export { actions, actionsMetaData } from './actions' export { autoConfig } from './autoConfig' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 03d66e0..271d718 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,20 +1,17 @@ -import { setupInstall } from '@start9labs/start-sdk/lib/inits/setupInstall' -import { WrapperData } from '../wrapperData' import { migrations } from './migrations' -import { setupUninstall } from '@start9labs/start-sdk/lib/inits/setupUninstall' -import { setupInit } from '@start9labs/start-sdk/lib/inits/setupInit' +import { sdk } from './sdk' /** * Here you define arbitrary code that runs once, on fresh install only */ -const install = setupInstall(async ({ effects, utils }) => {}) +const install = sdk.setupInstall(async ({ effects, utils }) => {}) /** * Here you define arbitrary code that runs once, on uninstall only */ -const uninstall = setupUninstall(async ({ effects, utils }) => {}) +const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) /** * This is a static function. There is no need to make changes here */ -export const { init, uninit } = setupInit(migrations, install, uninstall) +export const { init, uninit } = sdk.setupInit(migrations, install, uninstall) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index ff80c76..914bd9a 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,13 +1,12 @@ import { checkPortListening } from '@start9labs/start-sdk/lib/health/checkFns' -import { setupMain } from '@start9labs/start-sdk/lib/mainFn' import exportInterfaces from '@start9labs/start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from '@start9labs/start-sdk/lib/types' -import { WrapperData } from '../wrapperData' import { NetworkInterfaceBuilder } from '@start9labs/start-sdk/lib/mainFn/NetworkInterfaceBuilder' import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' +import { sdk } from './sdk' -export const main: ExpectedExports.main = setupMain( +export const main: ExpectedExports.main = sdk.setupMain( async ({ effects, utils, started }) => { /** * ======================== Setup ======================== diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index f1acc64..eb5e11c 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,8 +1,7 @@ -import { setupMigrations } from '@start9labs/start-sdk/lib/inits/migrations/setupMigrations' -import { manifest } from '../../manifest' import { v4_0_0_1 } from './v4_0_0_1' +import { sdk } from '../sdk' /** * Add each new migration as the next argument to this function */ -export const migrations = setupMigrations(manifest, v4_0_0_1) +export const migrations = sdk.setupMigrations(v4_0_0_1) diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index 4382e46..8a0c666 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -1,4 +1,4 @@ -import { Migration } from '@start9labs/start-sdk/lib/inits/migrations/Migration' +import { sdk } from '../sdk' /** * This is an example migration file @@ -7,7 +7,7 @@ import { Migration } from '@start9labs/start-sdk/lib/inits/migrations/Migration' * * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts */ -export const v4_0_0_1 = new Migration({ +export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', up: async ({ effects }) => await effects.setConfigured(false), down: async ({ effects }) => {}, diff --git a/startos/procedures/sdk.ts b/startos/procedures/sdk.ts new file mode 100644 index 0000000..32efe7b --- /dev/null +++ b/startos/procedures/sdk.ts @@ -0,0 +1,8 @@ +import { StartSdk } from '@start9labs/start-sdk/lib/StartSdk' +import { manifest } from '../manifest' +import { Store } from '../store' + +export const sdk = StartSdk.of() + .withManifest(manifest) + .withStore() + .build(true) diff --git a/startos/wrapperData.ts b/startos/store.ts similarity index 91% rename from startos/wrapperData.ts rename to startos/store.ts index 0379908..c4dffa1 100644 --- a/startos/wrapperData.ts +++ b/startos/store.ts @@ -5,6 +5,6 @@ import { ConfigSpec } from './procedures/config/spec' * * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords */ -export interface WrapperData { +export interface Store { config: ConfigSpec } From aceb627f49a31c71bc864c98a5818dd2281f17c7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 9 May 2023 14:48:21 -0600 Subject: [PATCH 028/120] add vault --- startos/procedures/migrations/v4_0_0_1.ts | 4 ++-- startos/vault.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 startos/vault.ts diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index 8a0c666..5607c05 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -9,6 +9,6 @@ import { sdk } from '../sdk' */ export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', - up: async ({ effects }) => await effects.setConfigured(false), - down: async ({ effects }) => {}, + up: async ({ effects, utils }) => await effects.setConfigured(false), + down: async ({ effects, utils }) => {}, }) diff --git a/startos/vault.ts b/startos/vault.ts new file mode 100644 index 0000000..30b38d5 --- /dev/null +++ b/startos/vault.ts @@ -0,0 +1,4 @@ +/** + * Here you define a set of sensitive keys/values to be stored in the service vault. Values are encrypted with the StartOS master password + */ +export interface Vault extends Record {} From 0f1cff99e9db7c9cc192700c23a6a520cba40d54 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 9 May 2023 16:08:49 -0600 Subject: [PATCH 029/120] chore: Update to use the new vault --- package-lock.json | 6 +++--- package.json | 2 +- startos/procedures/autoConfig.ts | 4 ++-- startos/procedures/config/read.ts | 14 ++++++++------ startos/procedures/config/save.ts | 30 +++++++++++++----------------- startos/procedures/sdk.ts | 2 ++ startos/vault.ts | 1 + 7 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 startos/vault.ts diff --git a/package-lock.json b/package-lock.json index f09fbbd..a7eb45d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#021c4d4503f02c6d7814f9c9614e2fd93a8142c0" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#cc057ea222624ee1206eb60d4e9c93c557b50872" }, "devDependencies": { "@types/node": "^20.0.0", @@ -21,8 +21,8 @@ }, "node_modules/@start9labs/start-sdk": { "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#021c4d4503f02c6d7814f9c9614e2fd93a8142c0", - "integrity": "sha512-Foufq8c2R2XKIeF1MbqfAkH59rmwbU3Mbn0p9Ji7eKGGP95STUzqIe5sLe+LrK9uSuHOZEJzNUHX6aLaGCfo4Q==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#cc057ea222624ee1206eb60d4e9c93c557b50872", + "integrity": "sha512-ciI+WYxqMHipIw9M5CLSPDQ+JhvqE0skBhWBLxFNitJONqFQzNlL1X7pQnupN5JOVAJEzIiWVvQVo9tqOTE7vw==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index f1c68b1..aa35371 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#021c4d4503f02c6d7814f9c9614e2fd93a8142c0" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#cc057ea222624ee1206eb60d4e9c93c557b50872" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index d47d5bf..5384719 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,4 +1,4 @@ -import { ConfigSpec } from './config/spec' +import { configSpec } from './config/spec' import { sdk } from './sdk' /** @@ -6,4 +6,4 @@ import { sdk } from './sdk' * * See Hello Moon for an example */ -export const autoConfig = sdk.setupAutoConfig({}) +export const autoConfig = sdk.setupAutoConfig(configSpec, {}) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 9e61c28..e184062 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,12 +1,14 @@ -import { Store } from '../../store' -import { ConfigSpec } from './spec' -import { Read } from '@start9labs/start-sdk/lib/config/setupConfig' +import { sdk } from '../sdk' +import { configSpec } from './spec' /** * This function executes on config get * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read: Read = async ({ effects, utils }) => { - return utils.store.getOwn('/config').once() -} +export const read = sdk.setupConfigRead( + configSpec, + async ({ effects, utils }) => { + return utils.store.getOwn('/config').once() + }, +) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 09fab64..658d5e7 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,24 +1,20 @@ -import { ConfigSpec } from './spec' -import { Save } from '@start9labs/start-sdk/lib/config/setupConfig' -import { Manifest } from '../../manifest' -import { Store } from '../../store' +import { configSpec } from './spec' +import { sdk } from '../sdk' /** * This function executes on config save * * Use it to persist config data to various files and to establish any resulting dependencies */ -export const save: Save = async ({ - effects, - utils, - input, - dependencies, -}) => { - await utils.store.setOwn('/config', input) - const dependenciesReceipt = await effects.setDependencies([]) +export const save = sdk.setupConfigSave( + configSpec, + async ({ effects, utils, input, dependencies }) => { + await utils.store.setOwn('/config', input) + const dependenciesReceipt = await effects.setDependencies([]) - return { - dependenciesReceipt, - restart: true, - } -} + return { + dependenciesReceipt, + restart: true, + } + }, +) diff --git a/startos/procedures/sdk.ts b/startos/procedures/sdk.ts index 32efe7b..115f026 100644 --- a/startos/procedures/sdk.ts +++ b/startos/procedures/sdk.ts @@ -1,8 +1,10 @@ import { StartSdk } from '@start9labs/start-sdk/lib/StartSdk' import { manifest } from '../manifest' import { Store } from '../store' +import { Vault } from '../vault' export const sdk = StartSdk.of() .withManifest(manifest) .withStore() + .withVault() .build(true) diff --git a/startos/vault.ts b/startos/vault.ts new file mode 100644 index 0000000..450947d --- /dev/null +++ b/startos/vault.ts @@ -0,0 +1 @@ +export type Vault = {} From 7cd7d780f70c27c60f3c299ec8a7ca3a4c5b0a02 Mon Sep 17 00:00:00 2001 From: BluJ Date: Tue, 9 May 2023 16:55:52 -0600 Subject: [PATCH 030/120] chore: UPdate name to metadata --- package-lock.json | 6 +++--- package.json | 2 +- startos/procedures/actions/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7eb45d..705b2c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#cc057ea222624ee1206eb60d4e9c93c557b50872" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#5536dfb55f454953af3ee407acf5befeaa8f1463" }, "devDependencies": { "@types/node": "^20.0.0", @@ -21,8 +21,8 @@ }, "node_modules/@start9labs/start-sdk": { "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#cc057ea222624ee1206eb60d4e9c93c557b50872", - "integrity": "sha512-ciI+WYxqMHipIw9M5CLSPDQ+JhvqE0skBhWBLxFNitJONqFQzNlL1X7pQnupN5JOVAJEzIiWVvQVo9tqOTE7vw==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#5536dfb55f454953af3ee407acf5befeaa8f1463", + "integrity": "sha512-vVDueGUgNOopVHdxZBwg5kIFXkyGea68J17/Gj2B91MueRFNfhx/M0gUyioYZaUNhYseBQgdSjZf+PsbHLSwuw==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index aa35371..ffef19d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#cc057ea222624ee1206eb60d4e9c93c557b50872" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#5536dfb55f454953af3ee407acf5befeaa8f1463" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 9f13b70..24efbba 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -5,4 +5,4 @@ import { setupActions } from '@start9labs/start-sdk/lib/actions/setupActions' /** * Add each new Action as the next argument to this function */ -export const { actions, actionsMetaData } = sdk.setupActions(nameToLogs) +export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) From c7ecd6f4a0c6e2300bab21d71a5f725dd3de2b3f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 9 May 2023 18:02:07 -0600 Subject: [PATCH 031/120] minor bug fix and commnets --- startos/procedures/actions/index.ts | 2 +- startos/procedures/index.ts | 2 +- startos/procedures/sdk.ts | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 24efbba..ff563fd 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,8 +1,8 @@ import { sdk } from '../sdk' import { nameToLogs } from './nameToLogs' -import { setupActions } from '@start9labs/start-sdk/lib/actions/setupActions' /** * Add each new Action as the next argument to this function */ + export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 57bb610..903713d 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -2,5 +2,5 @@ export { getConfig, setConfig } from './config' export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' -export { actions, actionsMetaData } from './actions' +export { actions, actionsMetadata } from './actions' export { autoConfig } from './autoConfig' diff --git a/startos/procedures/sdk.ts b/startos/procedures/sdk.ts index 115f026..b140461 100644 --- a/startos/procedures/sdk.ts +++ b/startos/procedures/sdk.ts @@ -3,6 +3,11 @@ import { manifest } from '../manifest' import { Store } from '../store' import { Vault } from '../vault' +/** + * This is a static file that provides type safety throughout the codebase + * + * the exported sdk const should be used instead of StartSdk directly + */ export const sdk = StartSdk.of() .withManifest(manifest) .withStore() From 3f3b8efc412e080f2c284309e69733b9d3da482f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 10 May 2023 06:13:42 -0600 Subject: [PATCH 032/120] move sdk.ts to root --- startos/procedures/actions/index.ts | 2 +- startos/procedures/actions/nameToLogs.ts | 2 +- startos/procedures/autoConfig.ts | 2 +- startos/procedures/backups.ts | 2 +- startos/procedures/config/index.ts | 2 +- startos/procedures/config/read.ts | 2 +- startos/procedures/config/save.ts | 2 +- startos/procedures/config/spec.ts | 2 +- startos/procedures/init.ts | 2 +- startos/procedures/main.ts | 2 +- startos/procedures/migrations/index.ts | 2 +- startos/procedures/migrations/v4_0_0_1.ts | 2 +- startos/{procedures => }/sdk.ts | 6 +++--- 13 files changed, 15 insertions(+), 15 deletions(-) rename startos/{procedures => }/sdk.ts (76%) diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index ff563fd..758605c 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from '../../sdk' import { nameToLogs } from './nameToLogs' /** diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 7e65379..ba748a1 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from '../../sdk' const { Config, Value } = sdk /** diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts index 5384719..c25c20f 100644 --- a/startos/procedures/autoConfig.ts +++ b/startos/procedures/autoConfig.ts @@ -1,5 +1,5 @@ import { configSpec } from './config/spec' -import { sdk } from './sdk' +import { sdk } from '../sdk' /** * In this function, you establish rules for auto configuring service dependencies diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 13e74bf..6c2ffbc 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,4 +1,4 @@ -import { sdk } from './sdk' +import { sdk } from '../sdk' /** * Here we define what volumes from the Manifest to include in backups */ diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 99f22c5..ad2b867 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,7 +1,7 @@ import { configSpec } from './spec' import { read } from './read' import { save } from './save' -import { sdk } from '../sdk' +import { sdk } from '../../sdk' /** * This is a static file. There is no need to make changes here diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index e184062..28ac479 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from '../../sdk' import { configSpec } from './spec' /** diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 658d5e7..3ac1844 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,5 +1,5 @@ import { configSpec } from './spec' -import { sdk } from '../sdk' +import { sdk } from '../../sdk' /** * This function executes on config save diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 503e9b1..af2d3a4 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from '../../sdk' const { Config, Value } = sdk /** * Here you define the config specification that will ultimately present to the user as validated form inputs diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 271d718..e1f3575 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,5 +1,5 @@ import { migrations } from './migrations' -import { sdk } from './sdk' +import { sdk } from '../sdk' /** * Here you define arbitrary code that runs once, on fresh install only diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 914bd9a..74f946a 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -4,7 +4,7 @@ import { ExpectedExports } from '@start9labs/start-sdk/lib/types' import { NetworkInterfaceBuilder } from '@start9labs/start-sdk/lib/mainFn/NetworkInterfaceBuilder' import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' -import { sdk } from './sdk' +import { sdk } from '../sdk' export const main: ExpectedExports.main = sdk.setupMain( async ({ effects, utils, started }) => { diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index eb5e11c..dd2c352 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,5 +1,5 @@ import { v4_0_0_1 } from './v4_0_0_1' -import { sdk } from '../sdk' +import { sdk } from '../../sdk' /** * Add each new migration as the next argument to this function diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index 5607c05..adab490 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from '../../sdk' /** * This is an example migration file diff --git a/startos/procedures/sdk.ts b/startos/sdk.ts similarity index 76% rename from startos/procedures/sdk.ts rename to startos/sdk.ts index b140461..f65c09f 100644 --- a/startos/procedures/sdk.ts +++ b/startos/sdk.ts @@ -1,7 +1,7 @@ import { StartSdk } from '@start9labs/start-sdk/lib/StartSdk' -import { manifest } from '../manifest' -import { Store } from '../store' -import { Vault } from '../vault' +import { manifest } from './manifest' +import { Store } from './store' +import { Vault } from './vault' /** * This is a static file that provides type safety throughout the codebase From 523bd8023bc678093895743dae16d3b10448fce0 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 10 May 2023 19:15:56 -0600 Subject: [PATCH 033/120] dependencies done --- package-lock.json | 6 +++--- package.json | 2 +- startos/procedures/autoConfig.ts | 9 --------- startos/procedures/backups.ts | 1 + startos/procedures/config/index.ts | 2 +- startos/procedures/config/save.ts | 2 +- startos/procedures/dependencies/dependencyConfig.ts | 9 +++++++++ startos/procedures/dependencies/dependencyMounts.ts | 8 ++++++++ startos/procedures/index.ts | 2 +- startos/procedures/init.ts | 2 +- startos/procedures/main.ts | 2 +- startos/procedures/migrations/index.ts | 2 +- 12 files changed, 28 insertions(+), 19 deletions(-) delete mode 100644 startos/procedures/autoConfig.ts create mode 100644 startos/procedures/dependencies/dependencyConfig.ts create mode 100644 startos/procedures/dependencies/dependencyMounts.ts diff --git a/package-lock.json b/package-lock.json index 705b2c3..c6d321a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#5536dfb55f454953af3ee407acf5befeaa8f1463" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#9ad51618551823a0fe6db84d5eca13bef11dbd38" }, "devDependencies": { "@types/node": "^20.0.0", @@ -21,8 +21,8 @@ }, "node_modules/@start9labs/start-sdk": { "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#5536dfb55f454953af3ee407acf5befeaa8f1463", - "integrity": "sha512-vVDueGUgNOopVHdxZBwg5kIFXkyGea68J17/Gj2B91MueRFNfhx/M0gUyioYZaUNhYseBQgdSjZf+PsbHLSwuw==", + "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#9ad51618551823a0fe6db84d5eca13bef11dbd38", + "integrity": "sha512-or050w+rCQPbY8TLPmn0JyHEWEHO5/m17/uLr1/wMnzF6DDBLjElTLA6ILbqdMXNis+oSZUjRlhF92MjzLkOvg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index ffef19d..1362d48 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#5536dfb55f454953af3ee407acf5befeaa8f1463" + "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#9ad51618551823a0fe6db84d5eca13bef11dbd38" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/autoConfig.ts b/startos/procedures/autoConfig.ts deleted file mode 100644 index c25c20f..0000000 --- a/startos/procedures/autoConfig.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { configSpec } from './config/spec' -import { sdk } from '../sdk' - -/** - * In this function, you establish rules for auto configuring service dependencies - * - * See Hello Moon for an example - */ -export const autoConfig = sdk.setupAutoConfig(configSpec, {}) diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 6c2ffbc..79ca22d 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,4 +1,5 @@ import { sdk } from '../sdk' + /** * Here we define what volumes from the Manifest to include in backups */ diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index ad2b867..6ebab87 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -1,7 +1,7 @@ +import { sdk } from '../../sdk' import { configSpec } from './spec' import { read } from './read' import { save } from './save' -import { sdk } from '../../sdk' /** * This is a static file. There is no need to make changes here diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 3ac1844..a03cb31 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,5 +1,5 @@ -import { configSpec } from './spec' import { sdk } from '../../sdk' +import { configSpec } from './spec' /** * This function executes on config save diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencies/dependencyConfig.ts new file mode 100644 index 0000000..8125edb --- /dev/null +++ b/startos/procedures/dependencies/dependencyConfig.ts @@ -0,0 +1,9 @@ +import { sdk } from '../../sdk' +import { configSpec } from '../config/spec' + +/** + * In this function, you establish rules for auto configuring service dependencies + * + * See Hello Moon for an example + */ +export const autoConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/dependencies/dependencyMounts.ts b/startos/procedures/dependencies/dependencyMounts.ts new file mode 100644 index 0000000..36e0304 --- /dev/null +++ b/startos/procedures/dependencies/dependencyMounts.ts @@ -0,0 +1,8 @@ +import { sdk } from '../../sdk' + +/** + * Here you define the volumes and paths of any dependencies needed by this service + * + * See Hello Moon for an example + */ +export const dependencyMounts = sdk.setupDependencyMounts() diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 903713d..7bfb001 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -3,4 +3,4 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' -export { autoConfig } from './autoConfig' +export { autoConfig } from './dependencies/dependencyConfig' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index e1f3575..9ac77f6 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,5 +1,5 @@ -import { migrations } from './migrations' import { sdk } from '../sdk' +import { migrations } from './migrations' /** * Here you define arbitrary code that runs once, on fresh install only diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 74f946a..642857f 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,10 +1,10 @@ +import { sdk } from '../sdk' import { checkPortListening } from '@start9labs/start-sdk/lib/health/checkFns' import exportInterfaces from '@start9labs/start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from '@start9labs/start-sdk/lib/types' import { NetworkInterfaceBuilder } from '@start9labs/start-sdk/lib/mainFn/NetworkInterfaceBuilder' import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' -import { sdk } from '../sdk' export const main: ExpectedExports.main = sdk.setupMain( async ({ effects, utils, started }) => { diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index dd2c352..2129c85 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -1,5 +1,5 @@ -import { v4_0_0_1 } from './v4_0_0_1' import { sdk } from '../../sdk' +import { v4_0_0_1 } from './v4_0_0_1' /** * Add each new migration as the next argument to this function From 12eaceb000029dfa2513ee801de1ac776d385692 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 10 May 2023 20:13:56 -0600 Subject: [PATCH 034/120] export mounts --- startos/procedures/dependencies/dependencyConfig.ts | 2 +- startos/procedures/index.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencies/dependencyConfig.ts index 8125edb..a68e125 100644 --- a/startos/procedures/dependencies/dependencyConfig.ts +++ b/startos/procedures/dependencies/dependencyConfig.ts @@ -6,4 +6,4 @@ import { configSpec } from '../config/spec' * * See Hello Moon for an example */ -export const autoConfig = sdk.setupDependencyConfig(configSpec, {}) +export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 7bfb001..9885389 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -3,4 +3,5 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' -export { autoConfig } from './dependencies/dependencyConfig' +export { dependencyConfig } from './dependencies/dependencyConfig' +export { dependencyMounts } from './dependencies/dependencyMounts' From 49002faad4a4b46c3be3ae21ae8e3db1bc5c6d33 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 11 May 2023 12:43:13 -0600 Subject: [PATCH 035/120] nested dep dirs --- .../{dependencyConfig.ts => dependencyConfig/index.ts} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename startos/procedures/dependencies/{dependencyConfig.ts => dependencyConfig/index.ts} (71%) diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencies/dependencyConfig/index.ts similarity index 71% rename from startos/procedures/dependencies/dependencyConfig.ts rename to startos/procedures/dependencies/dependencyConfig/index.ts index a68e125..819dc2a 100644 --- a/startos/procedures/dependencies/dependencyConfig.ts +++ b/startos/procedures/dependencies/dependencyConfig/index.ts @@ -1,5 +1,5 @@ -import { sdk } from '../../sdk' -import { configSpec } from '../config/spec' +import { sdk } from '../../../sdk' +import { configSpec } from '../../config/spec' /** * In this function, you establish rules for auto configuring service dependencies From 96571b872a8b1118d11d35e174e5c907c2d9c4e8 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 11 May 2023 17:05:37 -0600 Subject: [PATCH 036/120] update to rc2 --- package-lock.json | 9 ++-- package.json | 2 +- startos/procedures/actions/index.ts | 1 - startos/procedures/config/save.ts | 3 ++ startos/procedures/init.ts | 8 ++- startos/procedures/interfaces.ts | 31 ++++++++++++ startos/procedures/main.ts | 77 +---------------------------- 7 files changed, 48 insertions(+), 83 deletions(-) create mode 100644 startos/procedures/interfaces.ts diff --git a/package-lock.json b/package-lock.json index c6d321a..c1d663e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#9ad51618551823a0fe6db84d5eca13bef11dbd38" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc2" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,10 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc1", - "resolved": "git+ssh://git@github.com/Start9Labs/start-sdk.git#9ad51618551823a0fe6db84d5eca13bef11dbd38", - "integrity": "sha512-or050w+rCQPbY8TLPmn0JyHEWEHO5/m17/uLr1/wMnzF6DDBLjElTLA6ILbqdMXNis+oSZUjRlhF92MjzLkOvg==", - "license": "MIT", + "version": "0.4.0-rev0.lib0.rc2", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc2.tgz", + "integrity": "sha512-JUm+IKgPkctFej+bRxAgEZsrPlXCg11gUfNSA/L1fGny9pctE0S4GGmOWyhCg5TMs939Nt2k9GVRHMkBnWG1sQ==", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", diff --git a/package.json b/package.json index 1362d48..93b7c2b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "git+https://github.com/Start9Labs/start-sdk#9ad51618551823a0fe6db84d5eca13bef11dbd38" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc2" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index 758605c..ea6ffba 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -4,5 +4,4 @@ import { nameToLogs } from './nameToLogs' /** * Add each new Action as the next argument to this function */ - export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index a03cb31..243b386 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,4 +1,5 @@ import { sdk } from '../../sdk' +import { setInterfaces } from '../interfaces' import { configSpec } from './spec' /** @@ -10,9 +11,11 @@ export const save = sdk.setupConfigSave( configSpec, async ({ effects, utils, input, dependencies }) => { await utils.store.setOwn('/config', input) + const dependenciesReceipt = await effects.setDependencies([]) return { + interfacesReceipt: await setInterfaces({ effects, utils, input }), // This is plumbing, don't touch it dependenciesReceipt, restart: true, } diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 9ac77f6..1d364e2 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,4 +1,5 @@ import { sdk } from '../sdk' +import { setInterfaces } from './interfaces' import { migrations } from './migrations' /** @@ -14,4 +15,9 @@ const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) /** * This is a static function. There is no need to make changes here */ -export const { init, uninit } = sdk.setupInit(migrations, install, uninstall) +export const { init, uninit } = sdk.setupInit( + migrations, + install, + uninstall, + setInterfaces, +) diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts new file mode 100644 index 0000000..5550aea --- /dev/null +++ b/startos/procedures/interfaces.ts @@ -0,0 +1,31 @@ +import { sdk } from '../sdk' +import { configSpec } from './config/spec' + +export const uiPort = 80 +export const webUiInterfaceId = 'webui' + +/** + * ======================== Interfaces ======================== + * + * In this section, you will decide how the service will be exposed to the outside world + */ +export const setInterfaces = sdk.setupInterfaces( + configSpec, + async ({ effects, utils, input }) => { + const multi = utils.host.multi('multi') + const multiOrigin = await multi.bindPort(uiPort, { protocol: 'http' }) + const multiInterface = utils.createInterface({ + name: 'Web UI', + id: webUiInterfaceId, + description: 'The web interface of Hello World', + ui: true, + username: null, + path: '', + search: {}, + }) + + const multiReceipt = await multiInterface.export([multiOrigin]) + + return [multiReceipt] + }, +) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 642857f..5426eec 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,10 +1,9 @@ import { sdk } from '../sdk' import { checkPortListening } from '@start9labs/start-sdk/lib/health/checkFns' -import exportInterfaces from '@start9labs/start-sdk/lib/mainFn/exportInterfaces' import { ExpectedExports } from '@start9labs/start-sdk/lib/types' -import { NetworkInterfaceBuilder } from '@start9labs/start-sdk/lib/mainFn/NetworkInterfaceBuilder' import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' +import { uiPort } from './interfaces' export const main: ExpectedExports.main = sdk.setupMain( async ({ effects, utils, started }) => { @@ -15,77 +14,6 @@ export const main: ExpectedExports.main = sdk.setupMain( */ console.info('Starting Hello World!') - /** - * ======================== Interfaces ======================== - * - * In this section, you will decide how the service will be exposed to the outside world - * - * Naming convention reference: https://developer.mozilla.org/en-US/docs/Web/API/Location - */ - - // ------------ Reverse Proxy ---------------- - - // set up a reverse proxy to enable https for Tor/LAN - await effects.reverseProxy({ - bind: { - port: 443, - ssl: true, - }, - dst: { - port: 80, - ssl: false, - }, - }) - - // ------------ Tor ------------ - - // Find or generate a random Tor hostname by ID - const torHostname = utils.torHostName('torHostname') - - // Create a Tor host with the assigned port mapping - const torHostTcp = await torHostname.bindTor(80, 80) - // Assign the Tor host a web protocol (e.g. "http", "ws") - const torOriginHttp = torHostTcp.createOrigin('http') - // Create a Tor host with the assigned port mapping - const torHostSsl = await torHostname.bindTor(443, 443) - // Assign the Tor host a web protocol (e.g. "https", "wss") - const torOriginHttps = torHostSsl.createOrigin('https') - - // ------------ LAN ------------ - - // Create a LAN host with the assigned internal port - const lanHostSsl = await utils.bindLan(443) - // Assign the LAN host a web protocol (e.g. "https", "wss") - const lanOriginsHttps = lanHostSsl.createOrigins('https') - - // ------------ Interface ---------------- - - // An interface is a grouping of addresses that expose the same resource (e.g. a UI or RPC API). - // Addresses are different "routes" to the same destination - - // Define the Interface for user display and consumption - const webInterface = new NetworkInterfaceBuilder({ - effects, - name: 'Web UI', - id: 'webui', - description: 'The web interface of Hello World', - ui: true, - username: null, - path: '', - search: {}, - }) - - // Choose which origins to attach to this interface. The resulting addresses will share the attributes of the interface (name, path, search, etc) - const webReceipt = await webInterface.export([ - torOriginHttp, - torOriginHttps, - ...lanOriginsHttps.ip, - lanOriginsHttps.local, - ]) - - // Export all address receipts for all interfaces to obtain interface receipt - const interfaceReceipt = exportInterfaces(webReceipt) - /** * ======================== Additional Health Checks (optional) ======================== * @@ -103,7 +31,6 @@ export const main: ExpectedExports.main = sdk.setupMain( return Daemons.of({ effects, started, - interfaceReceipt, // Provide the interfaceReceipt to prove it was completed healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered }).addDaemon('webui', { command: 'hello-world', // The command to start the daemon @@ -111,7 +38,7 @@ export const main: ExpectedExports.main = sdk.setupMain( display: 'Web Interface', // The function to run to determine the health status of the daemon fn: () => - checkPortListening(effects, 80, { + checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), From bfc802b61eb9260cd144cfa00ad2b063a53dcf12 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 16 May 2023 12:07:15 -0600 Subject: [PATCH 037/120] latest --- package-lock.json | 8 ++++---- package.json | 2 +- startos/procedures/config/save.ts | 2 ++ startos/procedures/config/spec.ts | 1 + startos/procedures/interfaces.ts | 4 +++- startos/procedures/main.ts | 4 ++-- startos/store.ts | 4 +++- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index c1d663e..7fa42e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc2" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc3" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc2", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc2.tgz", - "integrity": "sha512-JUm+IKgPkctFej+bRxAgEZsrPlXCg11gUfNSA/L1fGny9pctE0S4GGmOWyhCg5TMs939Nt2k9GVRHMkBnWG1sQ==", + "version": "0.4.0-rev0.lib0.rc3", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc3.tgz", + "integrity": "sha512-Nf6n/kXWSSLYKpHsP2v9KCv3mPanre8Ie8uBQX37+mAxTyk/a1iN9Ru3oqk3c1SdkzcVtt7kx/AJhsltHeZmcg==", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", diff --git a/package.json b/package.json index 93b7c2b..010f94a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc2" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc3" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 243b386..daef8d2 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -10,8 +10,10 @@ import { configSpec } from './spec' export const save = sdk.setupConfigSave( configSpec, async ({ effects, utils, input, dependencies }) => { + // save data wherever you want await utils.store.setOwn('/config', input) + // set current dependencies based on config settings const dependenciesReceipt = await effects.setDependencies([]) return { diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index af2d3a4..cec27d8 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -1,5 +1,6 @@ import { sdk } from '../../sdk' const { Config, Value } = sdk + /** * Here you define the config specification that will ultimately present to the user as validated form inputs * diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 5550aea..d45b8e2 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -8,11 +8,13 @@ export const webUiInterfaceId = 'webui' * ======================== Interfaces ======================== * * In this section, you will decide how the service will be exposed to the outside world + * + * This function runs on service install/update AND on config save */ export const setInterfaces = sdk.setupInterfaces( configSpec, async ({ effects, utils, input }) => { - const multi = utils.host.multi('multi') + const multi = utils.host.multi('multi') // technically just a multi hostname const multiOrigin = await multi.bindPort(uiPort, { protocol: 'http' }) const multiInterface = utils.createInterface({ name: 'Web UI', diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 5426eec..78fce31 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,5 +1,4 @@ import { sdk } from '../sdk' -import { checkPortListening } from '@start9labs/start-sdk/lib/health/checkFns' import { ExpectedExports } from '@start9labs/start-sdk/lib/types' import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' @@ -35,10 +34,11 @@ export const main: ExpectedExports.main = sdk.setupMain( }).addDaemon('webui', { command: 'hello-world', // The command to start the daemon ready: { + // If display is null, it will not be displayed to the user in the UI display: 'Web Interface', // The function to run to determine the health status of the daemon fn: () => - checkPortListening(effects, uiPort, { + sdk.healthCheck.checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), diff --git a/startos/store.ts b/startos/store.ts index c4dffa1..4675152 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -6,5 +6,7 @@ import { ConfigSpec } from './procedures/config/spec' * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords */ export interface Store { - config: ConfigSpec + config: { + name: string + } } From ac75aee02ff27dccdf039ec5034cbfe38ca765a7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 16 May 2023 21:00:35 -0600 Subject: [PATCH 038/120] rc4 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7fa42e8..45593a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc3" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc4" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc3", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc3.tgz", - "integrity": "sha512-Nf6n/kXWSSLYKpHsP2v9KCv3mPanre8Ie8uBQX37+mAxTyk/a1iN9Ru3oqk3c1SdkzcVtt7kx/AJhsltHeZmcg==", + "version": "0.4.0-rev0.lib0.rc4", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc4.tgz", + "integrity": "sha512-ouOpplLYCFFj5PutVtN5S0TI1UsdXA5nauOrFqKvLyhxazGjHprCpQ/fVHNSspPl/+ujNb7upzFxdZnWOE2oXw==", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", diff --git a/package.json b/package.json index 010f94a..b2dace3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc3" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc4" }, "devDependencies": { "@types/node": "^20.0.0", From e277d00fba26d5cce1cbfbcbbbd150ef2d5f2ff4 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 17 May 2023 12:06:09 -0600 Subject: [PATCH 039/120] add vault example --- startos/manifest.ts | 2 +- startos/procedures/config/save.ts | 4 ++++ startos/procedures/init.ts | 7 ++++++- startos/vault.ts | 8 ++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/startos/manifest.ts b/startos/manifest.ts index 705e4cc..b04272c 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -17,7 +17,7 @@ export const manifest = setupManifest({ donationUrl: 'https://donate.start9.com/', description: { short: 'Example service for s9pk highlighting basic features', - long: 'Hello World is a bare-bones service that launches a web interface to say "Hello World", and nothing more.', + long: 'Hello World is a template service that provides examples of basic StartOS features.', }, assets: { license: 'LICENSE', diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index daef8d2..f3089dc 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -12,6 +12,10 @@ export const save = sdk.setupConfigSave( async ({ effects, utils, input, dependencies }) => { // save data wherever you want await utils.store.setOwn('/config', input) + await utils.vault.set( + 'secretPhrase', + `Knock knock. Who's there? ${input.name}!`, + ) // set current dependencies based on config settings const dependenciesReceipt = await effects.setDependencies([]) diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 1d364e2..1b4d7fc 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -5,7 +5,12 @@ import { migrations } from './migrations' /** * Here you define arbitrary code that runs once, on fresh install only */ -const install = sdk.setupInstall(async ({ effects, utils }) => {}) +const install = sdk.setupInstall(async ({ effects, utils }) => { + await utils.vault.set( + 'secretPhrase', + `Knock knock. Who's there? Nobody knows!`, + ) +}) /** * Here you define arbitrary code that runs once, on uninstall only diff --git a/startos/vault.ts b/startos/vault.ts index 201a153..085dd48 100644 --- a/startos/vault.ts +++ b/startos/vault.ts @@ -1,4 +1,8 @@ /** - * Here you define a set of sensitive keys/values to be stored in the service vault. Values are encrypted with the StartOS master password + * Here you define a set of sensitive keys/values to be stored in the service vault. + * + * Values are encrypted with the user's StartOS master password and are visible to the user. */ -export interface Vault extends Record {} +export interface Vault extends Record { + secretPhrase: string +} From 0d466fca9b3a9d9439cb1417cb87a41c6ed1aef7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 21 May 2023 12:47:41 -0600 Subject: [PATCH 040/120] rc5 and more features with underlying file and utils --- package-lock.json | 10 +++---- package.json | 2 +- startos/manifest.ts | 2 +- .../config/file-models/config.yml.ts | 10 +++++++ startos/procedures/config/read.ts | 8 +++++- startos/procedures/config/save.ts | 28 +++++++++++++------ startos/procedures/config/spec.ts | 8 ++++-- startos/procedures/init.ts | 13 +++++---- startos/procedures/interfaces.ts | 4 ++- startos/procedures/main.ts | 2 +- startos/procedures/migrations/v4_0_0_1.ts | 2 +- startos/store.ts | 10 ++----- startos/utils.ts | 8 ++++++ startos/vault.ts | 5 +++- 14 files changed, 77 insertions(+), 35 deletions(-) create mode 100644 startos/procedures/config/file-models/config.yml.ts create mode 100644 startos/utils.ts diff --git a/package-lock.json b/package-lock.json index 45593a8..695b99c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "hello-world-wrapper", + "name": "hello-world-startos", "lockfileVersion": 3, "requires": true, "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc4" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc5" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc4", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc4.tgz", - "integrity": "sha512-ouOpplLYCFFj5PutVtN5S0TI1UsdXA5nauOrFqKvLyhxazGjHprCpQ/fVHNSspPl/+ujNb7upzFxdZnWOE2oXw==", + "version": "0.4.0-rev0.lib0.rc5", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc5.tgz", + "integrity": "sha512-2hAJE1id0VgpU8DJt/I+m/IEePmnspzF8BxUoLO3C+ZgyOZU1tEri1f9QCsS6OLn3J11xPlpY1VuSjP5CyHC+Q==", "dependencies": { "@iarna/toml": "^2.2.5", "ts-matches": "^5.4.1", diff --git a/package.json b/package.json index b2dace3..111bf10 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc4" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc5" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/manifest.ts b/startos/manifest.ts index b04272c..28e42a3 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,7 +1,7 @@ import { setupManifest } from '@start9labs/start-sdk/lib/manifest/setupManifest' /** - * In this function you define static properties of the service + * In this function you define static properties of the service to be displayed in the Marketplace and used by StartOS */ export const manifest = setupManifest({ id: 'hello-world', diff --git a/startos/procedures/config/file-models/config.yml.ts b/startos/procedures/config/file-models/config.yml.ts new file mode 100644 index 0000000..0b36a71 --- /dev/null +++ b/startos/procedures/config/file-models/config.yml.ts @@ -0,0 +1,10 @@ +import { matches } from '@start9labs/start-sdk' +import FileHelper from '@start9labs/start-sdk/lib/util/fileHelper' + +const { object, string } = matches + +const yamlShape = object({ + name: string, +}) + +export const yamlFile = FileHelper.toml('config.yml', yamlShape) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 28ac479..c3ee3c1 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -1,4 +1,5 @@ import { sdk } from '../../sdk' +import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' /** @@ -9,6 +10,11 @@ import { configSpec } from './spec' export const read = sdk.setupConfigRead( configSpec, async ({ effects, utils }) => { - return utils.store.getOwn('/config').once() + // Retrieve data from the service's native config file. So, even if the user changes this file from the service's GUI or from the command line, the StartOS config will update as well. + const configYml = await yamlFile.read(effects) + // Return the expected config spec to display to the user + return { + name: configYml?.name || '', + } }, ) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index f3089dc..a9519b3 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,5 +1,7 @@ import { sdk } from '../../sdk' +import { getSecretPhrase } from '../../utils' import { setInterfaces } from '../interfaces' +import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' /** @@ -10,19 +12,29 @@ import { configSpec } from './spec' export const save = sdk.setupConfigSave( configSpec, async ({ effects, utils, input, dependencies }) => { - // save data wherever you want - await utils.store.setOwn('/config', input) - await utils.vault.set( - 'secretPhrase', - `Knock knock. Who's there? ${input.name}!`, - ) + /** + ******** save data wherever you want ******** + */ - // set current dependencies based on config settings + // Whenever possible, save data directly to the underlying config file(s) of the upstream service. + // This ensures that changes to the file from the service's GUI or from the command line are respected. + await yamlFile.write(input, effects) + // If absolutely necessary, save package specific data to the package Store. Stateless packages are preferable + await utils.store.setOwn('/nameLastUpdatedAt', new Date().toISOString()) + // Use the vault to persist sensitive values that are not commonly persisted by the upstream service, such as access credentials + await utils.vault.set('secretPhrase', getSecretPhrase(input.name)) + + /** + ******** set current dependencies based on config ******** + */ const dependenciesReceipt = await effects.setDependencies([]) return { - interfacesReceipt: await setInterfaces({ effects, utils, input }), // This is plumbing, don't touch it + // The line below is just plumbing, don't touch it. It insures setInterfaces runs whenever config is saved + interfacesReceipt: await setInterfaces({ effects, utils, input }), + // provide dependencies receipt from above dependenciesReceipt, + // optionally restart the service on config save restart: true, } }, diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index cec27d8..c85e51f 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -2,9 +2,9 @@ import { sdk } from '../../sdk' const { Config, Value } = sdk /** - * Here you define the config specification that will ultimately present to the user as validated form inputs + * Here you define the config spec that will ultimately present to the user as validated form inputs * - * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (a subform), and union (a conditional subform) + * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (aka a "sub form"), and union (aka a conditional "sub form") */ export const configSpec = Config.of({ name: Value.text({ @@ -15,5 +15,7 @@ export const configSpec = Config.of({ }), }) -// This line is necessary to satisfy Typescript typings. Do not touch it +/** + * This line is necessary to satisfy Typescript typings. Do not touch it + */ export type ConfigSpec = typeof configSpec.validator._TYPE diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 1b4d7fc..46da6a2 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,15 +1,18 @@ import { sdk } from '../sdk' +import { getSecretPhrase } from '../utils' +import { yamlFile } from './config/file-models/config.yml' import { setInterfaces } from './interfaces' import { migrations } from './migrations' /** - * Here you define arbitrary code that runs once, on fresh install only + * Here you define arbitrary code that runs *once*, on fresh install only */ const install = sdk.setupInstall(async ({ effects, utils }) => { - await utils.vault.set( - 'secretPhrase', - `Knock knock. Who's there? Nobody knows!`, - ) + const name = 'World' + + await yamlFile.write({ name }, effects) + + await utils.vault.set('secretPhrase', getSecretPhrase(name)) }) /** diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index d45b8e2..1dba9c3 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -9,7 +9,7 @@ export const webUiInterfaceId = 'webui' * * In this section, you will decide how the service will be exposed to the outside world * - * This function runs on service install/update AND on config save + * This function runs on service install/update *and* on config save */ export const setInterfaces = sdk.setupInterfaces( configSpec, @@ -21,6 +21,8 @@ export const setInterfaces = sdk.setupInterfaces( id: webUiInterfaceId, description: 'The web interface of Hello World', ui: true, + hasPrimary: false, + disabled: false, username: null, path: '', search: {}, diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 78fce31..435935b 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -16,7 +16,7 @@ export const main: ExpectedExports.main = sdk.setupMain( /** * ======================== Additional Health Checks (optional) ======================== * - * In this section, you will define additional health checks beyond those associated with daemons + * In this section, you will define *additional* health checks beyond those associated with daemons */ const healthReceipts: HealthReceipt[] = [] diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index adab490..eb4cdfe 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -5,7 +5,7 @@ import { sdk } from '../../sdk' * * By convention, each version service requiring a migration receives its own file * - * The resulting migration (e.g. v4000) is exported, then imported into migration/index.ts + * The resulting migration (e.g. v4_0_0_0) is exported, then imported into migrations/index.ts */ export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', diff --git a/startos/store.ts b/startos/store.ts index 4675152..9c7224e 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,12 +1,8 @@ -import { ConfigSpec } from './procedures/config/spec' - /** - * Here you define the set of data that the service wrapper will persist for self consumption and for exporting to users and other services + * The Store is for saving any necessary data NOT saved by the upstream service. Do NOT persist data in the package that is already being persisted by the service * - * It is conventional for the "config" key to store the service's saved config, excluding sensitive data like passwords + * Ideally this is empty. Stateless packages are easier to maintain and eliminate unexpected behavior */ export interface Store { - config: { - name: string - } + nameLastUpdatedAt: string } diff --git a/startos/utils.ts b/startos/utils.ts new file mode 100644 index 0000000..e7e4d98 --- /dev/null +++ b/startos/utils.ts @@ -0,0 +1,8 @@ +/** + * Here you can define and export and shared constants or functions used throughout the codebase + * + */ + +export function getSecretPhrase(name: string): string { + return `Knock knock. Who's there? ${name}!` +} diff --git a/startos/vault.ts b/startos/vault.ts index 085dd48..f558e38 100644 --- a/startos/vault.ts +++ b/startos/vault.ts @@ -1,7 +1,10 @@ /** * Here you define a set of sensitive keys/values to be stored in the service vault. * - * Values are encrypted with the user's StartOS master password and are visible to the user. + * Vaults are needed because services seldom store their own access credentials for good reason. + * You can think of the Vault as a bare bones password manager built into your StartOS package. + * + * Values are encrypted with the user's StartOS master password and are visible to the user in the service console. */ export interface Vault extends Record { secretPhrase: string From b3cb1c5d89ca156a1d424c6bd829303c53ea8a98 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 21 May 2023 15:45:17 -0600 Subject: [PATCH 041/120] don't type vault --- startos/utils.ts | 1 - startos/vault.ts | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/startos/utils.ts b/startos/utils.ts index e7e4d98..f293c6b 100644 --- a/startos/utils.ts +++ b/startos/utils.ts @@ -1,6 +1,5 @@ /** * Here you can define and export and shared constants or functions used throughout the codebase - * */ export function getSecretPhrase(name: string): string { diff --git a/startos/vault.ts b/startos/vault.ts index f558e38..8c5026c 100644 --- a/startos/vault.ts +++ b/startos/vault.ts @@ -1,11 +1,13 @@ /** * Here you define a set of sensitive keys/values to be stored in the service vault. * + * Vault values must be strings. + * * Vaults are needed because services seldom store their own access credentials for good reason. * You can think of the Vault as a bare bones password manager built into your StartOS package. * * Values are encrypted with the user's StartOS master password and are visible to the user in the service console. */ -export interface Vault extends Record { +export interface Vault { secretPhrase: string } From 740334bbd2e737a0c0dedf02dc7568b477a12862 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 21 May 2023 15:50:13 -0600 Subject: [PATCH 042/120] type for vault and store --- startos/store.ts | 2 +- startos/vault.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/startos/store.ts b/startos/store.ts index 9c7224e..b020201 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -3,6 +3,6 @@ * * Ideally this is empty. Stateless packages are easier to maintain and eliminate unexpected behavior */ -export interface Store { +export type Store = { nameLastUpdatedAt: string } diff --git a/startos/vault.ts b/startos/vault.ts index 8c5026c..50304cd 100644 --- a/startos/vault.ts +++ b/startos/vault.ts @@ -8,6 +8,6 @@ * * Values are encrypted with the user's StartOS master password and are visible to the user in the service console. */ -export interface Vault { +export type Vault = { secretPhrase: string } From 775ab9a08bba6810e0ba6458d36f287d3dd15dc2 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 8 Jun 2023 20:24:36 -0600 Subject: [PATCH 043/120] remove vault and export store items --- package-lock.json | 61 ++++++++++++++++++++++-- package.json | 2 +- startos/procedures/actions/nameToLogs.ts | 3 +- startos/procedures/config/save.ts | 10 ++-- startos/procedures/init.ts | 24 +++++++++- startos/sdk.ts | 2 - startos/store.ts | 3 +- startos/vault.ts | 13 ----- 8 files changed, 90 insertions(+), 28 deletions(-) delete mode 100644 startos/vault.ts diff --git a/package-lock.json b/package-lock.json index 695b99c..367de76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc5" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc6" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,11 +20,12 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc5", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc5.tgz", - "integrity": "sha512-2hAJE1id0VgpU8DJt/I+m/IEePmnspzF8BxUoLO3C+ZgyOZU1tEri1f9QCsS6OLn3J11xPlpY1VuSjP5CyHC+Q==", + "version": "0.4.0-rev0.lib0.rc6", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc6.tgz", + "integrity": "sha512-fXZUnYa0l/nCzrqIXMixNABEOrq4VYkN/JcstokKV3GQb2043IkCAlJDaqdvypZn99MIeNGVk7GtYZZKAAhDkg==", "dependencies": { "@iarna/toml": "^2.2.5", + "isomorphic-fetch": "^3.0.0", "ts-matches": "^5.4.1", "yaml": "^2.2.2" } @@ -44,6 +45,34 @@ "ncc": "dist/ncc/cli.js" } }, + "node_modules/isomorphic-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", + "dependencies": { + "node-fetch": "^2.6.1", + "whatwg-fetch": "^3.4.1" + } + }, + "node_modules/node-fetch": { + "version": "2.6.11", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", + "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/prettier": { "version": "2.8.7", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", @@ -59,6 +88,11 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, "node_modules/ts-matches": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", @@ -77,6 +111,25 @@ "node": ">=4.2.0" } }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-fetch": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", + "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/yaml": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", diff --git a/package.json b/package.json index 111bf10..78fb6d4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc5" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc6" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index ba748a1..990ce68 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -1,5 +1,6 @@ import { sdk } from '../../sdk' const { Config, Value } = sdk +import { yamlFile } from '../config/file-models/config.yml' /** * This is an example Action @@ -33,7 +34,7 @@ export const nameToLogs = sdk.createAction( }, async ({ effects, utils, input }) => { const name = - input.nameToPrint || (await utils.store.getOwn('/config/name').once()) + input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' console.info(`Hello ${name}`) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index a9519b3..5943086 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -15,14 +15,14 @@ export const save = sdk.setupConfigSave( /** ******** save data wherever you want ******** */ - // Whenever possible, save data directly to the underlying config file(s) of the upstream service. // This ensures that changes to the file from the service's GUI or from the command line are respected. await yamlFile.write(input, effects) - // If absolutely necessary, save package specific data to the package Store. Stateless packages are preferable - await utils.store.setOwn('/nameLastUpdatedAt', new Date().toISOString()) - // Use the vault to persist sensitive values that are not commonly persisted by the upstream service, such as access credentials - await utils.vault.set('secretPhrase', getSecretPhrase(input.name)) + // If necessary, save package specific data to the package Store. Stateless packages are preferable + await Promise.all([ + utils.store.setOwn('/nameLastUpdatedAt', new Date().toISOString()), + utils.store.setOwn('/secretPhrase', getSecretPhrase(input.name)), + ]) /** ******** set current dependencies based on config ******** diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 46da6a2..52aa736 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -12,7 +12,7 @@ const install = sdk.setupInstall(async ({ effects, utils }) => { await yamlFile.write({ name }, effects) - await utils.vault.set('secretPhrase', getSecretPhrase(name)) + await utils.store.setOwn('/secretPhrase', getSecretPhrase(name)) }) /** @@ -20,6 +20,27 @@ const install = sdk.setupInstall(async ({ effects, utils }) => { */ const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) +/** + * Here you determine which values from your store, if any, should be exposed to the user or to dependent services + * + * Values exposed to the user should be credentials and will be displayed in the user's "Vault" + */ +const exported = sdk.setupExports(({ effects, utils }) => { + return { + ui: [ + { + path: '/secretPhrase', + title: 'Secret Phrase', + }, + ], + services: [ + { + path: '/nameLastUpdatedAt', + }, + ], + } +}) + /** * This is a static function. There is no need to make changes here */ @@ -28,4 +49,5 @@ export const { init, uninit } = sdk.setupInit( install, uninstall, setInterfaces, + exported, ) diff --git a/startos/sdk.ts b/startos/sdk.ts index f65c09f..bf3fe8f 100644 --- a/startos/sdk.ts +++ b/startos/sdk.ts @@ -1,7 +1,6 @@ import { StartSdk } from '@start9labs/start-sdk/lib/StartSdk' import { manifest } from './manifest' import { Store } from './store' -import { Vault } from './vault' /** * This is a static file that provides type safety throughout the codebase @@ -11,5 +10,4 @@ import { Vault } from './vault' export const sdk = StartSdk.of() .withManifest(manifest) .withStore() - .withVault() .build(true) diff --git a/startos/store.ts b/startos/store.ts index b020201..2c9b921 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,8 +1,9 @@ /** * The Store is for saving any necessary data NOT saved by the upstream service. Do NOT persist data in the package that is already being persisted by the service * - * Ideally this is empty. Stateless packages are easier to maintain and eliminate unexpected behavior + * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior */ export type Store = { nameLastUpdatedAt: string + secretPhrase: string } diff --git a/startos/vault.ts b/startos/vault.ts deleted file mode 100644 index 50304cd..0000000 --- a/startos/vault.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Here you define a set of sensitive keys/values to be stored in the service vault. - * - * Vault values must be strings. - * - * Vaults are needed because services seldom store their own access credentials for good reason. - * You can think of the Vault as a bare bones password manager built into your StartOS package. - * - * Values are encrypted with the user's StartOS master password and are visible to the user in the service console. - */ -export type Vault = { - secretPhrase: string -} From 498351c708929f82ce40225fb1f771609153a516 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 9 Jun 2023 11:58:29 -0600 Subject: [PATCH 044/120] rc7 --- package-lock.json | 8 ++++---- package.json | 2 +- startos/procedures/init.ts | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 367de76..a3844dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc6" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc7" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc6", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc6.tgz", - "integrity": "sha512-fXZUnYa0l/nCzrqIXMixNABEOrq4VYkN/JcstokKV3GQb2043IkCAlJDaqdvypZn99MIeNGVk7GtYZZKAAhDkg==", + "version": "0.4.0-rev0.lib0.rc7", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc7.tgz", + "integrity": "sha512-SgWkMuCY0VyUF4QzGqwuy/lFBaX2Cve0aJPYsiShnFV3d4xhQZUi568lNzm/qZ9kZQ5t8sFhseHmIM6+lQn2Kw==", "dependencies": { "@iarna/toml": "^2.2.5", "isomorphic-fetch": "^3.0.0", diff --git a/package.json b/package.json index 78fb6d4..2646854 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc6" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc7" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 52aa736..7b997ee 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -22,11 +22,10 @@ const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) /** * Here you determine which values from your store, if any, should be exposed to the user or to dependent services - * - * Values exposed to the user should be credentials and will be displayed in the user's "Vault" */ const exported = sdk.setupExports(({ effects, utils }) => { return { + // Values exported to the UI will be displayed (masked) in the user's "Vault". It is designed for credentials ui: [ { path: '/secretPhrase', From 7443952216ba26674a42b08fa0c0512e7046c34e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 6 Sep 2023 08:47:17 -0600 Subject: [PATCH 045/120] clean up a little --- .gitmodules | 3 -- Dockerfile | 12 +----- Makefile | 87 +------------------------------------------ README.md | 104 ++++------------------------------------------------ hello-world | 1 - 5 files changed, 9 insertions(+), 198 deletions(-) delete mode 100644 .gitmodules delete mode 160000 hello-world diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 56fa461..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "hello-world"] - path = hello-world - url = https://github.com/Start9Labs/hello-world diff --git a/Dockerfile b/Dockerfile index f6fe710..6f22d8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1 @@ -FROM alpine:3.17 - -RUN apk update -RUN apk add --no-cache tini && \ - rm -f /var/cache/apk/* - -ARG ARCH -ADD ./hello-world/target/${ARCH}-unknown-linux-musl/release/hello-world /usr/local/bin/hello-world -RUN chmod +x /usr/local/bin/hello-world -ADD ./docker_entrypoint.sh /usr/local/bin/docker_entrypoint.sh -RUN chmod a+x /usr/local/bin/docker_entrypoint.sh +FROM start9/hello-world diff --git a/Makefile b/Makefile index 61cb38a..4640904 100644 --- a/Makefile +++ b/Makefile @@ -1,86 +1 @@ -PKG_ID := $(shell grep ".id:" startos/manifest.ts | grep -o "'[^']*'" | sed "s/'//g") -PKG_VERSION := $(shell grep ".version:" startos/manifest.ts | grep -o "'[^']*'" | sed "s/'//g") -TS_FILES := $(shell find ./ -name \*.ts) -HELLO_WORLD_SRC := $(shell find ./hello-world/src) hello-world/Cargo.toml hello-world/Cargo.lock - -# delete the target of a rule if it has changed and its recipe exits with a nonzero exit status -.DELETE_ON_ERROR: - -all: submodule-update verify - -verify: $(PKG_ID).s9pk - @embassy-sdk verify s9pk $(PKG_ID).s9pk - @echo " Done!" - @echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready" - -install: -ifeq (,$(wildcard ~/.embassy/config.yaml)) - @echo; echo "You must define \"host: http://embassy-server-name.local\" in ~/.embassy/config.yaml config file first"; echo -else - embassy-cli package install $(PKG_ID).s9pk -endif - -clean: - rm -rf docker-images - rm -f $(PKG_ID).s9pk - rm -f scripts/*.js - -submodule-update: - @if [ -z "$(shell git submodule status | egrep -v '^ '|awk '{print $$2}')" ]; then \ - echo "Submodules are up to date."; \ - else \ - echo "\nUpdating submodules...\n"; \ - git submodule update --init --progress; \ - fi - -# BEGIN REBRANDING -rebranding: - @read -p "Enter new package ID name (must be a single word): " NEW_PKG_ID; \ - read -p "Enter new package title: " NEW_PKG_TITLE; \ - find . \( -name "*.md" -o -name ".gitignore" -o -name "manifest.yaml" -o -name "*Service.yml" \) -type f -not -path "./hello-world/*" -exec sed -i '' -e "s/hello-world/$$NEW_PKG_ID/g; s/Hello World/$$NEW_PKG_TITLE/g" {} +; \ - echo; echo "Rebranding complete."; echo " New package ID name is: $$NEW_PKG_ID"; \ - echo " New package title is: $$NEW_PKG_TITLE"; \ - sed -i '' -e '/^# BEGIN REBRANDING/,/^# END REBRANDING/ s/^#*/#/' Makefile - @echo; echo "Note: Rebranding code has been commented out in Makefile"; echo -# END REBRANDING - -scripts/embassy.js: $(TS_FILES) - deno bundle scripts/embassy.ts scripts/embassy.js - -arm: - @rm -f docker-images/x86_64.tar - ARCH=aarch64 $(MAKE) - -x86: - @rm -f docker-images/aarch64.tar - ARCH=x86_64 $(MAKE) - -docker-images/aarch64.tar: Dockerfile docker_entrypoint.sh hello-world/target/aarch64-unknown-linux-musl/release/hello-world -ifeq ($(ARCH),x86_64) -else - mkdir -p docker-images - docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --build-arg ARCH=aarch64 --platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar . -endif - -docker-images/x86_64.tar: Dockerfile docker_entrypoint.sh hello-world/target/x86_64-unknown-linux-musl/release/hello-world -ifeq ($(ARCH),aarch64) -else - mkdir -p docker-images - docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) --build-arg ARCH=x86_64 --platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar . -endif - -$(PKG_ID).s9pk: assets/instructions.md assets/icon.png LICENSE scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar -ifeq ($(ARCH),aarch64) - @echo "embassy-sdk: Preparing aarch64 package ..." -else ifeq ($(ARCH),x86_64) - @echo "embassy-sdk: Preparing x86_64 package ..." -else - @echo "embassy-sdk: Preparing Universal Package ..." -endif - @embassy-sdk pack - -hello-world/target/aarch64-unknown-linux-musl/release/hello-world: $(HELLO_WORLD_SRC) - docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/hello-world:/home/rust/src messense/rust-musl-cross:aarch64-musl cargo build --release - -hello-world/target/x86_64-unknown-linux-musl/release/hello-world: $(HELLO_WORLD_SRC) - docker run --rm -it -v ~/.cargo/registry:/root/.cargo/registry -v "$(shell pwd)"/hello-world:/home/rust/src messense/rust-musl-cross:x86_64-musl cargo build --release +# TODO diff --git a/README.md b/README.md index 2853b08..0ac6315 100644 --- a/README.md +++ b/README.md @@ -1,113 +1,23 @@ -# Wrapper for hello-world +# Hello World StartOS -Hello World is a simple, minimal project that serves as a template for creating a service that runs on embassyOS. This repository creates the `s9pk` package that is installed to run `hello-world` on [embassyOS](https://github.com/Start9Labs/embassy-os/). Learn more about service packaging in the [Developer Docs](https://start9.com/latest/developer-docs/). +A bare bones project serving as a template for [StartOS](https://github.com/Start9Labs/start-os/) service packaging. Learn more about service packaging in the [Developer Docs](https://docs.start9.com/latest/developer-docs/). -## Dependencies +## Environment Setup Install the system dependencies below to build this project by following the instructions in the provided links. You can also find detailed steps to setup your environment in the service packaging [documentation](https://github.com/Start9Labs/service-pipeline#development-environment). +- [node](https://nodejs.org/en) (using NVM, recommended) - [docker](https://docs.docker.com/get-docker) - [docker-buildx](https://docs.docker.com/buildx/working-with-buildx/) -- [yq](https://mikefarah.gitbook.io/yq) -- [deno](https://deno.land/) - [make](https://www.gnu.org/software/make/) -- [embassy-sdk](https://github.com/Start9Labs/embassy-os/tree/master/backend) - -## Build environment -Prepare your embassyOS build environment. In this example we are using Ubuntu 20.04. -1. Install docker -``` -curl -fsSL https://get.docker.com | bash -sudo usermod -aG docker "$USER" -exec sudo su -l $USER -``` -2. Set buildx as the default builder -``` -docker buildx install -docker buildx create --use -``` -3. Enable cross-arch emulated builds in docker -``` -docker run --privileged --rm linuxkit/binfmt:v0.8 -``` -4. Install yq -``` -sudo snap install yq -``` -5. Install deno -``` -sudo snap install deno -``` -6. Install essentials build packages -``` -sudo apt-get install -y build-essential openssl libssl-dev libc6-dev clang libclang-dev ca-certificates -``` -7. Install Rust -``` -curl https://sh.rustup.rs -sSf | sh -# Choose nr 1 (default install) -source $HOME/.cargo/env -``` -8. Build and install embassy-sdk -``` -cd ~/ && git clone --recursive https://github.com/Start9Labs/embassy-os.git -cd embassy-os/backend/ -./install-sdk.sh -embassy-sdk init -``` -Now you are ready to build the `hello-world` package! +- [start-sdk](https://github.com/Start9Labs/start-sdk) ## Cloning -Clone the project locally: - ``` -git clone https://github.com/Start9Labs/hello-world-wrapper.git +git clone https://github.com/Start9Labs/hello-world-startos.git cd hello-world-wrapper -git submodule update --init --recursive ``` ## Building - -To build the `hello-world` package for all platforms using embassy-sdk version >=0.3.3, run the following command: - -``` -make -``` - -To build the `hello-world` package for a single platform using embassy-sdk version <=0.3.2, run: - -``` -# for amd64 -make ARCH=x86_64 -``` -or -``` -# for arm64 -make ARCH=aarch64 -``` - -## Installing (on embassyOS) - -Run the following commands to determine successful install: -> :information_source: Change embassy-server-name.local to your Embassy address - -``` -embassy-cli auth login -# Enter your embassy password -embassy-cli --host https://embassy-server-name.local package install hello-world.s9pk -``` - -If you already have your `embassy-cli` config file setup with a default `host`, you can install simply by running: - -``` -make install -``` - -> **Tip:** You can also install the hello-world.s9pk using **Sideload Service** under the **System > Manage** section. - -### Verify Install - -Go to your Embassy Services page, select **Hello World**, configure and start the service. Then, verify its interfaces are accessible. - -**Done!** + \ No newline at end of file diff --git a/hello-world b/hello-world deleted file mode 160000 index 48ce8a5..0000000 --- a/hello-world +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 48ce8a519b14eb6c32d770af66656e04a7866228 From 223ed21b953830e03a0ba037432e5f1748e24179 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 6 Sep 2023 10:04:15 -0600 Subject: [PATCH 046/120] more cleanup --- README.md | 2 +- startos/manifest.ts | 1 + startos/procedures/backups.ts | 10 ++++++++++ .../procedures/dependencies/dependencyConfig/index.ts | 4 +--- startos/procedures/interfaces.ts | 4 ++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0ac6315..892b12f 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Install the system dependencies below to build this project by following the ins ``` git clone https://github.com/Start9Labs/hello-world-startos.git -cd hello-world-wrapper +cd hello-world-startos ``` ## Building diff --git a/startos/manifest.ts b/startos/manifest.ts index 28e42a3..762d7f3 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -19,6 +19,7 @@ export const manifest = setupManifest({ short: 'Example service for s9pk highlighting basic features', long: 'Hello World is a template service that provides examples of basic StartOS features.', }, + // Relative paths to asset files assets: { license: 'LICENSE', icon: 'assets/icon.png', diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 79ca22d..bd0c3ee 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -4,3 +4,13 @@ import { sdk } from '../sdk' * Here we define what volumes from the Manifest to include in backups */ export const { createBackup, restoreBackup } = sdk.setupBackups('main') + +/** + * Excluding a hypothetical directory in the "main" volume, "excludedDir", that we do not want to back up + */ +// import { Backups } from '@start9labs/start-sdk/lib/backup/Backups' +// export const { createBackup, restoreBackup } = sdk.setupBackups( +// Backups.volumes('main').setOptions({ +// exclude: ['path/to/excludedDir'], +// }), +// ) diff --git a/startos/procedures/dependencies/dependencyConfig/index.ts b/startos/procedures/dependencies/dependencyConfig/index.ts index 819dc2a..423e60f 100644 --- a/startos/procedures/dependencies/dependencyConfig/index.ts +++ b/startos/procedures/dependencies/dependencyConfig/index.ts @@ -2,8 +2,6 @@ import { sdk } from '../../../sdk' import { configSpec } from '../../config/spec' /** - * In this function, you establish rules for auto configuring service dependencies - * - * See Hello Moon for an example + * In this function, you establish rules for auto configuring service dependencies. See Hello Moon for an example */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 1dba9c3..b930b6d 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -9,12 +9,12 @@ export const webUiInterfaceId = 'webui' * * In this section, you will decide how the service will be exposed to the outside world * - * This function runs on service install/update *and* on config save + * This function runs on service install, update, and config save */ export const setInterfaces = sdk.setupInterfaces( configSpec, async ({ effects, utils, input }) => { - const multi = utils.host.multi('multi') // technically just a multi hostname + const multi = utils.host.multi('multi') const multiOrigin = await multi.bindPort(uiPort, { protocol: 'http' }) const multiInterface = utils.createInterface({ name: 'Web UI', From f052876d574c082247f0061c4618a4d19b528c19 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 6 Sep 2023 10:35:05 -0600 Subject: [PATCH 047/120] Update sdk --- package.json | 2 +- startos/procedures/config/spec.ts | 7 +------ startos/procedures/interfaces.ts | 10 +++++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 2646854..b8d0639 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc7" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index c85e51f..8c28670 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -11,11 +11,6 @@ export const configSpec = Config.of({ name: 'Name', description: 'When you launch the Hello World UI, it will display "Hello [First Name]"', - required: { default: null }, + required: { default: 'World' }, }), }) - -/** - * This line is necessary to satisfy Typescript typings. Do not touch it - */ -export type ConfigSpec = typeof configSpec.validator._TYPE diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index b930b6d..4e58460 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -14,9 +14,9 @@ export const webUiInterfaceId = 'webui' export const setInterfaces = sdk.setupInterfaces( configSpec, async ({ effects, utils, input }) => { - const multi = utils.host.multi('multi') - const multiOrigin = await multi.bindPort(uiPort, { protocol: 'http' }) - const multiInterface = utils.createInterface({ + const uiMulti = utils.host.multi('uiMulti') + const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) + const ui = utils.createInterface({ name: 'Web UI', id: webUiInterfaceId, description: 'The web interface of Hello World', @@ -28,8 +28,8 @@ export const setInterfaces = sdk.setupInterfaces( search: {}, }) - const multiReceipt = await multiInterface.export([multiOrigin]) + const uiReceipt = await ui.export([uiMultiOrigin]) - return [multiReceipt] + return [uiReceipt] }, ) From f02c313d1d242ca884a746edc0b5c2b54c47fd8b Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 6 Sep 2023 10:40:57 -0600 Subject: [PATCH 048/120] fix type error --- package-lock.json | 8 ++++---- startos/procedures/interfaces.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index a3844dc..5503cac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc7" + "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" }, "devDependencies": { "@types/node": "^20.0.0", @@ -20,9 +20,9 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc7", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc7.tgz", - "integrity": "sha512-SgWkMuCY0VyUF4QzGqwuy/lFBaX2Cve0aJPYsiShnFV3d4xhQZUi568lNzm/qZ9kZQ5t8sFhseHmIM6+lQn2Kw==", + "version": "0.4.0-rev0.lib0.rc8.beta2", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc8.beta2.tgz", + "integrity": "sha512-2jo8gF/lOvzuOKKntPuQyejwDAY6Uxaz4KKqm2awoYN6Ycn1TrYud0KAdSjKFYDCKmJI/guQNej0XGVJe0B1XQ==", "dependencies": { "@iarna/toml": "^2.2.5", "isomorphic-fetch": "^3.0.0", diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 4e58460..9af8144 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -20,7 +20,7 @@ export const setInterfaces = sdk.setupInterfaces( name: 'Web UI', id: webUiInterfaceId, description: 'The web interface of Hello World', - ui: true, + type: 'ui', hasPrimary: false, disabled: false, username: null, From d62f046e1af9fbf7c97152198fb26e02320bee1a Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 12 Sep 2023 09:36:46 -0600 Subject: [PATCH 049/120] minor typo --- startos/procedures/init.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 7b997ee..4a166c5 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -25,7 +25,7 @@ const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) */ const exported = sdk.setupExports(({ effects, utils }) => { return { - // Values exported to the UI will be displayed (masked) in the user's "Vault". It is designed for credentials + // Values exported to the UI will be displayed (masked) in the user's "Credentials". It is designed for credentials ui: [ { path: '/secretPhrase', From d20799b9388afebb59f2d8388390d4e7d2984dc9 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 18 Mar 2024 12:39:56 -0600 Subject: [PATCH 050/120] latest sdk changes --- startos/manifest.ts | 29 ++----- startos/procedures/actions/nameToLogs.ts | 1 + startos/procedures/backups.ts | 3 +- .../config/file-models/config.yml.ts | 7 +- startos/procedures/init.ts | 19 +++-- startos/procedures/interfaces.ts | 4 +- startos/procedures/main.ts | 85 +++++++++---------- startos/procedures/migrations/v4_0_0_1.ts | 3 +- startos/sdk.ts | 2 +- 9 files changed, 69 insertions(+), 84 deletions(-) diff --git a/startos/manifest.ts b/startos/manifest.ts index 762d7f3..d6c8161 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,4 +1,4 @@ -import { setupManifest } from '@start9labs/start-sdk/lib/manifest/setupManifest' +import { setupManifest } from '@start9labs/start-sdk' /** * In this function you define static properties of the service to be displayed in the Marketplace and used by StartOS @@ -19,27 +19,12 @@ export const manifest = setupManifest({ short: 'Example service for s9pk highlighting basic features', long: 'Hello World is a template service that provides examples of basic StartOS features.', }, - // Relative paths to asset files - assets: { - license: 'LICENSE', - icon: 'assets/icon.png', - instructions: 'assets/instructions.md', - }, - volumes: { - // This is the image where files from the project asset directory will go - main: 'data', - }, - containers: { - main: { - // Identifier for the main image volume, which will be used when other actions need to mount to this volume. - image: 'main', - // Specifies where to mount the data volume(s), if there are any. Mounts for pointer dependency volumes are also denoted here. These are necessary if data needs to be read from / written to these volumes. - mounts: { - // Specifies where on the service's file system its persistence directory should be mounted prior to service startup - main: '/data', - }, - }, - }, + // directories of static files you want to mount to your container + assets: [], + // List of identifiers of your persistence volumes that can be mounted to your container + volumes: ['main'], + // List of identifiers of your application images, which will be used when other actions need to run in this image + images: ['main'], alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 990ce68..cb7b110 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -31,6 +31,7 @@ export const nameToLogs = sdk.createAction( id: 'nameToLogs', input, allowedStatuses: 'only-running', + group: null, }, async ({ effects, utils, input }) => { const name = diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index bd0c3ee..56f5a24 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -8,9 +8,8 @@ export const { createBackup, restoreBackup } = sdk.setupBackups('main') /** * Excluding a hypothetical directory in the "main" volume, "excludedDir", that we do not want to back up */ -// import { Backups } from '@start9labs/start-sdk/lib/backup/Backups' // export const { createBackup, restoreBackup } = sdk.setupBackups( -// Backups.volumes('main').setOptions({ +// sdk.Backups.volumes('main').setOptions({ // exclude: ['path/to/excludedDir'], // }), // ) diff --git a/startos/procedures/config/file-models/config.yml.ts b/startos/procedures/config/file-models/config.yml.ts index 0b36a71..0f16863 100644 --- a/startos/procedures/config/file-models/config.yml.ts +++ b/startos/procedures/config/file-models/config.yml.ts @@ -1,10 +1,9 @@ -import { matches } from '@start9labs/start-sdk' -import FileHelper from '@start9labs/start-sdk/lib/util/fileHelper' +import { matches, FileHelper } from '@start9labs/start-sdk' const { object, string } = matches -const yamlShape = object({ +const shape = object({ name: string, }) -export const yamlFile = FileHelper.toml('config.yml', yamlShape) +export const yamlFile = FileHelper.yaml('config.yml', shape) diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 4a166c5..d1ca746 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -26,17 +26,18 @@ const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) const exported = sdk.setupExports(({ effects, utils }) => { return { // Values exported to the UI will be displayed (masked) in the user's "Credentials". It is designed for credentials - ui: [ - { + ui: { + 'Secret Phrase': { + type: 'string', path: '/secretPhrase', - title: 'Secret Phrase', + copyable: true, + qr: false, + masked: true, }, - ], - services: [ - { - path: '/nameLastUpdatedAt', - }, - ], + }, + services: { + paths: ['/nameLastUpdatedAt'], + }, } }) diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 9af8144..fc89a00 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -23,12 +23,14 @@ export const setInterfaces = sdk.setupInterfaces( type: 'ui', hasPrimary: false, disabled: false, + masked: false, + schemeOverride: null, username: null, path: '', search: {}, }) - const uiReceipt = await ui.export([uiMultiOrigin]) + const uiReceipt = await uiMultiOrigin.export([ui]) return [uiReceipt] }, diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 435935b..bc4483b 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -1,49 +1,46 @@ import { sdk } from '../sdk' -import { ExpectedExports } from '@start9labs/start-sdk/lib/types' -import { HealthReceipt } from '@start9labs/start-sdk/lib/health/HealthReceipt' -import { Daemons } from '@start9labs/start-sdk/lib/mainFn/Daemons' +import { HealthReceipt } from '@start9labs/start-sdk/cjs/sdk/lib/health/HealthReceipt' import { uiPort } from './interfaces' -export const main: ExpectedExports.main = sdk.setupMain( - async ({ effects, utils, started }) => { - /** - * ======================== Setup ======================== - * - * In this section, you will fetch any resources or run any commands necessary to run the service - */ - console.info('Starting Hello World!') +export const main = sdk.setupMain(async ({ effects, utils, started }) => { + /** + * ======================== Setup ======================== + * + * In this section, you will fetch any resources or run any commands necessary to run the service + */ + console.info('Starting Hello World!') - /** - * ======================== Additional Health Checks (optional) ======================== - * - * In this section, you will define *additional* health checks beyond those associated with daemons - */ - const healthReceipts: HealthReceipt[] = [] + /** + * ======================== Additional Health Checks (optional) ======================== + * + * In this section, you will define *additional* health checks beyond those associated with daemons + */ + const healthReceipts: HealthReceipt[] = [] - /** - * ======================== Daemons ======================== - * - * In this section, you will create one or more daemons that define the service runtime - * - * Each daemon defines its own health check, which can optionally be exposed to the user - */ - return Daemons.of({ - effects, - started, - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered - }).addDaemon('webui', { - command: 'hello-world', // The command to start the daemon - ready: { - // If display is null, it will not be displayed to the user in the UI - display: 'Web Interface', - // The function to run to determine the health status of the daemon - fn: () => - sdk.healthCheck.checkPortListening(effects, uiPort, { - successMessage: 'The web interface is ready', - errorMessage: 'The web interface is not ready', - }), - }, - requires: [], - }) - }, -) + /** + * ======================== Daemons ======================== + * + * In this section, you will create one or more daemons that define the service runtime + * + * Each daemon defines its own health check, which can optionally be exposed to the user + */ + return sdk.Daemons.of({ + effects, + started, + healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + }).addDaemon('webui', { + imageId: 'main', + command: 'hello-world', // The command to start the daemon + ready: { + // If display is null, it will not be displayed to the user in the UI + display: 'Web Interface', + // The function to run to determine the health status of the daemon + fn: () => + sdk.healthCheck.checkPortListening(effects, uiPort, { + successMessage: 'The web interface is ready', + errorMessage: 'The web interface is not ready', + }), + }, + requires: [], + }) +}) diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index eb4cdfe..8514bbc 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -9,6 +9,7 @@ import { sdk } from '../../sdk' */ export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', - up: async ({ effects, utils }) => await effects.setConfigured(false), + up: async ({ effects, utils }) => + await effects.setConfigured({ configured: false }), down: async ({ effects, utils }) => {}, }) diff --git a/startos/sdk.ts b/startos/sdk.ts index bf3fe8f..6811622 100644 --- a/startos/sdk.ts +++ b/startos/sdk.ts @@ -1,4 +1,4 @@ -import { StartSdk } from '@start9labs/start-sdk/lib/StartSdk' +import { StartSdk } from '@start9labs/start-sdk' import { manifest } from './manifest' import { Store } from './store' From d7b3c6063db17d1233e4b9c7cc6adda5b5a29b87 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 18 Mar 2024 15:49:52 -0600 Subject: [PATCH 051/120] update for sdk changes --- startos/procedures/actions/nameToLogs.ts | 2 +- startos/procedures/config/read.ts | 19 ++++++++----------- startos/procedures/config/save.ts | 12 +++++++----- .../index.ts => dependencyConfig.ts} | 4 ++-- .../dependencies/dependencyMounts.ts | 8 -------- startos/procedures/init.ts | 8 ++++---- startos/procedures/interfaces.ts | 6 +++--- startos/procedures/main.ts | 3 ++- startos/procedures/migrations/v4_0_0_1.ts | 5 ++--- 9 files changed, 29 insertions(+), 38 deletions(-) rename startos/procedures/dependencies/{dependencyConfig/index.ts => dependencyConfig.ts} (70%) delete mode 100644 startos/procedures/dependencies/dependencyMounts.ts diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index cb7b110..41f5411 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -33,7 +33,7 @@ export const nameToLogs = sdk.createAction( allowedStatuses: 'only-running', group: null, }, - async ({ effects, utils, input }) => { + async ({ effects, input }) => { const name = input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index c3ee3c1..8f2e9e7 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -7,14 +7,11 @@ import { configSpec } from './spec' * * Use this function to gather data from various files and assemble into a valid config to display to the user */ -export const read = sdk.setupConfigRead( - configSpec, - async ({ effects, utils }) => { - // Retrieve data from the service's native config file. So, even if the user changes this file from the service's GUI or from the command line, the StartOS config will update as well. - const configYml = await yamlFile.read(effects) - // Return the expected config spec to display to the user - return { - name: configYml?.name || '', - } - }, -) +export const read = sdk.setupConfigRead(configSpec, async ({ effects }) => { + // Retrieve data from the service's native config file. So, even if the user changes this file from the service's GUI or from the command line, the StartOS config will update as well. + const configYml = await yamlFile.read(effects) + // Return the expected config spec to display to the user + return { + name: configYml?.name || '', + } +}) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 5943086..d998ee6 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -11,7 +11,7 @@ import { configSpec } from './spec' */ export const save = sdk.setupConfigSave( configSpec, - async ({ effects, utils, input, dependencies }) => { + async ({ effects, input, dependencies }) => { /** ******** save data wherever you want ******** */ @@ -20,18 +20,20 @@ export const save = sdk.setupConfigSave( await yamlFile.write(input, effects) // If necessary, save package specific data to the package Store. Stateless packages are preferable await Promise.all([ - utils.store.setOwn('/nameLastUpdatedAt', new Date().toISOString()), - utils.store.setOwn('/secretPhrase', getSecretPhrase(input.name)), + sdk.store.setOwn(effects, '/nameLastUpdatedAt', new Date().toISOString()), + sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(input.name)), ]) /** ******** set current dependencies based on config ******** */ - const dependenciesReceipt = await effects.setDependencies([]) + const dependenciesReceipt = await effects.setDependencies({ + dependencies: [], + }) return { // The line below is just plumbing, don't touch it. It insures setInterfaces runs whenever config is saved - interfacesReceipt: await setInterfaces({ effects, utils, input }), + interfacesReceipt: await setInterfaces({ effects, input }), // provide dependencies receipt from above dependenciesReceipt, // optionally restart the service on config save diff --git a/startos/procedures/dependencies/dependencyConfig/index.ts b/startos/procedures/dependencies/dependencyConfig.ts similarity index 70% rename from startos/procedures/dependencies/dependencyConfig/index.ts rename to startos/procedures/dependencies/dependencyConfig.ts index 423e60f..ae01931 100644 --- a/startos/procedures/dependencies/dependencyConfig/index.ts +++ b/startos/procedures/dependencies/dependencyConfig.ts @@ -1,5 +1,5 @@ -import { sdk } from '../../../sdk' -import { configSpec } from '../../config/spec' +import { sdk } from '../../sdk' +import { configSpec } from '../config/spec' /** * In this function, you establish rules for auto configuring service dependencies. See Hello Moon for an example diff --git a/startos/procedures/dependencies/dependencyMounts.ts b/startos/procedures/dependencies/dependencyMounts.ts deleted file mode 100644 index 36e0304..0000000 --- a/startos/procedures/dependencies/dependencyMounts.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { sdk } from '../../sdk' - -/** - * Here you define the volumes and paths of any dependencies needed by this service - * - * See Hello Moon for an example - */ -export const dependencyMounts = sdk.setupDependencyMounts() diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index d1ca746..673a846 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -7,23 +7,23 @@ import { migrations } from './migrations' /** * Here you define arbitrary code that runs *once*, on fresh install only */ -const install = sdk.setupInstall(async ({ effects, utils }) => { +const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' await yamlFile.write({ name }, effects) - await utils.store.setOwn('/secretPhrase', getSecretPhrase(name)) + await sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(name)) }) /** * Here you define arbitrary code that runs once, on uninstall only */ -const uninstall = sdk.setupUninstall(async ({ effects, utils }) => {}) +const uninstall = sdk.setupUninstall(async ({ effects }) => {}) /** * Here you determine which values from your store, if any, should be exposed to the user or to dependent services */ -const exported = sdk.setupExports(({ effects, utils }) => { +const exported = sdk.setupExports(({ effects }) => { return { // Values exported to the UI will be displayed (masked) in the user's "Credentials". It is designed for credentials ui: { diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index fc89a00..4b46164 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -13,10 +13,10 @@ export const webUiInterfaceId = 'webui' */ export const setInterfaces = sdk.setupInterfaces( configSpec, - async ({ effects, utils, input }) => { - const uiMulti = utils.host.multi('uiMulti') + async ({ effects, input }) => { + const uiMulti = sdk.host.multi(effects, 'uiMulti') const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) - const ui = utils.createInterface({ + const ui = sdk.createInterface(effects, { name: 'Web UI', id: webUiInterfaceId, description: 'The web interface of Hello World', diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index bc4483b..93b3c3f 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -2,7 +2,7 @@ import { sdk } from '../sdk' import { HealthReceipt } from '@start9labs/start-sdk/cjs/sdk/lib/health/HealthReceipt' import { uiPort } from './interfaces' -export const main = sdk.setupMain(async ({ effects, utils, started }) => { +export const main = sdk.setupMain(async ({ effects, started }) => { /** * ======================== Setup ======================== * @@ -31,6 +31,7 @@ export const main = sdk.setupMain(async ({ effects, utils, started }) => { }).addDaemon('webui', { imageId: 'main', command: 'hello-world', // The command to start the daemon + mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { // If display is null, it will not be displayed to the user in the UI display: 'Web Interface', diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index 8514bbc..3c22c16 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -9,7 +9,6 @@ import { sdk } from '../../sdk' */ export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', - up: async ({ effects, utils }) => - await effects.setConfigured({ configured: false }), - down: async ({ effects, utils }) => {}, + up: async ({ effects }) => await effects.setConfigured({ configured: false }), + down: async ({ effects }) => {}, }) From 70ea3722f4b9299c2a017ce46397efef2de2aa06 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 18 Mar 2024 17:13:03 -0600 Subject: [PATCH 052/120] minor fix --- startos/procedures/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 9885389..6fcce83 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -4,4 +4,3 @@ export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' export { dependencyConfig } from './dependencies/dependencyConfig' -export { dependencyMounts } from './dependencies/dependencyMounts' From 5dc7b7374a42a7adee3295a1412ec16cfea42e78 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 19 Mar 2024 00:31:38 -0600 Subject: [PATCH 053/120] update comments --- startos/manifest.ts | 16 +++++-------- startos/procedures/actions/index.ts | 2 +- startos/procedures/actions/nameToLogs.ts | 19 +++++++-------- startos/procedures/backups.ts | 8 +++++-- startos/procedures/config/index.ts | 2 +- startos/procedures/config/read.ts | 5 ++-- startos/procedures/config/save.ts | 15 +++++------- startos/procedures/config/spec.ts | 4 ++-- .../dependencies/dependencyConfig.ts | 2 +- startos/procedures/index.ts | 3 +++ startos/procedures/init.ts | 10 ++++---- startos/procedures/interfaces.ts | 9 ++++---- startos/procedures/main.ts | 23 +++++++++---------- startos/procedures/migrations/index.ts | 2 +- startos/procedures/migrations/v4_0_0_1.ts | 6 ++--- startos/sdk.ts | 4 ++-- startos/store.ts | 4 ++-- startos/utils.ts | 4 +++- 18 files changed, 70 insertions(+), 68 deletions(-) diff --git a/startos/manifest.ts b/startos/manifest.ts index d6c8161..936503f 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,7 +1,7 @@ import { setupManifest } from '@start9labs/start-sdk' /** - * In this function you define static properties of the service to be displayed in the Marketplace and used by StartOS + * Here we define static properties of the package to be displayed in the Marketplace and used by StartOS. */ export const manifest = setupManifest({ id: 'hello-world', @@ -16,15 +16,12 @@ export const manifest = setupManifest({ marketingSite: 'https://start9.com/', donationUrl: 'https://donate.start9.com/', description: { - short: 'Example service for s9pk highlighting basic features', + short: 'Bare bones example StartOS service', long: 'Hello World is a template service that provides examples of basic StartOS features.', }, - // directories of static files you want to mount to your container - assets: [], - // List of identifiers of your persistence volumes that can be mounted to your container - volumes: ['main'], - // List of identifiers of your application images, which will be used when other actions need to run in this image - images: ['main'], + assets: [], // directories of static files you want to mount to your container + volumes: ['main'], // IDs of persistence volumes that will be mounted to your container + images: ['main'], // IDs of images, used when other actions need to run in this image alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', @@ -34,8 +31,7 @@ export const manifest = setupManifest({ start: 'Optional alert to display before starting the service', stop: 'Optional alert to display before stopping the service', }, - /** See Hello Moon for an example with dependencies */ - dependencies: {}, + dependencies: {}, // See Hello Moon for an example with dependencies }) export type Manifest = typeof manifest diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index ea6ffba..dcddec5 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -2,6 +2,6 @@ import { sdk } from '../../sdk' import { nameToLogs } from './nameToLogs' /** - * Add each new Action as the next argument to this function + * Here we list every Action. */ export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 41f5411..2289a79 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -3,11 +3,13 @@ const { Config, Value } = sdk import { yamlFile } from '../config/file-models/config.yml' /** - * This is an example Action + * Here we define an Action for our package. * - * By convention, each action receives its own file - * - * Actions optionally take an arbitrary config form as input + * By convention, each Action receives its own file. + */ + +/** + * Actions optionally take arbitrary form input. */ const input = Config.of({ nameToPrint: Value.text({ @@ -18,13 +20,10 @@ const input = Config.of({ }) /** - * This function defines the Action, including the FormSpec (if any) - * - * The first argument is the Action metadata. The second argument is the Action function - * - * If no input is required, FormSpec would be null + * This function defines the Action, including the optional form input. */ export const nameToLogs = sdk.createAction( + // The Action metadata { name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', @@ -33,6 +32,8 @@ export const nameToLogs = sdk.createAction( allowedStatuses: 'only-running', group: null, }, + + // the execution function async ({ effects, input }) => { const name = input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' diff --git a/startos/procedures/backups.ts b/startos/procedures/backups.ts index 56f5a24..736c521 100644 --- a/startos/procedures/backups.ts +++ b/startos/procedures/backups.ts @@ -1,12 +1,16 @@ import { sdk } from '../sdk' /** - * Here we define what volumes from the Manifest to include in backups + * Here we define which volumes to back up, including advanced options. + */ + +/** + * This example backs up the entire "main" volume. */ export const { createBackup, restoreBackup } = sdk.setupBackups('main') /** - * Excluding a hypothetical directory in the "main" volume, "excludedDir", that we do not want to back up + * This example backs up the "main" volume, but excludes a hypothetical directory called "excludedDir". */ // export const { createBackup, restoreBackup } = sdk.setupBackups( // sdk.Backups.volumes('main').setOptions({ diff --git a/startos/procedures/config/index.ts b/startos/procedures/config/index.ts index 6ebab87..5ee064d 100644 --- a/startos/procedures/config/index.ts +++ b/startos/procedures/config/index.ts @@ -4,6 +4,6 @@ import { read } from './read' import { save } from './save' /** - * This is a static file. There is no need to make changes here + * Plumbing. DO NOT EDIT. */ export const { getConfig, setConfig } = sdk.setupConfig(configSpec, save, read) diff --git a/startos/procedures/config/read.ts b/startos/procedures/config/read.ts index 8f2e9e7..b0b0f97 100644 --- a/startos/procedures/config/read.ts +++ b/startos/procedures/config/read.ts @@ -3,13 +3,14 @@ import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' /** - * This function executes on config get + * This function executes on config read. * - * Use this function to gather data from various files and assemble into a valid config to display to the user + * Use this function to gather data from various files and assemble into a valid config to display to the user. */ export const read = sdk.setupConfigRead(configSpec, async ({ effects }) => { // Retrieve data from the service's native config file. So, even if the user changes this file from the service's GUI or from the command line, the StartOS config will update as well. const configYml = await yamlFile.read(effects) + // Return the expected config spec to display to the user return { name: configYml?.name || '', diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index d998ee6..7468891 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -5,9 +5,9 @@ import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' /** - * This function executes on config save + * This function executes on config save. * - * Use it to persist config data to various files and to establish any resulting dependencies + * Use it to persist config data to various files and to establish any resulting dependencies. */ export const save = sdk.setupConfigSave( configSpec, @@ -18,7 +18,7 @@ export const save = sdk.setupConfigSave( // Whenever possible, save data directly to the underlying config file(s) of the upstream service. // This ensures that changes to the file from the service's GUI or from the command line are respected. await yamlFile.write(input, effects) - // If necessary, save package specific data to the package Store. Stateless packages are preferable + // If necessary, save package specific data to the package Store. Stateless packages are preferable. await Promise.all([ sdk.store.setOwn(effects, '/nameLastUpdatedAt', new Date().toISOString()), sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(input.name)), @@ -32,12 +32,9 @@ export const save = sdk.setupConfigSave( }) return { - // The line below is just plumbing, don't touch it. It insures setInterfaces runs whenever config is saved - interfacesReceipt: await setInterfaces({ effects, input }), - // provide dependencies receipt from above - dependenciesReceipt, - // optionally restart the service on config save - restart: true, + interfacesReceipt: await setInterfaces({ effects, input }), // Plumbing. DO NOT EDIT. This line causes setInterfaces() to run whenever config is saved. + dependenciesReceipt, // Plumbing. DO NOT EDIT. + restart: true, // optionally restart the service on config save. } }, ) diff --git a/startos/procedures/config/spec.ts b/startos/procedures/config/spec.ts index 8c28670..901db3e 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/procedures/config/spec.ts @@ -2,9 +2,9 @@ import { sdk } from '../../sdk' const { Config, Value } = sdk /** - * Here you define the config spec that will ultimately present to the user as validated form inputs + * Here we define the config spec that will ultimately present to the user as validated form inputs. * - * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (aka a "sub form"), and union (aka a conditional "sub form") + * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object ("sub form"), and union (conditional "sub forms"). */ export const configSpec = Config.of({ name: Value.text({ diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencies/dependencyConfig.ts index ae01931..25d2837 100644 --- a/startos/procedures/dependencies/dependencyConfig.ts +++ b/startos/procedures/dependencies/dependencyConfig.ts @@ -2,6 +2,6 @@ import { sdk } from '../../sdk' import { configSpec } from '../config/spec' /** - * In this function, you establish rules for auto configuring service dependencies. See Hello Moon for an example + * Here we establish rules for auto configuring service dependencies. See Hello Moon for an example */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 6fcce83..26ea708 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -1,3 +1,6 @@ +/** + * Plumbing. DO NOT EDIT. + */ export { getConfig, setConfig } from './config' export { createBackup, restoreBackup } from './backups' export { main } from './main' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 673a846..ecfa24d 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -5,7 +5,7 @@ import { setInterfaces } from './interfaces' import { migrations } from './migrations' /** - * Here you define arbitrary code that runs *once*, on fresh install only + * Here you define arbitrary code that runs *once*, on fresh install only. */ const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' @@ -16,16 +16,16 @@ const install = sdk.setupInstall(async ({ effects }) => { }) /** - * Here you define arbitrary code that runs once, on uninstall only + * Here we define arbitrary code that runs once, on uninstall only. */ const uninstall = sdk.setupUninstall(async ({ effects }) => {}) /** - * Here you determine which values from your store, if any, should be exposed to the user or to dependent services + * Here we determine which values from the store, if any, should be exposed to the UI, or to dependent services, or both. */ const exported = sdk.setupExports(({ effects }) => { return { - // Values exported to the UI will be displayed (masked) in the user's "Credentials". It is designed for credentials + /** Values exported to the UI are displayed in "Properties" according to the structure defined here. */ ui: { 'Secret Phrase': { type: 'string', @@ -42,7 +42,7 @@ const exported = sdk.setupExports(({ effects }) => { }) /** - * This is a static function. There is no need to make changes here + * This is a static function. There is no need to make changes here. */ export const { init, uninit } = sdk.setupInit( migrations, diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 4b46164..8992a85 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -2,14 +2,13 @@ import { sdk } from '../sdk' import { configSpec } from './config/spec' export const uiPort = 80 -export const webUiInterfaceId = 'webui' /** - * ======================== Interfaces ======================== + * ======================== Service Interfaces ======================== * - * In this section, you will decide how the service will be exposed to the outside world + * Here we decide how the service will be exposed to the outside world. * - * This function runs on service install, update, and config save + * This function runs on install, update, and config save. */ export const setInterfaces = sdk.setupInterfaces( configSpec, @@ -18,7 +17,7 @@ export const setInterfaces = sdk.setupInterfaces( const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) const ui = sdk.createInterface(effects, { name: 'Web UI', - id: webUiInterfaceId, + id: 'webui', description: 'The web interface of Hello World', type: 'ui', hasPrimary: false, diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 93b3c3f..524d79e 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -4,44 +4,43 @@ import { uiPort } from './interfaces' export const main = sdk.setupMain(async ({ effects, started }) => { /** - * ======================== Setup ======================== + * ======================== Setup (optional) ======================== * - * In this section, you will fetch any resources or run any commands necessary to run the service + * In this section, we fetch any resources or run any desired preliminary commands. */ console.info('Starting Hello World!') /** * ======================== Additional Health Checks (optional) ======================== * - * In this section, you will define *additional* health checks beyond those associated with daemons + * In this section, we define *additional* health checks beyond those included with each daemon (below). */ const healthReceipts: HealthReceipt[] = [] /** * ======================== Daemons ======================== * - * In this section, you will create one or more daemons that define the service runtime + * In this section, we create one or more daemons that define the service runtime. * - * Each daemon defines its own health check, which can optionally be exposed to the user + * Each daemon defines its own health check, which can optionally be exposed to the user. */ return sdk.Daemons.of({ effects, started, - healthReceipts, // Provide the healthReceipts or [] to prove they were at least considered + healthReceipts, }).addDaemon('webui', { - imageId: 'main', - command: 'hello-world', // The command to start the daemon + imageId: 'main', // Must match an Image ID declared in the manifest. + command: 'hello-world', // The command to start the daemon. mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { - // If display is null, it will not be displayed to the user in the UI - display: 'Web Interface', - // The function to run to determine the health status of the daemon + display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. + // A function to run that will determine the health status of this daemon fn: () => sdk.healthCheck.checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), }, - requires: [], + requires: [], // If this daemon depends on the successful initialization of one or more prior daemons, enter their IDs here. }) }) diff --git a/startos/procedures/migrations/index.ts b/startos/procedures/migrations/index.ts index 2129c85..d8aabfe 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/procedures/migrations/index.ts @@ -2,6 +2,6 @@ import { sdk } from '../../sdk' import { v4_0_0_1 } from './v4_0_0_1' /** - * Add each new migration as the next argument to this function + * Here we list every migration in sequential order. */ export const migrations = sdk.setupMigrations(v4_0_0_1) diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/procedures/migrations/v4_0_0_1.ts index 3c22c16..49989e3 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/procedures/migrations/v4_0_0_1.ts @@ -1,11 +1,11 @@ import { sdk } from '../../sdk' /** - * This is an example migration file + * This is an example migration file. * - * By convention, each version service requiring a migration receives its own file + * By convention, each new version that requires a migration should receive its own file like this one. * - * The resulting migration (e.g. v4_0_0_0) is exported, then imported into migrations/index.ts + * The resulting migration (e.g. v4_0_0_0) is exported from here, then imported into migrations/index.ts. */ export const v4_0_0_1 = sdk.Migration.of({ version: '4.0.0.1', diff --git a/startos/sdk.ts b/startos/sdk.ts index 6811622..5146d32 100644 --- a/startos/sdk.ts +++ b/startos/sdk.ts @@ -3,9 +3,9 @@ import { manifest } from './manifest' import { Store } from './store' /** - * This is a static file that provides type safety throughout the codebase + * Plumbing. DO NOT EDIT. * - * the exported sdk const should be used instead of StartSdk directly + * The exported "sdk" const will be imported and used throughout the package codebase. */ export const sdk = StartSdk.of() .withManifest(manifest) diff --git a/startos/store.ts b/startos/store.ts index 2c9b921..cc84283 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,7 +1,7 @@ /** - * The Store is for saving any necessary data NOT saved by the upstream service. Do NOT persist data in the package that is already being persisted by the service + * The Store is for persisting data that are needed by the package but are NOT persisted by the upstream service. Do NOT persist data here that are already being persisted by the service itself. * - * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior + * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior. */ export type Store = { nameLastUpdatedAt: string diff --git a/startos/utils.ts b/startos/utils.ts index f293c6b..d0de57b 100644 --- a/startos/utils.ts +++ b/startos/utils.ts @@ -1,5 +1,7 @@ /** - * Here you can define and export and shared constants or functions used throughout the codebase + * Here we define any constants or functions that are shared by multiple components throughout the codebase. + * + * For simple packages, this file may remain empty. */ export function getSecretPhrase(name: string): string { From 49c8c2dd2034459a6c6232da5122fe9361e00a44 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 19 Mar 2024 08:53:48 -0600 Subject: [PATCH 054/120] minor updates --- startos/procedures/dependencies/dependencyConfig.ts | 4 +++- startos/procedures/init.ts | 2 +- startos/procedures/interfaces.ts | 4 +++- startos/procedures/main.ts | 2 +- startos/utils.ts | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencies/dependencyConfig.ts index 25d2837..191908c 100644 --- a/startos/procedures/dependencies/dependencyConfig.ts +++ b/startos/procedures/dependencies/dependencyConfig.ts @@ -2,6 +2,8 @@ import { sdk } from '../../sdk' import { configSpec } from '../config/spec' /** - * Here we establish rules for auto configuring service dependencies. See Hello Moon for an example + * Here we establish rules for auto configuring service dependencies. + * + * See Hello Moon for an example. */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index ecfa24d..d3533c5 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -42,7 +42,7 @@ const exported = sdk.setupExports(({ effects }) => { }) /** - * This is a static function. There is no need to make changes here. + * Plumbing. DO NOT EDIT. */ export const { init, uninit } = sdk.setupInit( migrations, diff --git a/startos/procedures/interfaces.ts b/startos/procedures/interfaces.ts index 8992a85..3424604 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/procedures/interfaces.ts @@ -1,7 +1,9 @@ import { sdk } from '../sdk' import { configSpec } from './config/spec' +// It is good practice to abstract these two variables from each interface, as they may be used elsewhere in the package codebase or by dependent packages. export const uiPort = 80 +export const webUiInterfaceId = 'webui' /** * ======================== Service Interfaces ======================== @@ -17,7 +19,7 @@ export const setInterfaces = sdk.setupInterfaces( const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) const ui = sdk.createInterface(effects, { name: 'Web UI', - id: 'webui', + id: webUiInterfaceId, description: 'The web interface of Hello World', type: 'ui', hasPrimary: false, diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 524d79e..5e3864f 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -34,7 +34,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. - // A function to run that will determine the health status of this daemon + // A function below determines the health status of this daemon fn: () => sdk.healthCheck.checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', diff --git a/startos/utils.ts b/startos/utils.ts index d0de57b..dbdf0f8 100644 --- a/startos/utils.ts +++ b/startos/utils.ts @@ -1,5 +1,5 @@ /** - * Here we define any constants or functions that are shared by multiple components throughout the codebase. + * Here we define any constants or functions that are shared by multiple components throughout the package codebase. * * For simple packages, this file may remain empty. */ From ed6cd08e2f71967d297348dc06fb7612a1fa1ea3 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Wed, 20 Mar 2024 13:39:01 -0600 Subject: [PATCH 055/120] wip --- startos/procedures/actions/index.ts | 2 ++ .../dependencyConfig.ts => dependencyConfig/index.ts} | 6 +++--- startos/procedures/index.ts | 2 +- startos/procedures/init.ts | 4 +--- 4 files changed, 7 insertions(+), 7 deletions(-) rename startos/procedures/{dependencies/dependencyConfig.ts => dependencyConfig/index.ts} (51%) diff --git a/startos/procedures/actions/index.ts b/startos/procedures/actions/index.ts index dcddec5..604d536 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/procedures/actions/index.ts @@ -3,5 +3,7 @@ import { nameToLogs } from './nameToLogs' /** * Here we list every Action. + * + * By convention, each Action should receive its own file in the "actions" directory. */ export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/dependencies/dependencyConfig.ts b/startos/procedures/dependencyConfig/index.ts similarity index 51% rename from startos/procedures/dependencies/dependencyConfig.ts rename to startos/procedures/dependencyConfig/index.ts index 191908c..cf25500 100644 --- a/startos/procedures/dependencies/dependencyConfig.ts +++ b/startos/procedures/dependencyConfig/index.ts @@ -2,8 +2,8 @@ import { sdk } from '../../sdk' import { configSpec } from '../config/spec' /** - * Here we establish rules for auto configuring service dependencies. - * - * See Hello Moon for an example. + * Here we list every dependency config. + * + * By convention, each Dependency Config should receive its own file in the "dependencyConfig" directory. */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 26ea708..41f4226 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -6,4 +6,4 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' -export { dependencyConfig } from './dependencies/dependencyConfig' +export { dependencyConfig } from './dependencyConfig' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index d3533c5..2a4222f 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -35,9 +35,7 @@ const exported = sdk.setupExports(({ effects }) => { masked: true, }, }, - services: { - paths: ['/nameLastUpdatedAt'], - }, + services: ['/nameLastUpdatedAt'], } }) From fd250331a2cc881ea16d49dca6802c8a1a370d90 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Mar 2024 16:15:04 -0600 Subject: [PATCH 056/120] latest changes --- startos/procedures/config/save.ts | 11 ++--------- startos/procedures/dependencies/dependencies.ts | 12 ++++++++++++ .../{ => dependencies}/dependencyConfig/index.ts | 8 +++++--- startos/procedures/index.ts | 2 +- startos/procedures/init.ts | 2 ++ 5 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 startos/procedures/dependencies/dependencies.ts rename startos/procedures/{ => dependencies}/dependencyConfig/index.ts (65%) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 7468891..7225857 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -11,7 +11,7 @@ import { configSpec } from './spec' */ export const save = sdk.setupConfigSave( configSpec, - async ({ effects, input, dependencies }) => { + async ({ effects, input }) => { /** ******** save data wherever you want ******** */ @@ -24,16 +24,9 @@ export const save = sdk.setupConfigSave( sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(input.name)), ]) - /** - ******** set current dependencies based on config ******** - */ - const dependenciesReceipt = await effects.setDependencies({ - dependencies: [], - }) - return { interfacesReceipt: await setInterfaces({ effects, input }), // Plumbing. DO NOT EDIT. This line causes setInterfaces() to run whenever config is saved. - dependenciesReceipt, // Plumbing. DO NOT EDIT. + dependenciesReceipt: await setDependencies({ effects, input }), // Plumbing. DO NOT EDIT. restart: true, // optionally restart the service on config save. } }, diff --git a/startos/procedures/dependencies/dependencies.ts b/startos/procedures/dependencies/dependencies.ts new file mode 100644 index 0000000..c9fd2ae --- /dev/null +++ b/startos/procedures/dependencies/dependencies.ts @@ -0,0 +1,12 @@ +import { sdk } from '../../sdk' + +/** + * ======================== Dependencies ======================== + * + * Here we determine which + * + * This function runs on install, update, and config save. + */ +export const setDependencies = sdk.setupDependencies( + async ({ effects, input }) => {}, +) diff --git a/startos/procedures/dependencyConfig/index.ts b/startos/procedures/dependencies/dependencyConfig/index.ts similarity index 65% rename from startos/procedures/dependencyConfig/index.ts rename to startos/procedures/dependencies/dependencyConfig/index.ts index cf25500..b44753f 100644 --- a/startos/procedures/dependencyConfig/index.ts +++ b/startos/procedures/dependencies/dependencyConfig/index.ts @@ -1,9 +1,11 @@ -import { sdk } from '../../sdk' -import { configSpec } from '../config/spec' +import { sdk } from '../../../sdk' +import { configSpec } from '../../config/spec' /** * Here we list every dependency config. - * + * * By convention, each Dependency Config should receive its own file in the "dependencyConfig" directory. + * + * See Hello Moon for an example. */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/procedures/index.ts b/startos/procedures/index.ts index 41f4226..26ea708 100644 --- a/startos/procedures/index.ts +++ b/startos/procedures/index.ts @@ -6,4 +6,4 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' -export { dependencyConfig } from './dependencyConfig' +export { dependencyConfig } from './dependencies/dependencyConfig' diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 2a4222f..c170416 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,6 +1,7 @@ import { sdk } from '../sdk' import { getSecretPhrase } from '../utils' import { yamlFile } from './config/file-models/config.yml' +import { setDependencies } from './dependencies/dependencies' import { setInterfaces } from './interfaces' import { migrations } from './migrations' @@ -47,5 +48,6 @@ export const { init, uninit } = sdk.setupInit( install, uninstall, setInterfaces, + setDependencies, exported, ) From d02853c3f1419cdc528d501b415a056bcdbdb985 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Mar 2024 16:25:22 -0600 Subject: [PATCH 057/120] remove manifest type --- startos/manifest.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/startos/manifest.ts b/startos/manifest.ts index 936503f..68d1875 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -33,5 +33,3 @@ export const manifest = setupManifest({ }, dependencies: {}, // See Hello Moon for an example with dependencies }) - -export type Manifest = typeof manifest From b9446f5986577cab972600a9f6fafa501106730e Mon Sep 17 00:00:00 2001 From: J H Date: Wed, 20 Mar 2024 20:28:09 -0600 Subject: [PATCH 058/120] chore: Update the types to match the sdk --- startos/procedures/config/save.ts | 1 + startos/procedures/dependencies/dependencies.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index 7225857..d607256 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -1,5 +1,6 @@ import { sdk } from '../../sdk' import { getSecretPhrase } from '../../utils' +import { setDependencies } from '../dependencies/dependencies' import { setInterfaces } from '../interfaces' import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' diff --git a/startos/procedures/dependencies/dependencies.ts b/startos/procedures/dependencies/dependencies.ts index c9fd2ae..1ef389e 100644 --- a/startos/procedures/dependencies/dependencies.ts +++ b/startos/procedures/dependencies/dependencies.ts @@ -8,5 +8,5 @@ import { sdk } from '../../sdk' * This function runs on install, update, and config save. */ export const setDependencies = sdk.setupDependencies( - async ({ effects, input }) => {}, + async ({ effects, input }) => ({}), ) From 29184a5cf84c7241147b73b044932b79b0bd4a5f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Mar 2024 21:13:04 -0600 Subject: [PATCH 059/120] update package json --- package-lock.json | 49 ++++++++++++++++++++++++++++------------------- package.json | 8 ++++---- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5503cac..b6c1a83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,10 @@ "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" }, "devDependencies": { - "@types/node": "^20.0.0", - "@vercel/ncc": "^0.36.1", - "prettier": "^2.8.4", - "typescript": "^4.9.5" + "@types/node": "^20.11.30", + "@vercel/ncc": "^0.38.1", + "prettier": "^3.2.5", + "typescript": "^5.4.3" } }, "node_modules/@iarna/toml": { @@ -31,15 +31,18 @@ } }, "node_modules/@types/node": { - "version": "20.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.0.0.tgz", - "integrity": "sha512-cD2uPTDnQQCVpmRefonO98/PPijuOnnEy5oytWJFPY1N9aJCz2wJ5kSGWO+zJoed2cY2JxQh6yBuUq4vIn61hw==", - "dev": true + "version": "20.11.30", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", + "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@vercel/ncc": { - "version": "0.36.1", - "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.36.1.tgz", - "integrity": "sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==", + "version": "0.38.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.1.tgz", + "integrity": "sha512-IBBb+iI2NLu4VQn3Vwldyi2QwaXt5+hTyh58ggAMoCGE6DJmPvwL3KPBWcJl1m9LYPChBLE980Jw+CS4Wokqxw==", "dev": true, "bin": { "ncc": "dist/ncc/cli.js" @@ -74,15 +77,15 @@ } }, "node_modules/prettier": { - "version": "2.8.7", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.7.tgz", - "integrity": "sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==", + "version": "3.2.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", + "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -99,18 +102,24 @@ "integrity": "sha512-kXrY75F0s0WD15N2bWKDScKlKgwnusN6dTRzGs1N7LlxQRnazrsBISC1HL4sy2adsyk65Zbx3Ui3IGN8leAFOQ==" }, "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", + "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", "dev": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" }, "engines": { - "node": ">=4.2.0" + "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/package.json b/package.json index b8d0639..5941e8c 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" }, "devDependencies": { - "@types/node": "^20.0.0", - "@vercel/ncc": "^0.36.1", - "prettier": "^2.8.4", - "typescript": "^4.9.5" + "@types/node": "^20.11.30", + "@vercel/ncc": "^0.38.1", + "prettier": "^3.2.5", + "typescript": "^5.4.3" }, "prettier": { "trailingComma": "all", From a435418d28d9aab6693ab17a4feed4160d4b3001 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 21 Mar 2024 15:15:03 -0600 Subject: [PATCH 060/120] bring back properties and then some --- startos/manifest.ts | 2 +- startos/procedures/actions/nameToLogs.ts | 2 +- startos/procedures/init.ts | 22 ++-------------------- startos/procedures/main.ts | 13 +++++++++++++ startos/procedures/properties.ts | 19 +++++++++++++++++++ startos/store.ts | 4 ++++ 6 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 startos/procedures/properties.ts diff --git a/startos/manifest.ts b/startos/manifest.ts index 68d1875..925aa90 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -9,7 +9,7 @@ export const manifest = setupManifest({ version: '4.0.0.1', releaseNotes: 'Revamped for StartOS 0.4.0', license: 'mit', - replaces: Array('Hello World (hosted)', 'Goodbye World'), + replaces: ['Hello World (hosted)', 'Goodbye World'], // A list of SaaS services/products this service is intended to replace wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', upstreamRepo: 'https://github.com/Start9Labs/hello-world', supportSite: 'https://docs.start9.com/', diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index 2289a79..bd9b5d2 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -25,9 +25,9 @@ const input = Config.of({ export const nameToLogs = sdk.createAction( // The Action metadata { + id: 'nameToLogs', name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', - id: 'nameToLogs', input, allowedStatuses: 'only-running', group: null, diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index c170416..35daebb 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -1,4 +1,5 @@ import { sdk } from '../sdk' +import { exposedStore } from '../store' import { getSecretPhrase } from '../utils' import { yamlFile } from './config/file-models/config.yml' import { setDependencies } from './dependencies/dependencies' @@ -21,25 +22,6 @@ const install = sdk.setupInstall(async ({ effects }) => { */ const uninstall = sdk.setupUninstall(async ({ effects }) => {}) -/** - * Here we determine which values from the store, if any, should be exposed to the UI, or to dependent services, or both. - */ -const exported = sdk.setupExports(({ effects }) => { - return { - /** Values exported to the UI are displayed in "Properties" according to the structure defined here. */ - ui: { - 'Secret Phrase': { - type: 'string', - path: '/secretPhrase', - copyable: true, - qr: false, - masked: true, - }, - }, - services: ['/nameLastUpdatedAt'], - } -}) - /** * Plumbing. DO NOT EDIT. */ @@ -49,5 +31,5 @@ export const { init, uninit } = sdk.setupInit( uninstall, setInterfaces, setDependencies, - exported, + exposedStore, ) diff --git a/startos/procedures/main.ts b/startos/procedures/main.ts index 5e3864f..8213d28 100644 --- a/startos/procedures/main.ts +++ b/startos/procedures/main.ts @@ -9,6 +9,19 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * In this section, we fetch any resources or run any desired preliminary commands. */ console.info('Starting Hello World!') + /* TODO BluJ + getDependencies() -> Dependencies + checkDependencies({ + packageIds: [PackageId, ...PackageId[]] + }) -> CheckResult + + interface CheckResult { + throwIfError() -> never + throwIfNotExists() -> never + isValid() -> boolean + errorMessage() -> Option + } + */ /** * ======================== Additional Health Checks (optional) ======================== diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts new file mode 100644 index 0000000..fe0863c --- /dev/null +++ b/startos/procedures/properties.ts @@ -0,0 +1,19 @@ +import { sdk } from '../sdk' + +/** + * Here we determine which values from the local Store and underlying service to expose in the UI in Properties. + */ +export const properties = sdk.setupProperties(async ({ effects }) => { + const store = await sdk.store.getOwn(effects, '').once() + + return { + 'Secret Phrase': { + type: 'string', + value: store.secretPhrase, + description: 'Use this phrase to gain access to extraordinary places', + copyable: true, + qr: false, + masked: true, + }, + } +}) diff --git a/startos/store.ts b/startos/store.ts index cc84283..5b6999a 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,3 +1,5 @@ +import { exposeStore } from '@start9labs/start-sdk' + /** * The Store is for persisting data that are needed by the package but are NOT persisted by the upstream service. Do NOT persist data here that are already being persisted by the service itself. * @@ -7,3 +9,5 @@ export type Store = { nameLastUpdatedAt: string secretPhrase: string } + +export const exposedStore = exposeStore(['/nameLastUpdatedAt']) From 503c0a776db71420c7e7bb2749537abb31b77014 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 21 Mar 2024 18:17:35 -0600 Subject: [PATCH 061/120] update action for sdk change --- startos/procedures/actions/nameToLogs.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index bd9b5d2..c30e000 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -22,18 +22,21 @@ const input = Config.of({ /** * This function defines the Action, including the optional form input. */ -export const nameToLogs = sdk.createAction( - // The Action metadata - { - id: 'nameToLogs', + +export const nameToLogs = sdk.createDynamicAction( + /** id */ + 'nameToLogs', + /** metadata */ + ({ effects }) => ({ name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', + warning: null, + disabled: false, input, allowedStatuses: 'only-running', group: null, - }, - - // the execution function + }), + /** the execution function */ async ({ effects, input }) => { const name = input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' @@ -49,4 +52,6 @@ export const nameToLogs = sdk.createAction( }, } }, + /** spec for form input */ + input, ) From 14953a6b83cbd3ec237abd259e5b3fa3f777ed8e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 21 Mar 2024 22:17:18 -0600 Subject: [PATCH 062/120] dynamic action --- startos/procedures/actions/nameToLogs.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/procedures/actions/nameToLogs.ts index c30e000..e9a6955 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/procedures/actions/nameToLogs.ts @@ -27,15 +27,17 @@ export const nameToLogs = sdk.createDynamicAction( /** id */ 'nameToLogs', /** metadata */ - ({ effects }) => ({ - name: 'Name to Logs', - description: 'Prints "Hello [Name]" to the service logs.', - warning: null, - disabled: false, - input, - allowedStatuses: 'only-running', - group: null, - }), + async ({ effects }) => { + return { + name: 'Name to Logs', + description: 'Prints "Hello [Name]" to the service logs.', + warning: null, + disabled: false, + input, + allowedStatuses: 'only-running', + group: null, + } + }, /** the execution function */ async ({ effects, input }) => { const name = From e566f67bd31efa80d8f23cdecc058923ab9b6ce2 Mon Sep 17 00:00:00 2001 From: J H Date: Sat, 23 Mar 2024 09:13:20 -0600 Subject: [PATCH 063/120] chore: Update to the latest sdk --- startos/procedures/config/save.ts | 12 ++++++++++-- startos/procedures/init.ts | 6 +++++- startos/procedures/properties.ts | 2 +- startos/store.ts | 11 +++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index d607256..b10b515 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -21,8 +21,16 @@ export const save = sdk.setupConfigSave( await yamlFile.write(input, effects) // If necessary, save package specific data to the package Store. Stateless packages are preferable. await Promise.all([ - sdk.store.setOwn(effects, '/nameLastUpdatedAt', new Date().toISOString()), - sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(input.name)), + sdk.store.setOwn( + effects, + sdk.StorePath.nameLastUpdatedAt, + new Date().toISOString(), + ), + sdk.store.setOwn( + effects, + sdk.StorePath.secretPhrase, + getSecretPhrase(input.name), + ), ]) return { diff --git a/startos/procedures/init.ts b/startos/procedures/init.ts index 35daebb..c22290f 100644 --- a/startos/procedures/init.ts +++ b/startos/procedures/init.ts @@ -14,7 +14,11 @@ const install = sdk.setupInstall(async ({ effects }) => { await yamlFile.write({ name }, effects) - await sdk.store.setOwn(effects, '/secretPhrase', getSecretPhrase(name)) + await sdk.store.setOwn( + effects, + sdk.StorePath.secretPhrase, + getSecretPhrase(name), + ) }) /** diff --git a/startos/procedures/properties.ts b/startos/procedures/properties.ts index fe0863c..474df3f 100644 --- a/startos/procedures/properties.ts +++ b/startos/procedures/properties.ts @@ -4,7 +4,7 @@ import { sdk } from '../sdk' * Here we determine which values from the local Store and underlying service to expose in the UI in Properties. */ export const properties = sdk.setupProperties(async ({ effects }) => { - const store = await sdk.store.getOwn(effects, '').once() + const store = await sdk.store.getOwn(effects, sdk.StorePath).once() return { 'Secret Phrase': { diff --git a/startos/store.ts b/startos/store.ts index 5b6999a..e5144d2 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,13 +1,20 @@ -import { exposeStore } from '@start9labs/start-sdk' +import { setupExposeStore } from '@start9labs/start-sdk' /** * The Store is for persisting data that are needed by the package but are NOT persisted by the upstream service. Do NOT persist data here that are already being persisted by the service itself. * * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior. */ + export type Store = { nameLastUpdatedAt: string secretPhrase: string + nestedObject: { + otherThings: string + } } -export const exposedStore = exposeStore(['/nameLastUpdatedAt']) +export const exposedStore = setupExposeStore((pathBuilder) => [ + pathBuilder.nameLastUpdatedAt, + pathBuilder.nestedObject.otherThings, +]) From 3c98ed0a90751436e9d81b04cafe73ca03e7206e Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 23 Mar 2024 22:33:31 -0600 Subject: [PATCH 064/120] use nested propert for example --- startos/procedures/config/save.ts | 2 +- startos/store.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/startos/procedures/config/save.ts b/startos/procedures/config/save.ts index b10b515..1b57373 100644 --- a/startos/procedures/config/save.ts +++ b/startos/procedures/config/save.ts @@ -23,7 +23,7 @@ export const save = sdk.setupConfigSave( await Promise.all([ sdk.store.setOwn( effects, - sdk.StorePath.nameLastUpdatedAt, + sdk.StorePath.nestedObject.nameLastUpdatedAt, new Date().toISOString(), ), sdk.store.setOwn( diff --git a/startos/store.ts b/startos/store.ts index e5144d2..c015a9e 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -7,10 +7,9 @@ import { setupExposeStore } from '@start9labs/start-sdk' */ export type Store = { - nameLastUpdatedAt: string secretPhrase: string nestedObject: { - otherThings: string + nameLastUpdatedAt: string } } From 11c7cbba2a02b8fd79654152ad3444b0752f63a5 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sun, 24 Mar 2024 10:47:41 -0600 Subject: [PATCH 065/120] minor --- startos/store.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/startos/store.ts b/startos/store.ts index c015a9e..2dd1f9b 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -14,6 +14,5 @@ export type Store = { } export const exposedStore = setupExposeStore((pathBuilder) => [ - pathBuilder.nameLastUpdatedAt, - pathBuilder.nestedObject.otherThings, + pathBuilder.nestedObject.nameLastUpdatedAt, ]) From 37f30d7521385302438ee7059c7652812d94199c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 4 Apr 2024 20:21:20 -0600 Subject: [PATCH 066/120] restructure directories --- .gitignore | 2 +- package.json | 3 ++- startos/{procedures => }/actions/index.ts | 4 ++-- startos/{procedures => }/actions/nameToLogs.ts | 4 ++-- startos/{procedures => }/backups.ts | 2 +- .../config/file-models/config.yml.ts | 0 startos/{procedures => }/config/index.ts | 2 +- startos/{procedures => }/config/read.ts | 2 +- startos/{procedures => }/config/save.ts | 4 ++-- startos/{procedures => }/config/spec.ts | 2 +- .../{procedures => }/dependencies/dependencies.ts | 2 +- .../dependencies/dependencyConfig/index.ts | 2 +- startos/{procedures => }/index.ts | 0 startos/{procedures => }/init.ts | 6 +++--- startos/{procedures => }/interfaces.ts | 2 +- startos/{procedures => }/main.ts | 15 +-------------- startos/{procedures => }/migrations/index.ts | 2 +- startos/{procedures => }/migrations/v4_0_0_1.ts | 2 +- startos/{procedures => }/properties.ts | 2 +- 19 files changed, 23 insertions(+), 35 deletions(-) rename startos/{procedures => }/actions/index.ts (86%) rename startos/{procedures => }/actions/nameToLogs.ts (94%) rename startos/{procedures => }/backups.ts (94%) rename startos/{procedures => }/config/file-models/config.yml.ts (100%) rename startos/{procedures => }/config/index.ts (86%) rename startos/{procedures => }/config/read.ts (95%) rename startos/{procedures => }/config/save.ts (95%) rename startos/{procedures => }/config/spec.ts (94%) rename startos/{procedures => }/dependencies/dependencies.ts (89%) rename startos/{procedures => }/dependencies/dependencyConfig/index.ts (90%) rename startos/{procedures => }/index.ts (100%) rename startos/{procedures => }/init.ts (88%) rename startos/{procedures => }/interfaces.ts (97%) rename startos/{procedures => }/main.ts (83%) rename startos/{procedures => }/migrations/index.ts (82%) rename startos/{procedures => }/migrations/v4_0_0_1.ts (93%) rename startos/{procedures => }/properties.ts (94%) diff --git a/.gitignore b/.gitignore index 3c911c7..6574995 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.s9pk -procedures/*.js +startos/*.js node_modules/ .DS_Store .vscode/ diff --git a/package.json b/package.json index 5941e8c..839b674 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { + "name": "hello-world-startos", "scripts": { - "build": "ncc build procedures/index.ts -o ./", + "build": "ncc build startos/index.ts -o ./", "prettier": "prettier --write startos", "check": "tsc --noEmit" }, diff --git a/startos/procedures/actions/index.ts b/startos/actions/index.ts similarity index 86% rename from startos/procedures/actions/index.ts rename to startos/actions/index.ts index 604d536..ad66eaa 100644 --- a/startos/procedures/actions/index.ts +++ b/startos/actions/index.ts @@ -1,9 +1,9 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' import { nameToLogs } from './nameToLogs' /** * Here we list every Action. - * + * * By convention, each Action should receive its own file in the "actions" directory. */ export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/procedures/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts similarity index 94% rename from startos/procedures/actions/nameToLogs.ts rename to startos/actions/nameToLogs.ts index e9a6955..6723922 100644 --- a/startos/procedures/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' const { Config, Value } = sdk import { yamlFile } from '../config/file-models/config.yml' @@ -34,7 +34,7 @@ export const nameToLogs = sdk.createDynamicAction( warning: null, disabled: false, input, - allowedStatuses: 'only-running', + allowedStatuses: 'onlyRunning', group: null, } }, diff --git a/startos/procedures/backups.ts b/startos/backups.ts similarity index 94% rename from startos/procedures/backups.ts rename to startos/backups.ts index 736c521..661d21e 100644 --- a/startos/procedures/backups.ts +++ b/startos/backups.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from './sdk' /** * Here we define which volumes to back up, including advanced options. diff --git a/startos/procedures/config/file-models/config.yml.ts b/startos/config/file-models/config.yml.ts similarity index 100% rename from startos/procedures/config/file-models/config.yml.ts rename to startos/config/file-models/config.yml.ts diff --git a/startos/procedures/config/index.ts b/startos/config/index.ts similarity index 86% rename from startos/procedures/config/index.ts rename to startos/config/index.ts index 5ee064d..71345b2 100644 --- a/startos/procedures/config/index.ts +++ b/startos/config/index.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' import { configSpec } from './spec' import { read } from './read' import { save } from './save' diff --git a/startos/procedures/config/read.ts b/startos/config/read.ts similarity index 95% rename from startos/procedures/config/read.ts rename to startos/config/read.ts index b0b0f97..30cca2c 100644 --- a/startos/procedures/config/read.ts +++ b/startos/config/read.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' import { yamlFile } from './file-models/config.yml' import { configSpec } from './spec' diff --git a/startos/procedures/config/save.ts b/startos/config/save.ts similarity index 95% rename from startos/procedures/config/save.ts rename to startos/config/save.ts index 1b57373..3fe136d 100644 --- a/startos/procedures/config/save.ts +++ b/startos/config/save.ts @@ -1,5 +1,5 @@ -import { sdk } from '../../sdk' -import { getSecretPhrase } from '../../utils' +import { sdk } from '../sdk' +import { getSecretPhrase } from '../utils' import { setDependencies } from '../dependencies/dependencies' import { setInterfaces } from '../interfaces' import { yamlFile } from './file-models/config.yml' diff --git a/startos/procedures/config/spec.ts b/startos/config/spec.ts similarity index 94% rename from startos/procedures/config/spec.ts rename to startos/config/spec.ts index 901db3e..7bab431 100644 --- a/startos/procedures/config/spec.ts +++ b/startos/config/spec.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' const { Config, Value } = sdk /** diff --git a/startos/procedures/dependencies/dependencies.ts b/startos/dependencies/dependencies.ts similarity index 89% rename from startos/procedures/dependencies/dependencies.ts rename to startos/dependencies/dependencies.ts index 1ef389e..58609be 100644 --- a/startos/procedures/dependencies/dependencies.ts +++ b/startos/dependencies/dependencies.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' /** * ======================== Dependencies ======================== diff --git a/startos/procedures/dependencies/dependencyConfig/index.ts b/startos/dependencies/dependencyConfig/index.ts similarity index 90% rename from startos/procedures/dependencies/dependencyConfig/index.ts rename to startos/dependencies/dependencyConfig/index.ts index b44753f..7d5509d 100644 --- a/startos/procedures/dependencies/dependencyConfig/index.ts +++ b/startos/dependencies/dependencyConfig/index.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../../sdk' +import { sdk } from '../../sdk' import { configSpec } from '../../config/spec' /** diff --git a/startos/procedures/index.ts b/startos/index.ts similarity index 100% rename from startos/procedures/index.ts rename to startos/index.ts diff --git a/startos/procedures/init.ts b/startos/init.ts similarity index 88% rename from startos/procedures/init.ts rename to startos/init.ts index c22290f..0bc16d5 100644 --- a/startos/procedures/init.ts +++ b/startos/init.ts @@ -1,6 +1,6 @@ -import { sdk } from '../sdk' -import { exposedStore } from '../store' -import { getSecretPhrase } from '../utils' +import { sdk } from './sdk' +import { exposedStore } from './store' +import { getSecretPhrase } from './utils' import { yamlFile } from './config/file-models/config.yml' import { setDependencies } from './dependencies/dependencies' import { setInterfaces } from './interfaces' diff --git a/startos/procedures/interfaces.ts b/startos/interfaces.ts similarity index 97% rename from startos/procedures/interfaces.ts rename to startos/interfaces.ts index 3424604..14cc1c9 100644 --- a/startos/procedures/interfaces.ts +++ b/startos/interfaces.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from './sdk' import { configSpec } from './config/spec' // It is good practice to abstract these two variables from each interface, as they may be used elsewhere in the package codebase or by dependent packages. diff --git a/startos/procedures/main.ts b/startos/main.ts similarity index 83% rename from startos/procedures/main.ts rename to startos/main.ts index 8213d28..9a5142a 100644 --- a/startos/procedures/main.ts +++ b/startos/main.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from './sdk' import { HealthReceipt } from '@start9labs/start-sdk/cjs/sdk/lib/health/HealthReceipt' import { uiPort } from './interfaces' @@ -9,19 +9,6 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * In this section, we fetch any resources or run any desired preliminary commands. */ console.info('Starting Hello World!') - /* TODO BluJ - getDependencies() -> Dependencies - checkDependencies({ - packageIds: [PackageId, ...PackageId[]] - }) -> CheckResult - - interface CheckResult { - throwIfError() -> never - throwIfNotExists() -> never - isValid() -> boolean - errorMessage() -> Option - } - */ /** * ======================== Additional Health Checks (optional) ======================== diff --git a/startos/procedures/migrations/index.ts b/startos/migrations/index.ts similarity index 82% rename from startos/procedures/migrations/index.ts rename to startos/migrations/index.ts index d8aabfe..1074746 100644 --- a/startos/procedures/migrations/index.ts +++ b/startos/migrations/index.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' import { v4_0_0_1 } from './v4_0_0_1' /** diff --git a/startos/procedures/migrations/v4_0_0_1.ts b/startos/migrations/v4_0_0_1.ts similarity index 93% rename from startos/procedures/migrations/v4_0_0_1.ts rename to startos/migrations/v4_0_0_1.ts index 49989e3..6db0ade 100644 --- a/startos/procedures/migrations/v4_0_0_1.ts +++ b/startos/migrations/v4_0_0_1.ts @@ -1,4 +1,4 @@ -import { sdk } from '../../sdk' +import { sdk } from '../sdk' /** * This is an example migration file. diff --git a/startos/procedures/properties.ts b/startos/properties.ts similarity index 94% rename from startos/procedures/properties.ts rename to startos/properties.ts index 474df3f..1c5b743 100644 --- a/startos/procedures/properties.ts +++ b/startos/properties.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from './sdk' /** * Here we determine which values from the local Store and underlying service to expose in the UI in Properties. From 5d00fe3d2664cd99066a16c5733edae0dd96ae3f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 9 May 2024 07:21:47 -0600 Subject: [PATCH 067/120] minor type change --- startos/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/startos/main.ts b/startos/main.ts index 9a5142a..b5a585b 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -1,6 +1,6 @@ import { sdk } from './sdk' -import { HealthReceipt } from '@start9labs/start-sdk/cjs/sdk/lib/health/HealthReceipt' import { uiPort } from './interfaces' +import { T } from '@start9labs/start-sdk' export const main = sdk.setupMain(async ({ effects, started }) => { /** @@ -15,7 +15,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * * In this section, we define *additional* health checks beyond those included with each daemon (below). */ - const healthReceipts: HealthReceipt[] = [] + const healthReceipts: T.HealthReceipt[] = [] /** * ======================== Daemons ======================== From f9db05203e39a92dbc0fff120549924f142e4faf Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 9 May 2024 07:27:37 -0600 Subject: [PATCH 068/120] fix start-sdk dep --- package-lock.json | 83 ++++++++++------------------------------------- package.json | 2 +- 2 files changed, 18 insertions(+), 67 deletions(-) diff --git a/package-lock.json b/package-lock.json index b6c1a83..2371383 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,8 +4,9 @@ "requires": true, "packages": { "": { + "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" + "@start9labs/start-sdk": "^0.4.0-3df957898aeaa22286970b280e3f525a480dfa96" }, "devDependencies": { "@types/node": "^20.11.30", @@ -20,20 +21,19 @@ "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-rev0.lib0.rc8.beta2", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-rev0.lib0.rc8.beta2.tgz", - "integrity": "sha512-2jo8gF/lOvzuOKKntPuQyejwDAY6Uxaz4KKqm2awoYN6Ycn1TrYud0KAdSjKFYDCKmJI/guQNej0XGVJe0B1XQ==", + "version": "0.4.0-3df957898aeaa22286970b280e3f525a480dfa96", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-3df957898aeaa22286970b280e3f525a480dfa96.tgz", + "integrity": "sha512-Pkg5PUVpegWIrsewzRwrWNmNVRiQQxQpUgFpkOMErrOljUDMIzFNN79lPY2fajKuqgEV8Bzs4QMkZ8qG/WHoEw==", "dependencies": { "@iarna/toml": "^2.2.5", - "isomorphic-fetch": "^3.0.0", "ts-matches": "^5.4.1", "yaml": "^2.2.2" } }, "node_modules/@types/node": { - "version": "20.11.30", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.30.tgz", - "integrity": "sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==", + "version": "20.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", + "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -48,34 +48,6 @@ "ncc": "dist/ncc/cli.js" } }, - "node_modules/isomorphic-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", - "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", - "dependencies": { - "node-fetch": "^2.6.1", - "whatwg-fetch": "^3.4.1" - } - }, - "node_modules/node-fetch": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz", - "integrity": "sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/prettier": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", @@ -91,20 +63,15 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, "node_modules/ts-matches": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", "integrity": "sha512-kXrY75F0s0WD15N2bWKDScKlKgwnusN6dTRzGs1N7LlxQRnazrsBISC1HL4sy2adsyk65Zbx3Ui3IGN8leAFOQ==" }, "node_modules/typescript": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", - "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -120,29 +87,13 @@ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/whatwg-fetch": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz", - "integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/yaml": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", - "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", + "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "bin": { + "yaml": "bin.mjs" + }, "engines": { "node": ">= 14" } diff --git a/package.json b/package.json index 839b674..6a59866 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.4.0-rev0.lib0.rc8.beta2" + "@start9labs/start-sdk": "^0.4.0-3df957898aeaa22286970b280e3f525a480dfa96" }, "devDependencies": { "@types/node": "^20.11.30", From f10721b9e970acc51d5229e994c970bb4f1931e6 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 9 May 2024 15:00:18 -0600 Subject: [PATCH 069/120] some rearranging --- startos/actions/nameToLogs.ts | 2 +- startos/config/read.ts | 2 +- startos/config/save.ts | 4 ++-- startos/{config => }/file-models/config.yml.ts | 3 ++- startos/init.ts | 4 ++-- startos/main.ts | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) rename startos/{config => }/file-models/config.yml.ts (69%) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 6723922..fa0dea7 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -1,6 +1,6 @@ import { sdk } from '../sdk' const { Config, Value } = sdk -import { yamlFile } from '../config/file-models/config.yml' +import { yamlFile } from '../file-models/config.yml' /** * Here we define an Action for our package. diff --git a/startos/config/read.ts b/startos/config/read.ts index 30cca2c..4782505 100644 --- a/startos/config/read.ts +++ b/startos/config/read.ts @@ -1,5 +1,5 @@ import { sdk } from '../sdk' -import { yamlFile } from './file-models/config.yml' +import { yamlFile } from '../file-models/config.yml' import { configSpec } from './spec' /** diff --git a/startos/config/save.ts b/startos/config/save.ts index 3fe136d..6620fbc 100644 --- a/startos/config/save.ts +++ b/startos/config/save.ts @@ -2,7 +2,7 @@ import { sdk } from '../sdk' import { getSecretPhrase } from '../utils' import { setDependencies } from '../dependencies/dependencies' import { setInterfaces } from '../interfaces' -import { yamlFile } from './file-models/config.yml' +import { yamlFile } from '../file-models/config.yml' import { configSpec } from './spec' /** @@ -18,7 +18,7 @@ export const save = sdk.setupConfigSave( */ // Whenever possible, save data directly to the underlying config file(s) of the upstream service. // This ensures that changes to the file from the service's GUI or from the command line are respected. - await yamlFile.write(input, effects) + await yamlFile.merge(input, effects) // If necessary, save package specific data to the package Store. Stateless packages are preferable. await Promise.all([ sdk.store.setOwn( diff --git a/startos/config/file-models/config.yml.ts b/startos/file-models/config.yml.ts similarity index 69% rename from startos/config/file-models/config.yml.ts rename to startos/file-models/config.yml.ts index 0f16863..b9fa118 100644 --- a/startos/config/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -1,9 +1,10 @@ import { matches, FileHelper } from '@start9labs/start-sdk' -const { object, string } = matches +const { object, string, natural } = matches const shape = object({ name: string, + // favoriteNumber: natural, }) export const yamlFile = FileHelper.yaml('config.yml', shape) diff --git a/startos/init.ts b/startos/init.ts index 0bc16d5..f6471c8 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -1,7 +1,7 @@ import { sdk } from './sdk' import { exposedStore } from './store' import { getSecretPhrase } from './utils' -import { yamlFile } from './config/file-models/config.yml' +import { yamlFile } from './file-models/config.yml' import { setDependencies } from './dependencies/dependencies' import { setInterfaces } from './interfaces' import { migrations } from './migrations' @@ -12,7 +12,7 @@ import { migrations } from './migrations' const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' - await yamlFile.write({ name }, effects) + await yamlFile.merge({ name }, effects) await sdk.store.setOwn( effects, diff --git a/startos/main.ts b/startos/main.ts index b5a585b..6509f55 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -28,7 +28,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { effects, started, healthReceipts, - }).addDaemon('webui', { + }).addDaemon('primary', { imageId: 'main', // Must match an Image ID declared in the manifest. command: 'hello-world', // The command to start the daemon. mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), From e8dfe485d551ec0f5de64348d14c370920ae2bcc Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 10 Jun 2024 22:40:49 -0600 Subject: [PATCH 070/120] restructuring --- .gitignore | 1 + Makefile | 23 +++++++++++++++++++++- assets/icon.png => icon.png | Bin assets/instructions.md => instructions.md | 0 package.json | 2 +- startos/index.ts | 1 + startos/main.ts | 4 ++-- startos/manifest.ts | 13 +++++++++++- 8 files changed, 39 insertions(+), 5 deletions(-) rename assets/icon.png => icon.png (100%) rename assets/instructions.md => instructions.md (100%) diff --git a/.gitignore b/.gitignore index 6574995..2603f70 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ .DS_Store .vscode/ docker-images +javascript \ No newline at end of file diff --git a/Makefile b/Makefile index 4640904..7978a72 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,22 @@ -# TODO +PACKAGE_ID := hello-world + +.PHONY: clean all + +all: ${PACKAGE_ID}.s9pk + +clean: + rm ${PACKAGE_ID}.s9pk + rm -rf javascript + rm -rf node_modules + +${PACKAGE_ID}.s9pk: icon.png instructions.md LICENSE Dockerfile javascript/index.js + start-cli s9pk pack --license=LICENSE + +javascript/index.js: $(shell git ls-files startos) node_modules package.json + npm run build + +node_modules: package.json package-lock.json + npm ci + +package-lock.json: package.json + npm i \ No newline at end of file diff --git a/assets/icon.png b/icon.png similarity index 100% rename from assets/icon.png rename to icon.png diff --git a/assets/instructions.md b/instructions.md similarity index 100% rename from assets/instructions.md rename to instructions.md diff --git a/package.json b/package.json index 6a59866..09f7611 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hello-world-startos", "scripts": { - "build": "ncc build startos/index.ts -o ./", + "build": "ncc build startos/index.ts -o ./javascript", "prettier": "prettier --write startos", "check": "tsc --noEmit" }, diff --git a/startos/index.ts b/startos/index.ts index 26ea708..b7925bd 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -7,3 +7,4 @@ export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' export { dependencyConfig } from './dependencies/dependencyConfig' +export { manifest } from './manifest' diff --git a/startos/main.ts b/startos/main.ts index 6509f55..bf48240 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -29,8 +29,8 @@ export const main = sdk.setupMain(async ({ effects, started }) => { started, healthReceipts, }).addDaemon('primary', { - imageId: 'main', // Must match an Image ID declared in the manifest. - command: 'hello-world', // The command to start the daemon. + image: { id: 'main' }, // Must match an Image ID declared in the manifest. + command: ['hello-world'], // The command to start the daemon. mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. diff --git a/startos/manifest.ts b/startos/manifest.ts index 925aa90..d43226c 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -21,7 +21,18 @@ export const manifest = setupManifest({ }, assets: [], // directories of static files you want to mount to your container volumes: ['main'], // IDs of persistence volumes that will be mounted to your container - images: ['main'], // IDs of images, used when other actions need to run in this image + images: { + main: { + source: { + dockerBuild: { + dockerfile: './Dockerfile', + workdir: '.', + }, + }, + arch: ['x86_64', 'aarch64'], + emulateMissingAs: 'aarch64', + }, + }, // IDs of images, used when other actions need to run in this image alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', From c6b57bae757cf9bfbbb62aefafd1351613513edb Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Tue, 11 Jun 2024 10:23:37 -0600 Subject: [PATCH 071/120] fix id --- startos/file-models/config.yml.ts | 5 ++++- startos/interfaces.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index b9fa118..f1b0802 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -7,4 +7,7 @@ const shape = object({ // favoriteNumber: natural, }) -export const yamlFile = FileHelper.yaml('config.yml', shape) +export const yamlFile = FileHelper.yaml( + '/media/startos/volumes/main/config.yml', + shape, +) diff --git a/startos/interfaces.ts b/startos/interfaces.ts index 14cc1c9..d36d332 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -15,7 +15,7 @@ export const webUiInterfaceId = 'webui' export const setInterfaces = sdk.setupInterfaces( configSpec, async ({ effects, input }) => { - const uiMulti = sdk.host.multi(effects, 'uiMulti') + const uiMulti = sdk.host.multi(effects, 'ui-multi') const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) const ui = sdk.createInterface(effects, { name: 'Web UI', From a97d45e1b88e0e64fdb80fd6c93b2784ad74ec5e Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Tue, 11 Jun 2024 21:03:36 +0200 Subject: [PATCH 072/120] Automate npm link command and refine clean rule in Makefile --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7978a72..b931d03 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ PACKAGE_ID := hello-world all: ${PACKAGE_ID}.s9pk clean: - rm ${PACKAGE_ID}.s9pk + rm -rf ${PACKAGE_ID}.s9pk rm -rf javascript rm -rf node_modules @@ -17,6 +17,7 @@ javascript/index.js: $(shell git ls-files startos) node_modules package.json node_modules: package.json package-lock.json npm ci + npm link @start9labs/start-sdk package-lock.json: package.json npm i \ No newline at end of file From 0c3ea240f5dd333d0113929a96bcf99b8e9c2332 Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Tue, 11 Jun 2024 22:43:53 +0200 Subject: [PATCH 073/120] Added install target, comments, and rearranged for better readability --- Makefile | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b931d03..0991e8d 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,12 @@ PACKAGE_ID := hello-world -.PHONY: clean all +# Phony targets +.PHONY: all clean install +# Default target all: ${PACKAGE_ID}.s9pk -clean: - rm -rf ${PACKAGE_ID}.s9pk - rm -rf javascript - rm -rf node_modules - +# Build targets ${PACKAGE_ID}.s9pk: icon.png instructions.md LICENSE Dockerfile javascript/index.js start-cli s9pk pack --license=LICENSE @@ -20,4 +18,17 @@ node_modules: package.json package-lock.json npm link @start9labs/start-sdk package-lock.json: package.json - npm i \ No newline at end of file + npm i + +# Clean target +clean: + rm -rf ${PACKAGE_ID}.s9pk + rm -rf javascript + rm -rf node_modules + +# Install target +install: + @if [ ! -f ~/.startos/config.yaml ]; then echo "You must define \"host: http://server-name.local\" in ~/.startos/config.yaml config file first."; exit 1; fi + @echo "\nInstalling to $$(grep -v '^#' ~/.startos/config.yaml | cut -d'/' -f3) ...\n" + @[ -f $(PACKAGE_ID).s9pk ] || ( $(MAKE) && echo "\nInstalling to $$(grep -v '^#' ~/.startos/config.yaml | cut -d'/' -f3) ...\n" ) + @start-cli package install -s $(PACKAGE_ID).s9pk From b1cf0e1fc63f4a56dfdfaf242241d2be037443da Mon Sep 17 00:00:00 2001 From: J H Date: Tue, 11 Jun 2024 16:17:53 -0600 Subject: [PATCH 074/120] chore: change to a valid version of the start-sdk --- package-lock.json | 83 +++++++++++++++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2371383..d47c60c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "^0.4.0-3df957898aeaa22286970b280e3f525a480dfa96" + "@start9labs/start-sdk": "0.3.6-alpha3" }, "devDependencies": { "@types/node": "^20.11.30", @@ -15,19 +15,14 @@ "typescript": "^5.4.3" } }, - "node_modules/@iarna/toml": { - "version": "2.2.5", - "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", - "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" - }, "node_modules/@start9labs/start-sdk": { - "version": "0.4.0-3df957898aeaa22286970b280e3f525a480dfa96", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.4.0-3df957898aeaa22286970b280e3f525a480dfa96.tgz", - "integrity": "sha512-Pkg5PUVpegWIrsewzRwrWNmNVRiQQxQpUgFpkOMErrOljUDMIzFNN79lPY2fajKuqgEV8Bzs4QMkZ8qG/WHoEw==", + "version": "0.3.6-alpha3", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha3.tgz", + "integrity": "sha512-Sa1+z/P1y7fAJ5XVx1GMSBTHY0JHzxoXzplDhEKOmLgmUFNEJbMjM/jWKtAWEDof7Eb+2xnb/H14x4JkliBgAQ==", "dependencies": { - "@iarna/toml": "^2.2.5", - "ts-matches": "^5.4.1", - "yaml": "^2.2.2" + "isomorphic-fetch": "^3.0.0", + "lodash": "^4.17.21", + "ts-matches": "^5.4.1" } }, "node_modules/@types/node": { @@ -48,6 +43,39 @@ "ncc": "dist/ncc/cli.js" } }, + "node_modules/isomorphic-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz", + "integrity": "sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==", + "dependencies": { + "node-fetch": "^2.6.1", + "whatwg-fetch": "^3.4.1" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, "node_modules/prettier": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", @@ -63,6 +91,11 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, "node_modules/ts-matches": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", @@ -87,15 +120,23 @@ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true }, - "node_modules/yaml": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", - "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-fetch": { + "version": "3.6.20", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", + "integrity": "sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" } } } diff --git a/package.json b/package.json index 09f7611..47d2c18 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "^0.4.0-3df957898aeaa22286970b280e3f525a480dfa96" + "@start9labs/start-sdk": "0.3.6-alpha3" }, "devDependencies": { "@types/node": "^20.11.30", From 4ef5c4171cef144e1977f5b321b219ed5b97fea2 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 12 Jun 2024 02:09:00 -0600 Subject: [PATCH 075/120] bump sdk --- package-lock.json | 46 ++++++++++++++++++++++++++++++++-------------- package.json | 2 +- startos/main.ts | 2 +- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index d47c60c..641d041 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha3" + "@start9labs/start-sdk": "0.3.6-alpha5" }, "devDependencies": { "@types/node": "^20.11.30", @@ -15,20 +15,27 @@ "typescript": "^5.4.3" } }, + "node_modules/@iarna/toml": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", + "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" + }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha3", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha3.tgz", - "integrity": "sha512-Sa1+z/P1y7fAJ5XVx1GMSBTHY0JHzxoXzplDhEKOmLgmUFNEJbMjM/jWKtAWEDof7Eb+2xnb/H14x4JkliBgAQ==", + "version": "0.3.6-alpha5", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha5.tgz", + "integrity": "sha512-4Um6iKKeg1Sei7w6X3o7Yt0HfP+YGQz68DCQrHRMYMGanQuGzc3twmX86aJjUenK+HY6T8j6H3RwN9a4BzSqnA==", "dependencies": { + "@iarna/toml": "^2.2.5", "isomorphic-fetch": "^3.0.0", "lodash": "^4.17.21", - "ts-matches": "^5.4.1" + "ts-matches": "^5.4.1", + "yaml": "^2.2.2" } }, "node_modules/@types/node": { - "version": "20.12.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", - "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", + "version": "20.14.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz", + "integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -77,9 +84,9 @@ } }, "node_modules/prettier": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", - "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -97,9 +104,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-matches": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.4.1.tgz", - "integrity": "sha512-kXrY75F0s0WD15N2bWKDScKlKgwnusN6dTRzGs1N7LlxQRnazrsBISC1HL4sy2adsyk65Zbx3Ui3IGN8leAFOQ==" + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.5.1.tgz", + "integrity": "sha512-UFYaKgfqlg9FROK7bdpYqFwG1CJvP4kOJdjXuWoqxo9jCmANoDw1GxkSCpJgoTeIiSTaTH5Qr1klSspb8c+ydg==" }, "node_modules/typescript": { "version": "5.4.5", @@ -138,6 +145,17 @@ "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } + }, + "node_modules/yaml": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", + "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } } } } diff --git a/package.json b/package.json index 47d2c18..c244f16 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha3" + "@start9labs/start-sdk": "0.3.6-alpha5" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/startos/main.ts b/startos/main.ts index bf48240..ab8f036 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -31,7 +31,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { }).addDaemon('primary', { image: { id: 'main' }, // Must match an Image ID declared in the manifest. command: ['hello-world'], // The command to start the daemon. - mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), + mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), // Mount necessary volumes. ID must match manifest declaration. ready: { display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. // A function below determines the health status of this daemon From aad55723421082e645f7916f39d58d3f1f2d6699 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 20 Jun 2024 16:29:05 -0600 Subject: [PATCH 076/120] use dockerTag, improve makefile and readme --- Dockerfile | 1 - Makefile | 5 ++--- README.md | 24 ++++-------------------- startos/config/spec.ts | 2 +- startos/file-models/config.yml.ts | 3 +-- startos/manifest.ts | 10 ++++------ 6 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6f22d8b..0000000 --- a/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM start9/hello-world diff --git a/Makefile b/Makefile index 0991e8d..b3def55 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,14 @@ PACKAGE_ID := hello-world all: ${PACKAGE_ID}.s9pk # Build targets -${PACKAGE_ID}.s9pk: icon.png instructions.md LICENSE Dockerfile javascript/index.js - start-cli s9pk pack --license=LICENSE +${PACKAGE_ID}.s9pk: $(start-cli s9pk list-ingredients) + start-cli s9pk pack javascript/index.js: $(shell git ls-files startos) node_modules package.json npm run build node_modules: package.json package-lock.json npm ci - npm link @start9labs/start-sdk package-lock.json: package.json npm i diff --git a/README.md b/README.md index 892b12f..d9aca7e 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,7 @@ -# Hello World StartOS +# Hello World for StartOS -A bare bones project serving as a template for [StartOS](https://github.com/Start9Labs/start-os/) service packaging. Learn more about service packaging in the [Developer Docs](https://docs.start9.com/latest/developer-docs/). +A bare bones project serving as a template for [StartOS Service Packaging](https://docs.star9.com/packaging-guide). -## Environment Setup +## Building from source -Install the system dependencies below to build this project by following the instructions in the provided links. You can also find detailed steps to setup your environment in the service packaging [documentation](https://github.com/Start9Labs/service-pipeline#development-environment). - -- [node](https://nodejs.org/en) (using NVM, recommended) -- [docker](https://docs.docker.com/get-docker) -- [docker-buildx](https://docs.docker.com/buildx/working-with-buildx/) -- [make](https://www.gnu.org/software/make/) -- [start-sdk](https://github.com/Start9Labs/start-sdk) - -## Cloning - -``` -git clone https://github.com/Start9Labs/hello-world-startos.git -cd hello-world-startos -``` - -## Building - \ No newline at end of file +Follow the [Quick Start Guide](https://docs.star9.com/packaging-guide/quick-start/) for StartOS service packaging, replacing references to `hello-world-startos` with this service ID. diff --git a/startos/config/spec.ts b/startos/config/spec.ts index 7bab431..9b32c51 100644 --- a/startos/config/spec.ts +++ b/startos/config/spec.ts @@ -10,7 +10,7 @@ export const configSpec = Config.of({ name: Value.text({ name: 'Name', description: - 'When you launch the Hello World UI, it will display "Hello [First Name]"', + 'When you launch the Hello World UI, it will display "Hello [Name]"', required: { default: 'World' }, }), }) diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index f1b0802..36714f0 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -1,10 +1,9 @@ import { matches, FileHelper } from '@start9labs/start-sdk' -const { object, string, natural } = matches +const { object, string } = matches const shape = object({ name: string, - // favoriteNumber: natural, }) export const yamlFile = FileHelper.yaml( diff --git a/startos/manifest.ts b/startos/manifest.ts index d43226c..b2fe07e 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -16,7 +16,7 @@ export const manifest = setupManifest({ marketingSite: 'https://start9.com/', donationUrl: 'https://donate.start9.com/', description: { - short: 'Bare bones example StartOS service', + short: 'Bare bones example of a StartOS service', long: 'Hello World is a template service that provides examples of basic StartOS features.', }, assets: [], // directories of static files you want to mount to your container @@ -24,15 +24,13 @@ export const manifest = setupManifest({ images: { main: { source: { - dockerBuild: { - dockerfile: './Dockerfile', - workdir: '.', - }, + dockerTag: 'start9/hello-world', }, arch: ['x86_64', 'aarch64'], emulateMissingAs: 'aarch64', }, - }, // IDs of images, used when other actions need to run in this image + }, + hardwareRequirements: null, alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', From 4c0f0526fadf19c73cc360f67391fb42433abee1 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Wed, 24 Jul 2024 14:34:22 -0600 Subject: [PATCH 077/120] Update for 0.3.6-alpha6 sdk --- package-lock.json | 59 +++++++++++++++---- package.json | 2 +- startos/manifest.ts | 8 +-- startos/migrations/index.ts | 4 +- .../migrations/{v4_0_0_1.ts => v0.3.6.0.ts} | 4 +- 5 files changed, 57 insertions(+), 20 deletions(-) rename startos/migrations/{v4_0_0_1.ts => v0.3.6.0.ts} (86%) diff --git a/package-lock.json b/package-lock.json index 641d041..3a50fe7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha5" + "@start9labs/start-sdk": "0.3.6-alpha6" }, "devDependencies": { "@types/node": "^20.11.30", @@ -20,15 +20,40 @@ "resolved": "https://registry.npmjs.org/@iarna/toml/-/toml-2.2.5.tgz", "integrity": "sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==" }, + "node_modules/@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha5", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha5.tgz", - "integrity": "sha512-4Um6iKKeg1Sei7w6X3o7Yt0HfP+YGQz68DCQrHRMYMGanQuGzc3twmX86aJjUenK+HY6T8j6H3RwN9a4BzSqnA==", + "version": "0.3.6-alpha6", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha6.tgz", + "integrity": "sha512-HL2K4fbnaqWf6Q2iBwDbAogq0P2E7dqeB1tb4dPzvdlkyuz70za4y0S9L64FQplxMExCQok2N162yXslmFgrYQ==", "dependencies": { "@iarna/toml": "^2.2.5", + "@noble/curves": "^1.4.0", + "@noble/hashes": "^1.4.0", "isomorphic-fetch": "^3.0.0", - "lodash": "^4.17.21", - "ts-matches": "^5.4.1", + "lodash.merge": "^4.6.2", + "mime": "^4.0.3", + "ts-matches": "^5.5.1", "yaml": "^2.2.2" } }, @@ -59,10 +84,24 @@ "whatwg-fetch": "^3.4.1" } }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" + }, + "node_modules/mime": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.4.tgz", + "integrity": "sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==", + "funding": [ + "https://github.com/sponsors/broofa" + ], + "bin": { + "mime": "bin/cli.js" + }, + "engines": { + "node": ">=16" + } }, "node_modules/node-fetch": { "version": "2.7.0", diff --git a/package.json b/package.json index c244f16..df22f58 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha5" + "@start9labs/start-sdk": "0.3.6-alpha6" }, "devDependencies": { "@types/node": "^20.11.30", diff --git a/startos/manifest.ts b/startos/manifest.ts index b2fe07e..04fe74b 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -6,8 +6,8 @@ import { setupManifest } from '@start9labs/start-sdk' export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', - version: '4.0.0.1', - releaseNotes: 'Revamped for StartOS 0.4.0', + version: '0.3.6:0', + releaseNotes: 'Revamped for StartOS 0.3.6', license: 'mit', replaces: ['Hello World (hosted)', 'Goodbye World'], // A list of SaaS services/products this service is intended to replace wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', @@ -26,11 +26,9 @@ export const manifest = setupManifest({ source: { dockerTag: 'start9/hello-world', }, - arch: ['x86_64', 'aarch64'], - emulateMissingAs: 'aarch64', }, }, - hardwareRequirements: null, + hardwareRequirements: {}, alerts: { install: 'Optional alert to display before installing the service', update: 'Optional alert to display before updating the service', diff --git a/startos/migrations/index.ts b/startos/migrations/index.ts index 1074746..739b17c 100644 --- a/startos/migrations/index.ts +++ b/startos/migrations/index.ts @@ -1,7 +1,7 @@ import { sdk } from '../sdk' -import { v4_0_0_1 } from './v4_0_0_1' +import { v0_3_6_0 } from './v0.3.6.0' /** * Here we list every migration in sequential order. */ -export const migrations = sdk.setupMigrations(v4_0_0_1) +export const migrations = sdk.setupMigrations(v0_3_6_0) diff --git a/startos/migrations/v4_0_0_1.ts b/startos/migrations/v0.3.6.0.ts similarity index 86% rename from startos/migrations/v4_0_0_1.ts rename to startos/migrations/v0.3.6.0.ts index 6db0ade..b5d9d92 100644 --- a/startos/migrations/v4_0_0_1.ts +++ b/startos/migrations/v0.3.6.0.ts @@ -7,8 +7,8 @@ import { sdk } from '../sdk' * * The resulting migration (e.g. v4_0_0_0) is exported from here, then imported into migrations/index.ts. */ -export const v4_0_0_1 = sdk.Migration.of({ - version: '4.0.0.1', +export const v0_3_6_0 = sdk.Migration.of({ + version: '0.3.6:0', up: async ({ effects }) => await effects.setConfigured({ configured: false }), down: async ({ effects }) => {}, }) From b4dcf8ecd128d3fe2db33c8d69beef27aaf8cb90 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 30 Jul 2024 21:09:57 -0600 Subject: [PATCH 078/120] minor tweaks --- startos/config/save.ts | 7 ++++--- startos/config/spec.ts | 2 +- startos/file-models/config.yml.ts | 5 +---- startos/manifest.ts | 13 ++++++------- startos/migrations/v0.3.6.0.ts | 2 +- startos/properties.ts | 2 +- startos/store.ts | 10 +++++++--- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/startos/config/save.ts b/startos/config/save.ts index 6620fbc..17a8c28 100644 --- a/startos/config/save.ts +++ b/startos/config/save.ts @@ -16,14 +16,15 @@ export const save = sdk.setupConfigSave( /** ******** save data wherever you want ******** */ - // Whenever possible, save data directly to the underlying config file(s) of the upstream service. - // This ensures that changes to the file from the service's GUI or from the command line are respected. + + // Whenever possible, save data directly to the underlying config file(s) of the upstream service. This ensures that changes to the file from the service's GUI or from the command line are respected. await yamlFile.merge(input, effects) + // If necessary, save package specific data to the package Store. Stateless packages are preferable. await Promise.all([ sdk.store.setOwn( effects, - sdk.StorePath.nestedObject.nameLastUpdatedAt, + sdk.StorePath.otherData.nameLastUpdatedAt, new Date().toISOString(), ), sdk.store.setOwn( diff --git a/startos/config/spec.ts b/startos/config/spec.ts index 9b32c51..5aca94b 100644 --- a/startos/config/spec.ts +++ b/startos/config/spec.ts @@ -4,7 +4,7 @@ const { Config, Value } = sdk /** * Here we define the config spec that will ultimately present to the user as validated form inputs. * - * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object ("sub form"), and union (conditional "sub forms"). + * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (sub form), and union (conditional sub form). */ export const configSpec = Config.of({ name: Value.text({ diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index 36714f0..1c14a15 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -6,7 +6,4 @@ const shape = object({ name: string, }) -export const yamlFile = FileHelper.yaml( - '/media/startos/volumes/main/config.yml', - shape, -) +export const yamlFile = FileHelper.yaml('./config.yml', shape) diff --git a/startos/manifest.ts b/startos/manifest.ts index 04fe74b..a813999 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -9,7 +9,6 @@ export const manifest = setupManifest({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', license: 'mit', - replaces: ['Hello World (hosted)', 'Goodbye World'], // A list of SaaS services/products this service is intended to replace wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', upstreamRepo: 'https://github.com/Start9Labs/hello-world', supportSite: 'https://docs.start9.com/', @@ -29,14 +28,14 @@ export const manifest = setupManifest({ }, }, hardwareRequirements: {}, + // optional alerts to display at different time in the service lifecycle alerts: { install: 'Optional alert to display before installing the service', - update: 'Optional alert to display before updating the service', - uninstall: 'Optional alert to display before uninstalling the service', - restore: - 'Optional alert to display before restoring the service from backup', - start: 'Optional alert to display before starting the service', - stop: 'Optional alert to display before stopping the service', + update: null, + uninstall: null, + restore: null, + start: null, + stop: null, }, dependencies: {}, // See Hello Moon for an example with dependencies }) diff --git a/startos/migrations/v0.3.6.0.ts b/startos/migrations/v0.3.6.0.ts index b5d9d92..5960912 100644 --- a/startos/migrations/v0.3.6.0.ts +++ b/startos/migrations/v0.3.6.0.ts @@ -5,7 +5,7 @@ import { sdk } from '../sdk' * * By convention, each new version that requires a migration should receive its own file like this one. * - * The resulting migration (e.g. v4_0_0_0) is exported from here, then imported into migrations/index.ts. + * The resulting migration (e.g. v0_3_6_0) is exported from here, then imported into migrations/index.ts. */ export const v0_3_6_0 = sdk.Migration.of({ version: '0.3.6:0', diff --git a/startos/properties.ts b/startos/properties.ts index 1c5b743..19e24a0 100644 --- a/startos/properties.ts +++ b/startos/properties.ts @@ -1,7 +1,7 @@ import { sdk } from './sdk' /** - * Here we determine which values from the local Store and underlying service to expose in the UI in Properties. + * Here we determine which values to expose to the UI in Properties. */ export const properties = sdk.setupProperties(async ({ effects }) => { const store = await sdk.store.getOwn(effects, sdk.StorePath).once() diff --git a/startos/store.ts b/startos/store.ts index 2dd1f9b..8998c35 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -5,14 +5,18 @@ import { setupExposeStore } from '@start9labs/start-sdk' * * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior. */ - export type Store = { secretPhrase: string - nestedObject: { + otherData: { nameLastUpdatedAt: string } } +/** + * By default, Store data are kept private to their service. + * + * To expose values from the Store to other services on StartOS, you must include their paths in the array returned by the function below. + */ export const exposedStore = setupExposeStore((pathBuilder) => [ - pathBuilder.nestedObject.nameLastUpdatedAt, + pathBuilder.otherData.nameLastUpdatedAt, ]) From 4e5ef27cfb2fcfbae1b8ed5798ea7f6cef9fdbfa Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Sat, 3 Aug 2024 20:46:14 -0600 Subject: [PATCH 079/120] barely worth a commit --- startos/dependencies/dependencies.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/startos/dependencies/dependencies.ts b/startos/dependencies/dependencies.ts index 58609be..133a018 100644 --- a/startos/dependencies/dependencies.ts +++ b/startos/dependencies/dependencies.ts @@ -3,9 +3,11 @@ import { sdk } from '../sdk' /** * ======================== Dependencies ======================== * - * Here we determine which + * Here we determine your service's dependencies. * * This function runs on install, update, and config save. + * + * See Hello Moon for an example */ export const setDependencies = sdk.setupDependencies( async ({ effects, input }) => ({}), From 474749db419a409350782526b9387f7d1d8a9cbf Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 8 Aug 2024 22:29:53 -0600 Subject: [PATCH 080/120] update to alpha7 --- package-lock.json | 24 ++++++++++++------------ package.json | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a50fe7..54dcea6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,10 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha6" + "@start9labs/start-sdk": "0.3.6-alpha7" }, "devDependencies": { - "@types/node": "^20.11.30", + "@types/node": "^22.1.0", "@vercel/ncc": "^0.38.1", "prettier": "^3.2.5", "typescript": "^5.4.3" @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha6", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha6.tgz", - "integrity": "sha512-HL2K4fbnaqWf6Q2iBwDbAogq0P2E7dqeB1tb4dPzvdlkyuz70za4y0S9L64FQplxMExCQok2N162yXslmFgrYQ==", + "version": "0.3.6-alpha7", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha7.tgz", + "integrity": "sha512-SkiGmfUQCZIngPVGKtxDIaqWYZP3IcWZE5Fj36k8wJreUfbwDMsHXUhLeXDS65+tAiqPA3Fuv3vDzFUhPKKLbw==", "dependencies": { "@iarna/toml": "^2.2.5", "@noble/curves": "^1.4.0", @@ -58,12 +58,12 @@ } }, "node_modules/@types/node": { - "version": "20.14.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.2.tgz", - "integrity": "sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==", + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.1.0.tgz", + "integrity": "sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==", "dev": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.13.0" } }, "node_modules/@vercel/ncc": { @@ -161,9 +161,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", + "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", "dev": true }, "node_modules/webidl-conversions": { diff --git a/package.json b/package.json index df22f58..3d61dfe 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha6" + "@start9labs/start-sdk": "0.3.6-alpha7" }, "devDependencies": { - "@types/node": "^20.11.30", + "@types/node": "^22.1.0", "@vercel/ncc": "^0.38.1", "prettier": "^3.2.5", "typescript": "^5.4.3" From 2a1c849443bcaef38860d30f9edaf67e78b4113f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 9 Aug 2024 07:59:17 -0600 Subject: [PATCH 081/120] update readme --- instructions.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/instructions.md b/instructions.md index c636962..d6bb97f 100644 --- a/instructions.md +++ b/instructions.md @@ -1,5 +1,7 @@ -# Instructions for Hello World +# Hello Moon for StartOS -Instructions go here. These appear to the user in the UI on the Service page under **Instructions**. +A bare bones project serving as a template for [StartOS Service Packaging](https://docs.star9.com/packaging-guide). -You are allowed to include basic [Markdown formatting](https://www.markdownguide.org/basic-syntax). +## Building from source + +Follow the [Quick Start Guide](https://docs.star9.com/packaging-guide/quick-start/) for StartOS service packaging, replacing references to `hello-moon-startos` with this service ID. From 0eb9a39c8a902eb5aa076b88291797ddbae99977 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Mon, 19 Aug 2024 13:12:54 -0600 Subject: [PATCH 082/120] new version graph strategy --- package.json | 2 +- startos/manifest.ts | 5 ++--- startos/migrations/index.ts | 7 ------- startos/migrations/v0.3.6.0.ts | 14 -------------- startos/versions/index.ts | 9 +++++++++ startos/versions/v0.3.6.0.ts | 20 ++++++++++++++++++++ tsconfig.json | 2 +- 7 files changed, 33 insertions(+), 26 deletions(-) delete mode 100644 startos/migrations/index.ts delete mode 100644 startos/migrations/v0.3.6.0.ts create mode 100644 startos/versions/index.ts create mode 100644 startos/versions/v0.3.6.0.ts diff --git a/package.json b/package.json index 3d61dfe..9a4a091 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha7" + "@start9labs/start-sdk": "0.3.6-alpha8" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/manifest.ts b/startos/manifest.ts index a813999..7dca3d8 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,13 +1,12 @@ import { setupManifest } from '@start9labs/start-sdk' +import { versions } from './versions' /** * Here we define static properties of the package to be displayed in the Marketplace and used by StartOS. */ -export const manifest = setupManifest({ +export const manifest = setupManifest(versions, { id: 'hello-world', title: 'Hello World', - version: '0.3.6:0', - releaseNotes: 'Revamped for StartOS 0.3.6', license: 'mit', wrapperRepo: 'https://github.com/Start9Labs/hello-world-wrapper', upstreamRepo: 'https://github.com/Start9Labs/hello-world', diff --git a/startos/migrations/index.ts b/startos/migrations/index.ts deleted file mode 100644 index 739b17c..0000000 --- a/startos/migrations/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { sdk } from '../sdk' -import { v0_3_6_0 } from './v0.3.6.0' - -/** - * Here we list every migration in sequential order. - */ -export const migrations = sdk.setupMigrations(v0_3_6_0) diff --git a/startos/migrations/v0.3.6.0.ts b/startos/migrations/v0.3.6.0.ts deleted file mode 100644 index 5960912..0000000 --- a/startos/migrations/v0.3.6.0.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { sdk } from '../sdk' - -/** - * This is an example migration file. - * - * By convention, each new version that requires a migration should receive its own file like this one. - * - * The resulting migration (e.g. v0_3_6_0) is exported from here, then imported into migrations/index.ts. - */ -export const v0_3_6_0 = sdk.Migration.of({ - version: '0.3.6:0', - up: async ({ effects }) => await effects.setConfigured({ configured: false }), - down: async ({ effects }) => {}, -}) diff --git a/startos/versions/index.ts b/startos/versions/index.ts new file mode 100644 index 0000000..66d0f04 --- /dev/null +++ b/startos/versions/index.ts @@ -0,0 +1,9 @@ +import { VersionGraph } from '@start9labs/start-sdk' +import { v0360 } from './v0.3.6.0' + +/** + * Here we list every version. + * + * THE CURRENT VERSION MUST BE PROVIDED AS THE FIRST ARGUMENT. + */ +export const versions = VersionGraph.of(v0360) diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts new file mode 100644 index 0000000..db3240e --- /dev/null +++ b/startos/versions/v0.3.6.0.ts @@ -0,0 +1,20 @@ +import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' + +/** + * This is an example versions file. + * + * By convention, each new version should receive its own file like this one. + * + * Optionally include migrations for migrating data from one version to another. + * + * The resulting version (e.g. v0360) is exported from here, then imported into migrations/index.ts. + */ + +export const v0360 = VersionInfo.of({ + version: '0.3.6:0', + releaseNotes: 'Revamped for StartOS 0.3.6', + migrations: { + up: ({ effects }) => effects.setConfigured({ configured: false }), + down: IMPOSSIBLE, + }, +}) diff --git a/tsconfig.json b/tsconfig.json index b814af3..bc099e0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["startos/**/*.ts"], + "include": ["startos/**/*.ts", "startos/versions/v0.3.6.0.ts"], "compilerOptions": { "target": "es2022", "module": "None", From 1b0a1c48ef2743d464d71df5667f0fb91d9f981b Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 20 Aug 2024 08:15:38 -0600 Subject: [PATCH 083/120] small change --- package-lock.json | 8 ++++---- startos/versions/v0.3.6.0.ts | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54dcea6..a0585e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha7" + "@start9labs/start-sdk": "0.3.6-alpha8" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha7", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha7.tgz", - "integrity": "sha512-SkiGmfUQCZIngPVGKtxDIaqWYZP3IcWZE5Fj36k8wJreUfbwDMsHXUhLeXDS65+tAiqPA3Fuv3vDzFUhPKKLbw==", + "version": "0.3.6-alpha8", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha8.tgz", + "integrity": "sha512-rbwPIvB2NHZoQBaBZQrfljAgUJKpGegnWgAgEBOpT0+1+PTliQ8x98IxYj7rBGyWL9DJkrRh5GlAxNe+I1YPdQ==", "dependencies": { "@iarna/toml": "^2.2.5", "@noble/curves": "^1.4.0", diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index db3240e..5924905 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -14,7 +14,9 @@ export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { - up: ({ effects }) => effects.setConfigured({ configured: false }), + up: async ({ effects }) => { + await effects.setConfigured({ configured: false }) + }, down: IMPOSSIBLE, }, }) From f6ed594bca6a815cd8cc4c946b855eb7e0aa3580 Mon Sep 17 00:00:00 2001 From: Shadowy Super Coder Date: Wed, 21 Aug 2024 16:01:22 -0600 Subject: [PATCH 084/120] replace 'migrations' with 'versions' --- startos/init.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/startos/init.ts b/startos/init.ts index f6471c8..a33055a 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -4,7 +4,7 @@ import { getSecretPhrase } from './utils' import { yamlFile } from './file-models/config.yml' import { setDependencies } from './dependencies/dependencies' import { setInterfaces } from './interfaces' -import { migrations } from './migrations' +import { versions } from './versions' /** * Here you define arbitrary code that runs *once*, on fresh install only. @@ -30,7 +30,7 @@ const uninstall = sdk.setupUninstall(async ({ effects }) => {}) * Plumbing. DO NOT EDIT. */ export const { init, uninit } = sdk.setupInit( - migrations, + versions, install, uninstall, setInterfaces, From e9133a754cf71944516b2a89a9215cbcfdac8e4c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 6 Sep 2024 14:14:39 -0600 Subject: [PATCH 085/120] remove most comments --- startos/actions/index.ts | 5 --- startos/actions/nameToLogs.ts | 34 ++++++------------- startos/backups.ts | 16 --------- startos/config/read.ts | 7 ---- startos/config/save.ts | 17 ++-------- startos/config/spec.ts | 5 --- startos/dependencies/dependencies.ts | 9 ----- .../dependencies/dependencyConfig/index.ts | 7 ---- startos/file-models/config.yml.ts | 1 - startos/index.ts | 1 + startos/init.ts | 8 ++--- startos/interfaces.ts | 18 +++------- startos/main.ts | 3 +- startos/manifest.ts | 10 ++---- startos/properties.ts | 3 -- startos/sdk.ts | 2 +- startos/store.ts | 30 ++++++++++------ startos/utils.ts | 7 ++-- startos/versions/index.ts | 5 --- startos/versions/v0.3.6.0.ts | 10 ------ 20 files changed, 47 insertions(+), 151 deletions(-) diff --git a/startos/actions/index.ts b/startos/actions/index.ts index ad66eaa..75048b4 100644 --- a/startos/actions/index.ts +++ b/startos/actions/index.ts @@ -1,9 +1,4 @@ import { sdk } from '../sdk' import { nameToLogs } from './nameToLogs' -/** - * Here we list every Action. - * - * By convention, each Action should receive its own file in the "actions" directory. - */ export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index fa0dea7..4ae4b11 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -2,15 +2,6 @@ import { sdk } from '../sdk' const { Config, Value } = sdk import { yamlFile } from '../file-models/config.yml' -/** - * Here we define an Action for our package. - * - * By convention, each Action receives its own file. - */ - -/** - * Actions optionally take arbitrary form input. - */ const input = Config.of({ nameToPrint: Value.text({ name: 'Temp Name', @@ -19,26 +10,23 @@ const input = Config.of({ }), }) -/** - * This function defines the Action, including the optional form input. - */ - export const nameToLogs = sdk.createDynamicAction( - /** id */ + // id 'nameToLogs', - /** metadata */ + + // metadata async ({ effects }) => { return { name: 'Name to Logs', description: 'Prints "Hello [Name]" to the service logs.', warning: null, disabled: false, - input, allowedStatuses: 'onlyRunning', group: null, } }, - /** the execution function */ + + // the execution function async ({ effects, input }) => { const name = input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' @@ -46,14 +34,14 @@ export const nameToLogs = sdk.createDynamicAction( console.info(`Hello ${name}`) return { + version: '0', message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, - value: { - value: name, - copyable: true, - qr: false, - }, + value: name, + copyable: true, + qr: false, } }, - /** spec for form input */ + + // spec for form input input, ) diff --git a/startos/backups.ts b/startos/backups.ts index 661d21e..b81c298 100644 --- a/startos/backups.ts +++ b/startos/backups.ts @@ -1,19 +1,3 @@ import { sdk } from './sdk' -/** - * Here we define which volumes to back up, including advanced options. - */ - -/** - * This example backs up the entire "main" volume. - */ export const { createBackup, restoreBackup } = sdk.setupBackups('main') - -/** - * This example backs up the "main" volume, but excludes a hypothetical directory called "excludedDir". - */ -// export const { createBackup, restoreBackup } = sdk.setupBackups( -// sdk.Backups.volumes('main').setOptions({ -// exclude: ['path/to/excludedDir'], -// }), -// ) diff --git a/startos/config/read.ts b/startos/config/read.ts index 4782505..bf1d1d2 100644 --- a/startos/config/read.ts +++ b/startos/config/read.ts @@ -2,16 +2,9 @@ import { sdk } from '../sdk' import { yamlFile } from '../file-models/config.yml' import { configSpec } from './spec' -/** - * This function executes on config read. - * - * Use this function to gather data from various files and assemble into a valid config to display to the user. - */ export const read = sdk.setupConfigRead(configSpec, async ({ effects }) => { - // Retrieve data from the service's native config file. So, even if the user changes this file from the service's GUI or from the command line, the StartOS config will update as well. const configYml = await yamlFile.read(effects) - // Return the expected config spec to display to the user return { name: configYml?.name || '', } diff --git a/startos/config/save.ts b/startos/config/save.ts index 17a8c28..72d2e59 100644 --- a/startos/config/save.ts +++ b/startos/config/save.ts @@ -5,26 +5,15 @@ import { setInterfaces } from '../interfaces' import { yamlFile } from '../file-models/config.yml' import { configSpec } from './spec' -/** - * This function executes on config save. - * - * Use it to persist config data to various files and to establish any resulting dependencies. - */ export const save = sdk.setupConfigSave( configSpec, async ({ effects, input }) => { - /** - ******** save data wherever you want ******** - */ - - // Whenever possible, save data directly to the underlying config file(s) of the upstream service. This ensures that changes to the file from the service's GUI or from the command line are respected. await yamlFile.merge(input, effects) - // If necessary, save package specific data to the package Store. Stateless packages are preferable. await Promise.all([ sdk.store.setOwn( effects, - sdk.StorePath.otherData.nameLastUpdatedAt, + sdk.StorePath.nameLastUpdatedAt, new Date().toISOString(), ), sdk.store.setOwn( @@ -35,9 +24,9 @@ export const save = sdk.setupConfigSave( ]) return { - interfacesReceipt: await setInterfaces({ effects, input }), // Plumbing. DO NOT EDIT. This line causes setInterfaces() to run whenever config is saved. + interfacesReceipt: await setInterfaces({ effects, input }), // Plumbing. DO NOT EDIT. dependenciesReceipt: await setDependencies({ effects, input }), // Plumbing. DO NOT EDIT. - restart: true, // optionally restart the service on config save. + restart: true, } }, ) diff --git a/startos/config/spec.ts b/startos/config/spec.ts index 5aca94b..1ac98e2 100644 --- a/startos/config/spec.ts +++ b/startos/config/spec.ts @@ -1,11 +1,6 @@ import { sdk } from '../sdk' const { Config, Value } = sdk -/** - * Here we define the config spec that will ultimately present to the user as validated form inputs. - * - * Most form controls are available, including text, textarea, number, toggle, select, multiselect, list, color, datetime, object (sub form), and union (conditional sub form). - */ export const configSpec = Config.of({ name: Value.text({ name: 'Name', diff --git a/startos/dependencies/dependencies.ts b/startos/dependencies/dependencies.ts index 133a018..829d986 100644 --- a/startos/dependencies/dependencies.ts +++ b/startos/dependencies/dependencies.ts @@ -1,14 +1,5 @@ import { sdk } from '../sdk' -/** - * ======================== Dependencies ======================== - * - * Here we determine your service's dependencies. - * - * This function runs on install, update, and config save. - * - * See Hello Moon for an example - */ export const setDependencies = sdk.setupDependencies( async ({ effects, input }) => ({}), ) diff --git a/startos/dependencies/dependencyConfig/index.ts b/startos/dependencies/dependencyConfig/index.ts index 7d5509d..3df9ea4 100644 --- a/startos/dependencies/dependencyConfig/index.ts +++ b/startos/dependencies/dependencyConfig/index.ts @@ -1,11 +1,4 @@ import { sdk } from '../../sdk' import { configSpec } from '../../config/spec' -/** - * Here we list every dependency config. - * - * By convention, each Dependency Config should receive its own file in the "dependencyConfig" directory. - * - * See Hello Moon for an example. - */ export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index 1c14a15..7b73848 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -1,5 +1,4 @@ import { matches, FileHelper } from '@start9labs/start-sdk' - const { object, string } = matches const shape = object({ diff --git a/startos/index.ts b/startos/index.ts index b7925bd..6ae6d65 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -6,5 +6,6 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' export { actions, actionsMetadata } from './actions' +export { properties } from './properties' export { dependencyConfig } from './dependencies/dependencyConfig' export { manifest } from './manifest' diff --git a/startos/init.ts b/startos/init.ts index a33055a..f539c86 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -6,9 +6,7 @@ import { setDependencies } from './dependencies/dependencies' import { setInterfaces } from './interfaces' import { versions } from './versions' -/** - * Here you define arbitrary code that runs *once*, on fresh install only. - */ +// **** Install **** const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' @@ -21,9 +19,7 @@ const install = sdk.setupInstall(async ({ effects }) => { ) }) -/** - * Here we define arbitrary code that runs once, on uninstall only. - */ +// **** Uninstall **** const uninstall = sdk.setupUninstall(async ({ effects }) => {}) /** diff --git a/startos/interfaces.ts b/startos/interfaces.ts index d36d332..efa47d3 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -1,29 +1,19 @@ import { sdk } from './sdk' import { configSpec } from './config/spec' -// It is good practice to abstract these two variables from each interface, as they may be used elsewhere in the package codebase or by dependent packages. -export const uiPort = 80 -export const webUiInterfaceId = 'webui' - -/** - * ======================== Service Interfaces ======================== - * - * Here we decide how the service will be exposed to the outside world. - * - * This function runs on install, update, and config save. - */ export const setInterfaces = sdk.setupInterfaces( configSpec, async ({ effects, input }) => { const uiMulti = sdk.host.multi(effects, 'ui-multi') - const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http' }) + const uiMultiOrigin = await uiMulti.bindPort(80, { + protocol: 'http', + }) const ui = sdk.createInterface(effects, { name: 'Web UI', - id: webUiInterfaceId, + id: 'ui', description: 'The web interface of Hello World', type: 'ui', hasPrimary: false, - disabled: false, masked: false, schemeOverride: null, username: null, diff --git a/startos/main.ts b/startos/main.ts index ab8f036..179abf0 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -1,5 +1,4 @@ import { sdk } from './sdk' -import { uiPort } from './interfaces' import { T } from '@start9labs/start-sdk' export const main = sdk.setupMain(async ({ effects, started }) => { @@ -36,7 +35,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. // A function below determines the health status of this daemon fn: () => - sdk.healthCheck.checkPortListening(effects, uiPort, { + sdk.healthCheck.checkPortListening(effects, 80, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), diff --git a/startos/manifest.ts b/startos/manifest.ts index 7dca3d8..4f4dc66 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,9 +1,6 @@ import { setupManifest } from '@start9labs/start-sdk' import { versions } from './versions' -/** - * Here we define static properties of the package to be displayed in the Marketplace and used by StartOS. - */ export const manifest = setupManifest(versions, { id: 'hello-world', title: 'Hello World', @@ -17,8 +14,8 @@ export const manifest = setupManifest(versions, { short: 'Bare bones example of a StartOS service', long: 'Hello World is a template service that provides examples of basic StartOS features.', }, - assets: [], // directories of static files you want to mount to your container - volumes: ['main'], // IDs of persistence volumes that will be mounted to your container + assets: [], + volumes: ['main'], images: { main: { source: { @@ -27,7 +24,6 @@ export const manifest = setupManifest(versions, { }, }, hardwareRequirements: {}, - // optional alerts to display at different time in the service lifecycle alerts: { install: 'Optional alert to display before installing the service', update: null, @@ -36,5 +32,5 @@ export const manifest = setupManifest(versions, { start: null, stop: null, }, - dependencies: {}, // See Hello Moon for an example with dependencies + dependencies: {}, }) diff --git a/startos/properties.ts b/startos/properties.ts index 19e24a0..9657aee 100644 --- a/startos/properties.ts +++ b/startos/properties.ts @@ -1,8 +1,5 @@ import { sdk } from './sdk' -/** - * Here we determine which values to expose to the UI in Properties. - */ export const properties = sdk.setupProperties(async ({ effects }) => { const store = await sdk.store.getOwn(effects, sdk.StorePath).once() diff --git a/startos/sdk.ts b/startos/sdk.ts index 5146d32..26c3015 100644 --- a/startos/sdk.ts +++ b/startos/sdk.ts @@ -5,7 +5,7 @@ import { Store } from './store' /** * Plumbing. DO NOT EDIT. * - * The exported "sdk" const will be imported and used throughout the package codebase. + * The exported "sdk" const is used throughout this package codebase. */ export const sdk = StartSdk.of() .withManifest(manifest) diff --git a/startos/store.ts b/startos/store.ts index 8998c35..f1d3f2f 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -1,22 +1,30 @@ import { setupExposeStore } from '@start9labs/start-sdk' /** - * The Store is for persisting data that are needed by the package but are NOT persisted by the upstream service. Do NOT persist data here that are already being persisted by the service itself. + * @description The Store is used for persisting arbitrary data that are needed by the wrapper + * package but are NOT persisted by the upstream service. Do NOT persist data here that are + * already being persisted by the service itself. * - * Store data should be kept to a minimum. Stateless packages are easier to maintain and eliminate unexpected behavior. + * Store data should be kept to a minimum. Stateless packages are easier to maintain + * and eliminate unexpected behavior. + * @type {Record} + * @example + * ``` + * export type Store = { + * key1: string + * key2: boolean + * key3: number + * key4: { + * key5: string[] + * } + * } + * ``` */ export type Store = { secretPhrase: string - otherData: { - nameLastUpdatedAt: string - } + nameLastUpdatedAt: string } -/** - * By default, Store data are kept private to their service. - * - * To expose values from the Store to other services on StartOS, you must include their paths in the array returned by the function below. - */ export const exposedStore = setupExposeStore((pathBuilder) => [ - pathBuilder.otherData.nameLastUpdatedAt, + pathBuilder.nameLastUpdatedAt, ]) diff --git a/startos/utils.ts b/startos/utils.ts index dbdf0f8..814d7cf 100644 --- a/startos/utils.ts +++ b/startos/utils.ts @@ -1,8 +1,5 @@ -/** - * Here we define any constants or functions that are shared by multiple components throughout the package codebase. - * - * For simple packages, this file may remain empty. - */ +// Here we define any constants or functions that are shared by multiple components +// throughout the package codebase. This file will be unnecessary for many packages. export function getSecretPhrase(name: string): string { return `Knock knock. Who's there? ${name}!` diff --git a/startos/versions/index.ts b/startos/versions/index.ts index 66d0f04..339e78f 100644 --- a/startos/versions/index.ts +++ b/startos/versions/index.ts @@ -1,9 +1,4 @@ import { VersionGraph } from '@start9labs/start-sdk' import { v0360 } from './v0.3.6.0' -/** - * Here we list every version. - * - * THE CURRENT VERSION MUST BE PROVIDED AS THE FIRST ARGUMENT. - */ export const versions = VersionGraph.of(v0360) diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index 5924905..c2983b0 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,15 +1,5 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' -/** - * This is an example versions file. - * - * By convention, each new version should receive its own file like this one. - * - * Optionally include migrations for migrating data from one version to another. - * - * The resulting version (e.g. v0360) is exported from here, then imported into migrations/index.ts. - */ - export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', From 79f1b1fc605895e14770b2d591a1c2d1ca687013 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 19 Sep 2024 14:21:54 -0600 Subject: [PATCH 086/120] updates for new actions --- instructions.md | 4 +- startos/actions/config.ts | 36 +++++++++++++++ startos/actions/index.ts | 3 +- startos/actions/nameToLogs.ts | 41 +++++++---------- startos/backups.ts | 4 +- startos/config/index.ts | 9 ---- startos/config/read.ts | 11 ----- startos/config/save.ts | 32 -------------- startos/config/spec.ts | 11 ----- startos/{dependencies => }/dependencies.ts | 2 +- .../dependencies/dependencyConfig/index.ts | 4 -- startos/index.ts | 4 +- startos/init.ts | 8 ++-- startos/interfaces.ts | 44 +++++++++---------- startos/versions/v0.3.6.0.ts | 4 +- 15 files changed, 88 insertions(+), 129 deletions(-) create mode 100644 startos/actions/config.ts delete mode 100644 startos/config/index.ts delete mode 100644 startos/config/read.ts delete mode 100644 startos/config/save.ts delete mode 100644 startos/config/spec.ts rename startos/{dependencies => }/dependencies.ts (76%) delete mode 100644 startos/dependencies/dependencyConfig/index.ts diff --git a/instructions.md b/instructions.md index d6bb97f..d9aca7e 100644 --- a/instructions.md +++ b/instructions.md @@ -1,7 +1,7 @@ -# Hello Moon for StartOS +# Hello World for StartOS A bare bones project serving as a template for [StartOS Service Packaging](https://docs.star9.com/packaging-guide). ## Building from source -Follow the [Quick Start Guide](https://docs.star9.com/packaging-guide/quick-start/) for StartOS service packaging, replacing references to `hello-moon-startos` with this service ID. +Follow the [Quick Start Guide](https://docs.star9.com/packaging-guide/quick-start/) for StartOS service packaging, replacing references to `hello-world-startos` with this service ID. diff --git a/startos/actions/config.ts b/startos/actions/config.ts new file mode 100644 index 0000000..dea1bd2 --- /dev/null +++ b/startos/actions/config.ts @@ -0,0 +1,36 @@ +import { sdk } from '../sdk' +const { InputSpec, Value } = sdk +import { yamlFile } from '../file-models/config.yml' + +export const input = InputSpec.of({ + name: Value.text({ + name: 'Name', + description: + 'When you launch the Hello World UI, it will display "Hello [Name]"', + required: { default: 'World' }, + }), +}) + +export const config = sdk.Action.withInput( + // id + 'config', + + // metadata + { + name: 'Configure', + description: 'edit the underlying config.yaml of Hello World', + warning: null, + allowedStatuses: 'all', + group: null, + visibility: 'enabled', + }, + + // spec for form input + input, + + // optionally pre-fill the input form + ({ effects }) => yamlFile.read(effects), + + // the execution function + async ({ effects, input }) => yamlFile.merge(effects, input), +) diff --git a/startos/actions/index.ts b/startos/actions/index.ts index 75048b4..cd84dfa 100644 --- a/startos/actions/index.ts +++ b/startos/actions/index.ts @@ -1,4 +1,5 @@ import { sdk } from '../sdk' import { nameToLogs } from './nameToLogs' +import { config } from './config' -export const { actions, actionsMetadata } = sdk.setupActions(nameToLogs) +export const actions = sdk.setupActions(nameToLogs, config) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 4ae4b11..160e810 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -1,35 +1,27 @@ import { sdk } from '../sdk' -const { Config, Value } = sdk import { yamlFile } from '../file-models/config.yml' -const input = Config.of({ - nameToPrint: Value.text({ - name: 'Temp Name', - description: 'If no name is provided, the name from config will be used', - required: false, - }), -}) - -export const nameToLogs = sdk.createDynamicAction( +export const nameToLogs = sdk.Action.withoutInput( // id 'nameToLogs', // metadata - async ({ effects }) => { - return { - name: 'Name to Logs', - description: 'Prints "Hello [Name]" to the service logs.', - warning: null, - disabled: false, - allowedStatuses: 'onlyRunning', - group: null, - } - }, + async ({ effects }) => ({ + name: 'Name to Logs', + description: 'Prints "Hello [Name]" to the service logs.', + warning: null, + allowedStatuses: 'only-running', + group: null, + visibility: (await sdk.store + .getOwn(effects, sdk.StorePath.nameLastUpdatedAt) + .once()) + ? 'enabled' + : { disabled: 'Cannot print name to logs until you update your name.' }, + }), // the execution function - async ({ effects, input }) => { - const name = - input.nameToPrint || (await yamlFile.read(effects))?.name || 'Unknown' + async ({ effects }) => { + const name = (await yamlFile.read(effects))!.name console.info(`Hello ${name}`) @@ -41,7 +33,4 @@ export const nameToLogs = sdk.createDynamicAction( qr: false, } }, - - // spec for form input - input, ) diff --git a/startos/backups.ts b/startos/backups.ts index b81c298..6615a45 100644 --- a/startos/backups.ts +++ b/startos/backups.ts @@ -1,3 +1,5 @@ import { sdk } from './sdk' -export const { createBackup, restoreBackup } = sdk.setupBackups('main') +export const { createBackup, restoreBackup } = sdk.setupBackups( + sdk.Backups.volumes('main'), +) diff --git a/startos/config/index.ts b/startos/config/index.ts deleted file mode 100644 index 71345b2..0000000 --- a/startos/config/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { sdk } from '../sdk' -import { configSpec } from './spec' -import { read } from './read' -import { save } from './save' - -/** - * Plumbing. DO NOT EDIT. - */ -export const { getConfig, setConfig } = sdk.setupConfig(configSpec, save, read) diff --git a/startos/config/read.ts b/startos/config/read.ts deleted file mode 100644 index bf1d1d2..0000000 --- a/startos/config/read.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { sdk } from '../sdk' -import { yamlFile } from '../file-models/config.yml' -import { configSpec } from './spec' - -export const read = sdk.setupConfigRead(configSpec, async ({ effects }) => { - const configYml = await yamlFile.read(effects) - - return { - name: configYml?.name || '', - } -}) diff --git a/startos/config/save.ts b/startos/config/save.ts deleted file mode 100644 index 72d2e59..0000000 --- a/startos/config/save.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { sdk } from '../sdk' -import { getSecretPhrase } from '../utils' -import { setDependencies } from '../dependencies/dependencies' -import { setInterfaces } from '../interfaces' -import { yamlFile } from '../file-models/config.yml' -import { configSpec } from './spec' - -export const save = sdk.setupConfigSave( - configSpec, - async ({ effects, input }) => { - await yamlFile.merge(input, effects) - - await Promise.all([ - sdk.store.setOwn( - effects, - sdk.StorePath.nameLastUpdatedAt, - new Date().toISOString(), - ), - sdk.store.setOwn( - effects, - sdk.StorePath.secretPhrase, - getSecretPhrase(input.name), - ), - ]) - - return { - interfacesReceipt: await setInterfaces({ effects, input }), // Plumbing. DO NOT EDIT. - dependenciesReceipt: await setDependencies({ effects, input }), // Plumbing. DO NOT EDIT. - restart: true, - } - }, -) diff --git a/startos/config/spec.ts b/startos/config/spec.ts deleted file mode 100644 index 1ac98e2..0000000 --- a/startos/config/spec.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { sdk } from '../sdk' -const { Config, Value } = sdk - -export const configSpec = Config.of({ - name: Value.text({ - name: 'Name', - description: - 'When you launch the Hello World UI, it will display "Hello [Name]"', - required: { default: 'World' }, - }), -}) diff --git a/startos/dependencies/dependencies.ts b/startos/dependencies.ts similarity index 76% rename from startos/dependencies/dependencies.ts rename to startos/dependencies.ts index 829d986..336d120 100644 --- a/startos/dependencies/dependencies.ts +++ b/startos/dependencies.ts @@ -1,4 +1,4 @@ -import { sdk } from '../sdk' +import { sdk } from './sdk' export const setDependencies = sdk.setupDependencies( async ({ effects, input }) => ({}), diff --git a/startos/dependencies/dependencyConfig/index.ts b/startos/dependencies/dependencyConfig/index.ts deleted file mode 100644 index 3df9ea4..0000000 --- a/startos/dependencies/dependencyConfig/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { sdk } from '../../sdk' -import { configSpec } from '../../config/spec' - -export const dependencyConfig = sdk.setupDependencyConfig(configSpec, {}) diff --git a/startos/index.ts b/startos/index.ts index 6ae6d65..1dddeba 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -1,11 +1,9 @@ /** * Plumbing. DO NOT EDIT. */ -export { getConfig, setConfig } from './config' export { createBackup, restoreBackup } from './backups' export { main } from './main' export { init, uninit } from './init' -export { actions, actionsMetadata } from './actions' +export { actions } from './actions' export { properties } from './properties' -export { dependencyConfig } from './dependencies/dependencyConfig' export { manifest } from './manifest' diff --git a/startos/init.ts b/startos/init.ts index f539c86..e475f3d 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -2,15 +2,16 @@ import { sdk } from './sdk' import { exposedStore } from './store' import { getSecretPhrase } from './utils' import { yamlFile } from './file-models/config.yml' -import { setDependencies } from './dependencies/dependencies' +import { setDependencies } from './dependencies' import { setInterfaces } from './interfaces' import { versions } from './versions' +import { actions } from './actions' // **** Install **** const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' - await yamlFile.merge({ name }, effects) + await yamlFile.merge(effects, { name }) await sdk.store.setOwn( effects, @@ -25,11 +26,12 @@ const uninstall = sdk.setupUninstall(async ({ effects }) => {}) /** * Plumbing. DO NOT EDIT. */ -export const { init, uninit } = sdk.setupInit( +export const { init, uninit } = sdk.setupPackageInit( versions, install, uninstall, setInterfaces, setDependencies, + actions, exposedStore, ) diff --git a/startos/interfaces.ts b/startos/interfaces.ts index efa47d3..fe751a8 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -1,28 +1,24 @@ import { sdk } from './sdk' -import { configSpec } from './config/spec' -export const setInterfaces = sdk.setupInterfaces( - configSpec, - async ({ effects, input }) => { - const uiMulti = sdk.host.multi(effects, 'ui-multi') - const uiMultiOrigin = await uiMulti.bindPort(80, { - protocol: 'http', - }) - const ui = sdk.createInterface(effects, { - name: 'Web UI', - id: 'ui', - description: 'The web interface of Hello World', - type: 'ui', - hasPrimary: false, - masked: false, - schemeOverride: null, - username: null, - path: '', - search: {}, - }) +export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => { + const uiMulti = sdk.host.multi(effects, 'ui-multi') + const uiMultiOrigin = await uiMulti.bindPort(80, { + protocol: 'http', + }) + const ui = sdk.createInterface(effects, { + name: 'Web UI', + id: 'ui', + description: 'The web interface of Hello World', + type: 'ui', + hasPrimary: false, + masked: false, + schemeOverride: null, + username: null, + path: '', + search: {}, + }) - const uiReceipt = await uiMultiOrigin.export([ui]) + const uiReceipt = await uiMultiOrigin.export([ui]) - return [uiReceipt] - }, -) + return [uiReceipt] +}) diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index c2983b0..00b442a 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,11 +1,13 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' +import { sdk } from '../sdk' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { up: async ({ effects }) => { - await effects.setConfigured({ configured: false }) + // require the user to run the "config" action + await sdk.action.requestOwn(effects, { actionId: 'config' }) }, down: IMPOSSIBLE, }, From 23bae823c1116b61be96213c50dc657ab414a28e Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 23 Sep 2024 16:46:20 -0600 Subject: [PATCH 087/120] update for sdk changes --- startos/actions/config.ts | 9 ++++++--- startos/actions/index.ts | 4 ++-- startos/actions/nameToLogs.ts | 10 +++++++--- startos/dependencies.ts | 2 +- startos/index.ts | 2 +- startos/init.ts | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index dea1bd2..e0b6729 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -20,7 +20,7 @@ export const config = sdk.Action.withInput( name: 'Configure', description: 'edit the underlying config.yaml of Hello World', warning: null, - allowedStatuses: 'all', + allowedStatuses: 'any', group: null, visibility: 'enabled', }, @@ -29,8 +29,11 @@ export const config = sdk.Action.withInput( input, // optionally pre-fill the input form - ({ effects }) => yamlFile.read(effects), + ({ effects }) => yamlFile.read(), // the execution function - async ({ effects, input }) => yamlFile.merge(effects, input), + async ({ effects, input }) => { + await yamlFile.merge(input) + return null + }, ) diff --git a/startos/actions/index.ts b/startos/actions/index.ts index cd84dfa..4c33fd9 100644 --- a/startos/actions/index.ts +++ b/startos/actions/index.ts @@ -1,5 +1,5 @@ import { sdk } from '../sdk' -import { nameToLogs } from './nameToLogs' import { config } from './config' +import { nameToLogs } from './nameToLogs' -export const actions = sdk.setupActions(nameToLogs, config) +export const actions = sdk.Actions.of().addAction(config).addAction(nameToLogs) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 160e810..827cc41 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -14,14 +14,18 @@ export const nameToLogs = sdk.Action.withoutInput( group: null, visibility: (await sdk.store .getOwn(effects, sdk.StorePath.nameLastUpdatedAt) - .once()) + .const()) ? 'enabled' - : { disabled: 'Cannot print name to logs until you update your name.' }, + : { + disabled: { + reason: 'Cannot print name to logs until you update your name.', + }, + }, }), // the execution function async ({ effects }) => { - const name = (await yamlFile.read(effects))!.name + const name = (await yamlFile.read())!.name console.info(`Hello ${name}`) diff --git a/startos/dependencies.ts b/startos/dependencies.ts index 336d120..7221c4b 100644 --- a/startos/dependencies.ts +++ b/startos/dependencies.ts @@ -1,5 +1,5 @@ import { sdk } from './sdk' export const setDependencies = sdk.setupDependencies( - async ({ effects, input }) => ({}), + async ({ effects }) => ({}), ) diff --git a/startos/index.ts b/startos/index.ts index 1dddeba..9996405 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -3,7 +3,7 @@ */ export { createBackup, restoreBackup } from './backups' export { main } from './main' -export { init, uninit } from './init' +export { packageInit, packageUninit, containerInit } from './init' export { actions } from './actions' export { properties } from './properties' export { manifest } from './manifest' diff --git a/startos/init.ts b/startos/init.ts index e475f3d..8eba26d 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -11,7 +11,7 @@ import { actions } from './actions' const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' - await yamlFile.merge(effects, { name }) + await yamlFile.merge({ name }) await sdk.store.setOwn( effects, @@ -26,7 +26,7 @@ const uninstall = sdk.setupUninstall(async ({ effects }) => {}) /** * Plumbing. DO NOT EDIT. */ -export const { init, uninit } = sdk.setupPackageInit( +export const { packageInit, packageUninit, containerInit } = sdk.setupInit( versions, install, uninstall, From d609af41e3633a8a7d82a9bcb7f0dd028aca95e6 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 25 Sep 2024 12:01:03 -0600 Subject: [PATCH 088/120] allow backups to be dynamic --- startos/backups.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startos/backups.ts b/startos/backups.ts index 6615a45..dd75053 100644 --- a/startos/backups.ts +++ b/startos/backups.ts @@ -1,5 +1,5 @@ import { sdk } from './sdk' -export const { createBackup, restoreBackup } = sdk.setupBackups( +export const { createBackup, restoreBackup } = sdk.setupBackups(async () => sdk.Backups.volumes('main'), ) From 267a459b44a53e13de9ebda7d60f600986d4c1af Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 25 Sep 2024 13:16:33 -0600 Subject: [PATCH 089/120] simplify types --- startos/actions/config.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index e0b6729..f8d9730 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -32,8 +32,5 @@ export const config = sdk.Action.withInput( ({ effects }) => yamlFile.read(), // the execution function - async ({ effects, input }) => { - await yamlFile.merge(input) - return null - }, + ({ effects, input }) => yamlFile.merge(input).then((_) => null), ) From 51d67be48dfb904e078d3febc1782d4851b3bc78 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 3 Oct 2024 15:19:23 -0600 Subject: [PATCH 090/120] delete properties --- startos/actions/config.ts | 18 ++++++++++++++---- startos/actions/index.ts | 6 +++++- startos/actions/properties.ts | 30 ++++++++++++++++++++++++++++++ startos/index.ts | 1 - startos/init.ts | 4 ++-- startos/properties.ts | 16 ---------------- 6 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 startos/actions/properties.ts delete mode 100644 startos/properties.ts diff --git a/startos/actions/config.ts b/startos/actions/config.ts index f8d9730..3c52364 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -1,8 +1,9 @@ import { sdk } from '../sdk' const { InputSpec, Value } = sdk import { yamlFile } from '../file-models/config.yml' +import { getSecretPhrase } from '../utils' -export const input = InputSpec.of({ +export const inputSpec = InputSpec.of({ name: Value.text({ name: 'Name', description: @@ -25,12 +26,21 @@ export const config = sdk.Action.withInput( visibility: 'enabled', }, - // spec for form input - input, + // form input specification + inputSpec, // optionally pre-fill the input form ({ effects }) => yamlFile.read(), // the execution function - ({ effects, input }) => yamlFile.merge(input).then((_) => null), + async ({ effects, input }) => { + await Promise.all([ + yamlFile.merge(input), + sdk.store.setOwn( + effects, + sdk.StorePath.secretPhrase, + getSecretPhrase(input.name), + ), + ]) + }, ) diff --git a/startos/actions/index.ts b/startos/actions/index.ts index 4c33fd9..40acbc9 100644 --- a/startos/actions/index.ts +++ b/startos/actions/index.ts @@ -1,5 +1,9 @@ +import { properties } from './properties' import { sdk } from '../sdk' import { config } from './config' import { nameToLogs } from './nameToLogs' -export const actions = sdk.Actions.of().addAction(config).addAction(nameToLogs) +export const actions = sdk.Actions.of() + .addAction(config) + .addAction(properties) + .addAction(nameToLogs) diff --git a/startos/actions/properties.ts b/startos/actions/properties.ts new file mode 100644 index 0000000..0406189 --- /dev/null +++ b/startos/actions/properties.ts @@ -0,0 +1,30 @@ +import { sdk } from '../sdk' + +export const properties = sdk.Action.withoutInput( + // id + 'properties', + + // metadata + async ({ effects }) => ({ + name: 'Properties', + description: 'Useful information about Hello World', + warning: null, + allowedStatuses: 'any', + group: null, + visibility: 'enabled', + }), + + // the execution function + async ({ effects }) => { + return { + version: '1', + type: 'string', + name: 'Secret Phrase', + description: 'Use this phrase to gain access to extraordinary places', + value: await sdk.store.getOwn(effects, sdk.StorePath.secretPhrase).once(), + copyable: true, + qr: false, + masked: true, + } + }, +) diff --git a/startos/index.ts b/startos/index.ts index 9996405..12c0e2c 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -5,5 +5,4 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { packageInit, packageUninit, containerInit } from './init' export { actions } from './actions' -export { properties } from './properties' export { manifest } from './manifest' diff --git a/startos/init.ts b/startos/init.ts index 8eba26d..3fe8b24 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -1,11 +1,11 @@ import { sdk } from './sdk' import { exposedStore } from './store' -import { getSecretPhrase } from './utils' -import { yamlFile } from './file-models/config.yml' import { setDependencies } from './dependencies' import { setInterfaces } from './interfaces' import { versions } from './versions' import { actions } from './actions' +import { getSecretPhrase } from './utils' +import { yamlFile } from './file-models/config.yml' // **** Install **** const install = sdk.setupInstall(async ({ effects }) => { diff --git a/startos/properties.ts b/startos/properties.ts deleted file mode 100644 index 9657aee..0000000 --- a/startos/properties.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { sdk } from './sdk' - -export const properties = sdk.setupProperties(async ({ effects }) => { - const store = await sdk.store.getOwn(effects, sdk.StorePath).once() - - return { - 'Secret Phrase': { - type: 'string', - value: store.secretPhrase, - description: 'Use this phrase to gain access to extraordinary places', - copyable: true, - qr: false, - masked: true, - }, - } -}) From 1c90418b91374ab3f3d4695a169d5b9f429c74a0 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 3 Oct 2024 16:57:56 -0600 Subject: [PATCH 091/120] use async for action metadata --- startos/actions/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index 3c52364..08817d7 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -17,14 +17,14 @@ export const config = sdk.Action.withInput( 'config', // metadata - { + async ({ effects }) => ({ name: 'Configure', description: 'edit the underlying config.yaml of Hello World', warning: null, allowedStatuses: 'any', group: null, visibility: 'enabled', - }, + }), // form input specification inputSpec, From 27f6cd3c57d3a50b4644c2642ec953d050b6a6e2 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 9 Oct 2024 16:37:03 -0600 Subject: [PATCH 092/120] update for latest types --- startos/actions/config.ts | 2 +- startos/actions/nameToLogs.ts | 15 ++++++++------- startos/versions/v0.3.6.0.ts | 6 +----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index 08817d7..a79a4a3 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -30,7 +30,7 @@ export const config = sdk.Action.withInput( inputSpec, // optionally pre-fill the input form - ({ effects }) => yamlFile.read(), + ({ effects }) => yamlFile.read.once(), // the execution function async ({ effects, input }) => { diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 827cc41..100e033 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -17,23 +17,24 @@ export const nameToLogs = sdk.Action.withoutInput( .const()) ? 'enabled' : { - disabled: { - reason: 'Cannot print name to logs until you update your name.', - }, + disabled: 'Cannot print name to logs until you update your name.', }, }), // the execution function async ({ effects }) => { - const name = (await yamlFile.read())!.name + const name = (await yamlFile.read.once())!.name console.info(`Hello ${name}`) return { - version: '0', - message: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, + version: '1', + type: 'string', + name: 'Log Successful', + description: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, value: name, - copyable: true, + masked: false, + copyable: false, qr: false, } }, diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index 00b442a..42f60ad 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,14 +1,10 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' -import { sdk } from '../sdk' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { - up: async ({ effects }) => { - // require the user to run the "config" action - await sdk.action.requestOwn(effects, { actionId: 'config' }) - }, + up: async ({ effects }) => {}, down: IMPOSSIBLE, }, }) From 7e2ae0b7760e89fa7eef4c63d680d44b34737219 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 9 Oct 2024 18:25:11 -0600 Subject: [PATCH 093/120] severity as param --- startos/versions/v0.3.6.0.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index 42f60ad..c058ad6 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,10 +1,14 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' +import { sdk } from '../sdk' +import { config } from '../actions/config' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { - up: async ({ effects }) => {}, + up: async ({ effects }) => { + await sdk.action.requestOwn(effects, config, 'critical') + }, down: IMPOSSIBLE, }, }) From 12409c9e36b6e0a8d4aa7221d19c8f8a7165f048 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 10 Oct 2024 12:04:54 -0600 Subject: [PATCH 094/120] prefer const and fix bugs --- startos/actions/config.ts | 11 ++++++++++- startos/actions/nameToLogs.ts | 2 +- startos/actions/properties.ts | 6 ++++-- startos/init.ts | 2 +- startos/versions/v0.3.6.0.ts | 6 +++++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index a79a4a3..565abdb 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -30,10 +30,14 @@ export const config = sdk.Action.withInput( inputSpec, // optionally pre-fill the input form - ({ effects }) => yamlFile.read.once(), + ({ effects }) => yamlFile.read.const(effects), // the execution function async ({ effects, input }) => { + const yaml = await yamlFile.read.const(effects) + + if (yaml?.name === input.name) return + await Promise.all([ yamlFile.merge(input), sdk.store.setOwn( @@ -41,6 +45,11 @@ export const config = sdk.Action.withInput( sdk.StorePath.secretPhrase, getSecretPhrase(input.name), ), + sdk.store.setOwn( + effects, + sdk.StorePath.nameLastUpdatedAt, + new Date().toISOString(), + ), ]) }, ) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 100e033..1a8f1f3 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -23,7 +23,7 @@ export const nameToLogs = sdk.Action.withoutInput( // the execution function async ({ effects }) => { - const name = (await yamlFile.read.once())!.name + const name = (await yamlFile.read.const(effects))!.name console.info(`Hello ${name}`) diff --git a/startos/actions/properties.ts b/startos/actions/properties.ts index 0406189..60fe5ec 100644 --- a/startos/actions/properties.ts +++ b/startos/actions/properties.ts @@ -21,9 +21,11 @@ export const properties = sdk.Action.withoutInput( type: 'string', name: 'Secret Phrase', description: 'Use this phrase to gain access to extraordinary places', - value: await sdk.store.getOwn(effects, sdk.StorePath.secretPhrase).once(), + value: await sdk.store + .getOwn(effects, sdk.StorePath.secretPhrase) + .const(), copyable: true, - qr: false, + qr: true, masked: true, } }, diff --git a/startos/init.ts b/startos/init.ts index 3fe8b24..5939cda 100644 --- a/startos/init.ts +++ b/startos/init.ts @@ -11,7 +11,7 @@ import { yamlFile } from './file-models/config.yml' const install = sdk.setupInstall(async ({ effects }) => { const name = 'World' - await yamlFile.merge({ name }) + await yamlFile.write({ name }) await sdk.store.setOwn( effects, diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index c058ad6..bb35fbe 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,13 +1,17 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' import { sdk } from '../sdk' import { config } from '../actions/config' +import { yamlFile } from '../file-models/config.yml' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { up: async ({ effects }) => { - await sdk.action.requestOwn(effects, config, 'critical') + const yaml = (await yamlFile.read.const(effects))! + await sdk.action.requestOwn(effects, config, 'critical', { + input: { kind: 'partial', value: yaml }, + }) }, down: IMPOSSIBLE, }, From 368eebda8f758ad02c1a9209c5d8b555191e6a24 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Fri, 11 Oct 2024 13:50:38 -0600 Subject: [PATCH 095/120] fix circular import --- Makefile | 4 ++-- package-lock.json | 38 +++++++++++++++++++++-------------- package.json | 4 ++-- startos/actions/config.ts | 2 +- startos/actions/nameToLogs.ts | 2 +- startos/index.ts | 5 ++++- startos/manifest.ts | 3 ++- startos/versions/v0.3.6.0.ts | 7 ++----- tsconfig.json | 4 ++-- 9 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index b3def55..bd51a6c 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,10 @@ PACKAGE_ID := hello-world all: ${PACKAGE_ID}.s9pk # Build targets -${PACKAGE_ID}.s9pk: $(start-cli s9pk list-ingredients) +${PACKAGE_ID}.s9pk: $(shell start-cli s9pk list-ingredients) start-cli s9pk pack -javascript/index.js: $(shell git ls-files startos) node_modules package.json +javascript/index.js: $(shell git ls-files startos) tsconfig.json node_modules package.json npm run build node_modules: package.json package-lock.json diff --git a/package-lock.json b/package-lock.json index a0585e0..4b71cb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha8" + "@start9labs/start-sdk": "0.3.6-alpha.11" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,16 +43,17 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha8", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha8.tgz", - "integrity": "sha512-rbwPIvB2NHZoQBaBZQrfljAgUJKpGegnWgAgEBOpT0+1+PTliQ8x98IxYj7rBGyWL9DJkrRh5GlAxNe+I1YPdQ==", + "version": "0.3.6-alpha.11", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.11.tgz", + "integrity": "sha512-rQAj3Q5mOPWUbhzDyPpHRv1/sfvzcIPVEavzRX/fIgyrFrZaJiKhPPH6d0Mdu0FVzmLMgOoQajUGYcIlxEARYQ==", + "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", "@noble/curves": "^1.4.0", "@noble/hashes": "^1.4.0", "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", - "mime": "^4.0.3", + "mime-types": "^2.1.35", "ts-matches": "^5.5.1", "yaml": "^2.2.2" } @@ -89,18 +90,25 @@ "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" }, - "node_modules/mime": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.4.tgz", - "integrity": "sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==", - "funding": [ - "https://github.com/sponsors/broofa" - ], - "bin": { - "mime": "bin/cli.js" + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" }, "engines": { - "node": ">=16" + "node": ">= 0.6" } }, "node_modules/node-fetch": { diff --git a/package.json b/package.json index 9a4a091..67f2345 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "hello-world-startos", "scripts": { - "build": "ncc build startos/index.ts -o ./javascript", + "build": "rm -rf ./javascript && ncc build startos/index.ts -o ./javascript", "prettier": "prettier --write startos", "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha8" + "@start9labs/start-sdk": "0.3.6-alpha.11" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/actions/config.ts b/startos/actions/config.ts index 565abdb..ddef67a 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -30,7 +30,7 @@ export const config = sdk.Action.withInput( inputSpec, // optionally pre-fill the input form - ({ effects }) => yamlFile.read.const(effects), + ({ effects }) => yamlFile.read.once(), // the execution function async ({ effects, input }) => { diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 1a8f1f3..100e033 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -23,7 +23,7 @@ export const nameToLogs = sdk.Action.withoutInput( // the execution function async ({ effects }) => { - const name = (await yamlFile.read.const(effects))!.name + const name = (await yamlFile.read.once())!.name console.info(`Hello ${name}`) diff --git a/startos/index.ts b/startos/index.ts index 12c0e2c..8d32c10 100644 --- a/startos/index.ts +++ b/startos/index.ts @@ -5,4 +5,7 @@ export { createBackup, restoreBackup } from './backups' export { main } from './main' export { packageInit, packageUninit, containerInit } from './init' export { actions } from './actions' -export { manifest } from './manifest' +import { buildManifest } from '@start9labs/start-sdk' +import { manifest as sdkManifest } from './manifest' +import { versions } from './versions' +export const manifest = buildManifest(versions, sdkManifest) diff --git a/startos/manifest.ts b/startos/manifest.ts index 4f4dc66..916337a 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,7 +1,8 @@ import { setupManifest } from '@start9labs/start-sdk' import { versions } from './versions' +import { SDKManifest } from '@start9labs/start-sdk/base/lib/types' -export const manifest = setupManifest(versions, { +export const manifest = setupManifest({ id: 'hello-world', title: 'Hello World', license: 'mit', diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index bb35fbe..c0a45c8 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,17 +1,14 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' import { sdk } from '../sdk' import { config } from '../actions/config' -import { yamlFile } from '../file-models/config.yml' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { up: async ({ effects }) => { - const yaml = (await yamlFile.read.const(effects))! - await sdk.action.requestOwn(effects, config, 'critical', { - input: { kind: 'partial', value: yaml }, - }) + // require the user to run the "config" action + await sdk.action.requestOwn(effects, config, 'critical') }, down: IMPOSSIBLE, }, diff --git a/tsconfig.json b/tsconfig.json index bc099e0..9ee887c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,8 @@ { "include": ["startos/**/*.ts", "startos/versions/v0.3.6.0.ts"], "compilerOptions": { - "target": "es2022", - "module": "None", + "target": "ES2018", + "module": "CommonJS", "moduleResolution": "node", "esModuleInterop": true, "strict": true, From bf9f993869ccf4a62de8ef37fb6b12f82b7a06c9 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 11 Oct 2024 15:11:34 -0600 Subject: [PATCH 096/120] not much --- startos/actions/config.ts | 3 ++- startos/versions/v0.3.6.0.ts | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/startos/actions/config.ts b/startos/actions/config.ts index ddef67a..82ab5f1 100644 --- a/startos/actions/config.ts +++ b/startos/actions/config.ts @@ -1,8 +1,9 @@ import { sdk } from '../sdk' -const { InputSpec, Value } = sdk import { yamlFile } from '../file-models/config.yml' import { getSecretPhrase } from '../utils' +const { InputSpec, Value } = sdk + export const inputSpec = InputSpec.of({ name: Value.text({ name: 'Name', diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index c0a45c8..c058ad6 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -7,7 +7,6 @@ export const v0360 = VersionInfo.of({ releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { up: async ({ effects }) => { - // require the user to run the "config" action await sdk.action.requestOwn(effects, config, 'critical') }, down: IMPOSSIBLE, From 3902ac6cbb82cda79a31dd2ddd760eba972e5bfa Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 16 Oct 2024 15:09:35 -0600 Subject: [PATCH 097/120] misc fixes --- startos/actions/nameToLogs.ts | 2 +- startos/file-models/config.yml.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 100e033..32173ef 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -3,7 +3,7 @@ import { yamlFile } from '../file-models/config.yml' export const nameToLogs = sdk.Action.withoutInput( // id - 'nameToLogs', + 'name-to-logs', // metadata async ({ effects }) => ({ diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index 7b73848..017d3cc 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -5,4 +5,7 @@ const shape = object({ name: string, }) -export const yamlFile = FileHelper.yaml('./config.yml', shape) +export const yamlFile = FileHelper.yaml( + '/media/startos/volumes/main/config.yml', + shape, +) From e2bde860a5327bb72236019e67fc31d037304dc7 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Wed, 16 Oct 2024 16:52:29 -0600 Subject: [PATCH 098/120] alpha.12 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4b71cb9..f1e6083 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.11" + "@start9labs/start-sdk": "0.3.6-alpha.12" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.11", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.11.tgz", - "integrity": "sha512-rQAj3Q5mOPWUbhzDyPpHRv1/sfvzcIPVEavzRX/fIgyrFrZaJiKhPPH6d0Mdu0FVzmLMgOoQajUGYcIlxEARYQ==", + "version": "0.3.6-alpha.12", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.12.tgz", + "integrity": "sha512-Ue469KIIDHUQVV5DUGYCOzkINAN+pSqPwoVy0Nc0qnDxWIiFU5+LahZnz5iSRBnAiqfNyJutGZlGKKL5jTAYcQ==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 67f2345..7b79c67 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.11" + "@start9labs/start-sdk": "0.3.6-alpha.12" }, "devDependencies": { "@types/node": "^22.1.0", From 798ed2011da5ccbd8a7e3aa1fd1a2212856653fa Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 16 Oct 2024 19:42:15 -0600 Subject: [PATCH 099/120] better action names --- startos/actions/index.ts | 8 ++++---- startos/actions/nameToLogs.ts | 2 +- startos/actions/{config.ts => setName.ts} | 8 ++++---- startos/actions/{properties.ts => showSecretPhrase.ts} | 8 ++++---- startos/versions/v0.3.6.0.ts | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) rename startos/actions/{config.ts => setName.ts} (88%) rename startos/actions/{properties.ts => showSecretPhrase.ts} (76%) diff --git a/startos/actions/index.ts b/startos/actions/index.ts index 40acbc9..1866c78 100644 --- a/startos/actions/index.ts +++ b/startos/actions/index.ts @@ -1,9 +1,9 @@ -import { properties } from './properties' import { sdk } from '../sdk' -import { config } from './config' +import { showSecretPhrase } from './showSecretPhrase' +import { setName } from './setName' import { nameToLogs } from './nameToLogs' export const actions = sdk.Actions.of() - .addAction(config) - .addAction(properties) + .addAction(setName) + .addAction(showSecretPhrase) .addAction(nameToLogs) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 32173ef..325aa3c 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -7,7 +7,7 @@ export const nameToLogs = sdk.Action.withoutInput( // metadata async ({ effects }) => ({ - name: 'Name to Logs', + name: 'Print name to Logs', description: 'Prints "Hello [Name]" to the service logs.', warning: null, allowedStatuses: 'only-running', diff --git a/startos/actions/config.ts b/startos/actions/setName.ts similarity index 88% rename from startos/actions/config.ts rename to startos/actions/setName.ts index 82ab5f1..b3411a5 100644 --- a/startos/actions/config.ts +++ b/startos/actions/setName.ts @@ -13,14 +13,14 @@ export const inputSpec = InputSpec.of({ }), }) -export const config = sdk.Action.withInput( +export const setName = sdk.Action.withInput( // id - 'config', + 'set-name', // metadata async ({ effects }) => ({ - name: 'Configure', - description: 'edit the underlying config.yaml of Hello World', + name: 'Set Name', + description: 'Set you name so hello world can say hello to you', warning: null, allowedStatuses: 'any', group: null, diff --git a/startos/actions/properties.ts b/startos/actions/showSecretPhrase.ts similarity index 76% rename from startos/actions/properties.ts rename to startos/actions/showSecretPhrase.ts index 60fe5ec..24f4b6f 100644 --- a/startos/actions/properties.ts +++ b/startos/actions/showSecretPhrase.ts @@ -1,13 +1,13 @@ import { sdk } from '../sdk' -export const properties = sdk.Action.withoutInput( +export const showSecretPhrase = sdk.Action.withoutInput( // id - 'properties', + 'show-secret-phrase', // metadata async ({ effects }) => ({ - name: 'Properties', - description: 'Useful information about Hello World', + name: 'Show Secret Phrase', + description: 'Reveal the secret phrase for Hello World', warning: null, allowedStatuses: 'any', group: null, diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index c058ad6..ba7cec5 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,6 +1,6 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' import { sdk } from '../sdk' -import { config } from '../actions/config' +import { config } from '../actions/setName' export const v0360 = VersionInfo.of({ version: '0.3.6:0', From 23b592f85043d6e238aea5a1ace7307aba4e5eca Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 17 Oct 2024 09:22:23 -0600 Subject: [PATCH 100/120] fix bug --- README.md | 5 +++++ startos/versions/v0.3.6.0.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9aca7e..00776b2 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,9 @@ A bare bones project serving as a template for [StartOS Service Packaging](https ## Building from source +`npm i` +`make` + +## Creating your own project + Follow the [Quick Start Guide](https://docs.star9.com/packaging-guide/quick-start/) for StartOS service packaging, replacing references to `hello-world-startos` with this service ID. diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index ba7cec5..ed8ffc7 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -1,13 +1,13 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' import { sdk } from '../sdk' -import { config } from '../actions/setName' +import { setName } from '../actions/setName' export const v0360 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { up: async ({ effects }) => { - await sdk.action.requestOwn(effects, config, 'critical') + await sdk.action.requestOwn(effects, setName, 'critical') }, down: IMPOSSIBLE, }, From 8185793ae28c91016b019b7fdf19bbad0606e0ab Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 17 Oct 2024 20:53:49 -0600 Subject: [PATCH 101/120] cleaning up after webinar --- startos/actions/nameToLogs.ts | 14 +------------- startos/actions/setName.ts | 4 ++-- startos/backups.ts | 4 ++-- startos/interfaces.ts | 3 ++- startos/main.ts | 3 ++- startos/manifest.ts | 2 -- startos/utils.ts | 2 ++ 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 325aa3c..3aea5ba 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -23,19 +23,7 @@ export const nameToLogs = sdk.Action.withoutInput( // the execution function async ({ effects }) => { - const name = (await yamlFile.read.once())!.name - + const name = (await yamlFile.read.const(effects))!.name console.info(`Hello ${name}`) - - return { - version: '1', - type: 'string', - name: 'Log Successful', - description: `"Hello ${name}" has been written to the service logs. Open your logs to view it.`, - value: name, - masked: false, - copyable: false, - qr: false, - } }, ) diff --git a/startos/actions/setName.ts b/startos/actions/setName.ts index b3411a5..cb94cf8 100644 --- a/startos/actions/setName.ts +++ b/startos/actions/setName.ts @@ -20,7 +20,7 @@ export const setName = sdk.Action.withInput( // metadata async ({ effects }) => ({ name: 'Set Name', - description: 'Set you name so hello world can say hello to you', + description: 'Set your name so Hello World can say hello to you', warning: null, allowedStatuses: 'any', group: null, @@ -31,7 +31,7 @@ export const setName = sdk.Action.withInput( inputSpec, // optionally pre-fill the input form - ({ effects }) => yamlFile.read.once(), + ({ effects }) => yamlFile.read.const(effects), // the execution function async ({ effects, input }) => { diff --git a/startos/backups.ts b/startos/backups.ts index dd75053..6ccffb6 100644 --- a/startos/backups.ts +++ b/startos/backups.ts @@ -1,5 +1,5 @@ import { sdk } from './sdk' -export const { createBackup, restoreBackup } = sdk.setupBackups(async () => - sdk.Backups.volumes('main'), +export const { createBackup, restoreBackup } = sdk.setupBackups( + async ({ effects }) => sdk.Backups.volumes('main'), ) diff --git a/startos/interfaces.ts b/startos/interfaces.ts index fe751a8..4786c30 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -1,8 +1,9 @@ import { sdk } from './sdk' +import { uiPort } from './utils' export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => { const uiMulti = sdk.host.multi(effects, 'ui-multi') - const uiMultiOrigin = await uiMulti.bindPort(80, { + const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http', }) const ui = sdk.createInterface(effects, { diff --git a/startos/main.ts b/startos/main.ts index 179abf0..fc4b58e 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -1,5 +1,6 @@ import { sdk } from './sdk' import { T } from '@start9labs/start-sdk' +import { uiPort } from './utils' export const main = sdk.setupMain(async ({ effects, started }) => { /** @@ -35,7 +36,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. // A function below determines the health status of this daemon fn: () => - sdk.healthCheck.checkPortListening(effects, 80, { + sdk.healthCheck.checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), diff --git a/startos/manifest.ts b/startos/manifest.ts index 916337a..28d449d 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -1,6 +1,4 @@ import { setupManifest } from '@start9labs/start-sdk' -import { versions } from './versions' -import { SDKManifest } from '@start9labs/start-sdk/base/lib/types' export const manifest = setupManifest({ id: 'hello-world', diff --git a/startos/utils.ts b/startos/utils.ts index 814d7cf..497edac 100644 --- a/startos/utils.ts +++ b/startos/utils.ts @@ -4,3 +4,5 @@ export function getSecretPhrase(name: string): string { return `Knock knock. Who's there? ${name}!` } + +export const uiPort = 80 From 9eb2eeb31891c03b3aa63ea6d7bbcb5ac245da80 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 22 Oct 2024 13:50:35 -0600 Subject: [PATCH 102/120] update action for new response type --- startos/actions/nameToLogs.ts | 7 +++++++ startos/actions/showSecretPhrase.ts | 17 +++++++++-------- startos/main.ts | 6 +----- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/startos/actions/nameToLogs.ts b/startos/actions/nameToLogs.ts index 3aea5ba..bfe74a6 100644 --- a/startos/actions/nameToLogs.ts +++ b/startos/actions/nameToLogs.ts @@ -25,5 +25,12 @@ export const nameToLogs = sdk.Action.withoutInput( async ({ effects }) => { const name = (await yamlFile.read.const(effects))!.name console.info(`Hello ${name}`) + + return { + version: '1', + title: 'Success', + message: `"Hello ${name}" has been logged. Open the Hello World service logs to view it.`, + result: null, + } }, ) diff --git a/startos/actions/showSecretPhrase.ts b/startos/actions/showSecretPhrase.ts index 24f4b6f..092eb66 100644 --- a/startos/actions/showSecretPhrase.ts +++ b/startos/actions/showSecretPhrase.ts @@ -15,18 +15,19 @@ export const showSecretPhrase = sdk.Action.withoutInput( }), // the execution function - async ({ effects }) => { - return { - version: '1', - type: 'string', - name: 'Secret Phrase', - description: 'Use this phrase to gain access to extraordinary places', + async ({ effects }) => ({ + version: '1', + title: 'Secret Phrase', + message: + 'Below is your secret phrase. Use it to gain access to extraordinary places', + result: { + type: 'single', value: await sdk.store .getOwn(effects, sdk.StorePath.secretPhrase) .const(), copyable: true, qr: true, masked: true, - } - }, + }, + }), ) diff --git a/startos/main.ts b/startos/main.ts index fc4b58e..4f03e34 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -24,11 +24,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * * Each daemon defines its own health check, which can optionally be exposed to the user. */ - return sdk.Daemons.of({ - effects, - started, - healthReceipts, - }).addDaemon('primary', { + return sdk.Daemons.of(effects, started, healthReceipts).addDaemon('primary', { image: { id: 'main' }, // Must match an Image ID declared in the manifest. command: ['hello-world'], // The command to start the daemon. mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), // Mount necessary volumes. ID must match manifest declaration. From 8d75dc02e5d290ab26304370d984e8fb16e5651c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 31 Oct 2024 12:48:34 -0600 Subject: [PATCH 103/120] bump sdk --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f1e6083..71bf98f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.12" + "@start9labs/start-sdk": "0.3.6-alpha.13" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.12", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.12.tgz", - "integrity": "sha512-Ue469KIIDHUQVV5DUGYCOzkINAN+pSqPwoVy0Nc0qnDxWIiFU5+LahZnz5iSRBnAiqfNyJutGZlGKKL5jTAYcQ==", + "version": "0.3.6-alpha.13", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.13.tgz", + "integrity": "sha512-uM4g+ZUFHmkXYHhQ3fnYSo727gGbYuGJcKqBPu7wyMhpn/TCpCakIKdgq3h3cL1GwWpQCagBH4/qNX74fxEnDg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 7b79c67..e3aafcb 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.12" + "@start9labs/start-sdk": "0.3.6-alpha.13" }, "devDependencies": { "@types/node": "^22.1.0", From 8551fe7a5c8678b3dc3421038c390817df1c9338 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 13 Nov 2024 09:54:52 -0700 Subject: [PATCH 104/120] alpha 14 --- package-lock.json | 8 ++++---- package.json | 2 +- startos/actions/setName.ts | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 71bf98f..9e97922 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.13" + "@start9labs/start-sdk": "0.3.6-alpha.14" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.13", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.13.tgz", - "integrity": "sha512-uM4g+ZUFHmkXYHhQ3fnYSo727gGbYuGJcKqBPu7wyMhpn/TCpCakIKdgq3h3cL1GwWpQCagBH4/qNX74fxEnDg==", + "version": "0.3.6-alpha.14", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.14.tgz", + "integrity": "sha512-ibXcU2strfjow7aG3YWpChq37Cq1hnUN/dwbJ6F94h5e/wTLEiousJMNWqEeqTm/y8jCC22+nAuQKeAgW1wv+g==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index e3aafcb..fcca3e9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.13" + "@start9labs/start-sdk": "0.3.6-alpha.14" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/actions/setName.ts b/startos/actions/setName.ts index cb94cf8..5fb74fb 100644 --- a/startos/actions/setName.ts +++ b/startos/actions/setName.ts @@ -9,7 +9,8 @@ export const inputSpec = InputSpec.of({ name: 'Name', description: 'When you launch the Hello World UI, it will display "Hello [Name]"', - required: { default: 'World' }, + required: true, + default: 'World', }), }) From b7b19b6ad14d6b0ef9e0c65d9b03c8df250d53a7 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 14 Nov 2024 14:21:33 -0700 Subject: [PATCH 105/120] alpha 16 --- package-lock.json | 17 +++++++++-------- package.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9e97922..ae17dbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.14" + "@start9labs/start-sdk": "0.3.6-alpha.16" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.14", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.14.tgz", - "integrity": "sha512-ibXcU2strfjow7aG3YWpChq37Cq1hnUN/dwbJ6F94h5e/wTLEiousJMNWqEeqTm/y8jCC22+nAuQKeAgW1wv+g==", + "version": "0.3.6-alpha.16", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.16.tgz", + "integrity": "sha512-hrHjlSH/aIZNYmYPjv0kfZDxw1oNS8sdzr7CrhoOx/5t/3wPowZ321lmE/PEIYfMe5AMhN4Msj/MF4o9XmZLeA==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^5.5.1", + "ts-matches": "^5.6.1", "yaml": "^2.2.2" } }, @@ -151,9 +151,10 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-matches": { - "version": "5.5.1", - "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.5.1.tgz", - "integrity": "sha512-UFYaKgfqlg9FROK7bdpYqFwG1CJvP4kOJdjXuWoqxo9jCmANoDw1GxkSCpJgoTeIiSTaTH5Qr1klSspb8c+ydg==" + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.6.1.tgz", + "integrity": "sha512-1QXWQUa14MCgbz7vMg7i7eVPhMKB/5w8808nkN2sfnDkbG9nWYr9IwuTxX+h99yyawHYS53DewShA2RYCbSW4Q==", + "license": "MIT" }, "node_modules/typescript": { "version": "5.4.5", diff --git a/package.json b/package.json index fcca3e9..45de58a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.14" + "@start9labs/start-sdk": "0.3.6-alpha.16" }, "devDependencies": { "@types/node": "^22.1.0", From 44b4c39a46c2d01308e147f36893cdef0be14086 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Nov 2024 12:57:37 -0700 Subject: [PATCH 106/120] alpha 18 --- package-lock.json | 16 ++++++++-------- package.json | 2 +- startos/file-models/config.yml.ts | 2 +- startos/main.ts | 2 +- startos/manifest.ts | 2 +- startos/store.ts | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae17dbd..6a5be88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.16" + "@start9labs/start-sdk": "0.3.6-alpha.17" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.16", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.16.tgz", - "integrity": "sha512-hrHjlSH/aIZNYmYPjv0kfZDxw1oNS8sdzr7CrhoOx/5t/3wPowZ321lmE/PEIYfMe5AMhN4Msj/MF4o9XmZLeA==", + "version": "0.3.6-alpha.17", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.17.tgz", + "integrity": "sha512-x/Ac+fY/uSiifZiHd/kw562B6GMtaRFWvrjSJJ9IouuVIoHj8qjOfJ4IPG0SnI0zXuV4Brwm3yG4kmpDwC7KVg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^5.6.1", + "ts-matches": "^6.0.0", "yaml": "^2.2.2" } }, @@ -151,9 +151,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-matches": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-5.6.1.tgz", - "integrity": "sha512-1QXWQUa14MCgbz7vMg7i7eVPhMKB/5w8808nkN2sfnDkbG9nWYr9IwuTxX+h99yyawHYS53DewShA2RYCbSW4Q==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.0.0.tgz", + "integrity": "sha512-vR4hhz9bYMW30qIJUuLaeAWlsR54vse6ZI2riVhVLMBE6/vss43jwrOvbHheiyU7e26ssT/yWx69aJHD2REJSA==", "license": "MIT" }, "node_modules/typescript": { diff --git a/package.json b/package.json index 45de58a..bc6965f 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.16" + "@start9labs/start-sdk": "0.3.6-alpha.17" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/file-models/config.yml.ts b/startos/file-models/config.yml.ts index 017d3cc..44d8da4 100644 --- a/startos/file-models/config.yml.ts +++ b/startos/file-models/config.yml.ts @@ -2,7 +2,7 @@ import { matches, FileHelper } from '@start9labs/start-sdk' const { object, string } = matches const shape = object({ - name: string, + name: string.optional().onMismatch(undefined), }) export const yamlFile = FileHelper.yaml( diff --git a/startos/main.ts b/startos/main.ts index 4f03e34..13c5a41 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -25,7 +25,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * Each daemon defines its own health check, which can optionally be exposed to the user. */ return sdk.Daemons.of(effects, started, healthReceipts).addDaemon('primary', { - image: { id: 'main' }, // Must match an Image ID declared in the manifest. + image: { id: 'hello-world' }, // Must match an Image ID declared in the manifest. command: ['hello-world'], // The command to start the daemon. mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), // Mount necessary volumes. ID must match manifest declaration. ready: { diff --git a/startos/manifest.ts b/startos/manifest.ts index 28d449d..5aa1a0e 100644 --- a/startos/manifest.ts +++ b/startos/manifest.ts @@ -16,7 +16,7 @@ export const manifest = setupManifest({ assets: [], volumes: ['main'], images: { - main: { + 'hello-world': { source: { dockerTag: 'start9/hello-world', }, diff --git a/startos/store.ts b/startos/store.ts index f1d3f2f..7f7b4e4 100644 --- a/startos/store.ts +++ b/startos/store.ts @@ -22,7 +22,7 @@ import { setupExposeStore } from '@start9labs/start-sdk' */ export type Store = { secretPhrase: string - nameLastUpdatedAt: string + nameLastUpdatedAt: string | null } export const exposedStore = setupExposeStore((pathBuilder) => [ From dc420cb02a536379468cb804d0121b467bcf705a Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Nov 2024 14:03:11 -0700 Subject: [PATCH 107/120] alpha 18 --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6a5be88..f7e4b1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.17" + "@start9labs/start-sdk": "0.3.6-alpha.18" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.17", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.17.tgz", - "integrity": "sha512-x/Ac+fY/uSiifZiHd/kw562B6GMtaRFWvrjSJJ9IouuVIoHj8qjOfJ4IPG0SnI0zXuV4Brwm3yG4kmpDwC7KVg==", + "version": "0.3.6-alpha.18", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.18.tgz", + "integrity": "sha512-oJp2+s5QyLjJl+ojf+jSujnqox4ITR28JZ7QDHpS6SkmfqbTRkYtx8fFz5h6GL9eZPRoHOwD+RONxxNNs5V7NQ==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^6.0.0", + "ts-matches": "^6.1.0", "yaml": "^2.2.2" } }, @@ -151,9 +151,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-matches": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.0.0.tgz", - "integrity": "sha512-vR4hhz9bYMW30qIJUuLaeAWlsR54vse6ZI2riVhVLMBE6/vss43jwrOvbHheiyU7e26ssT/yWx69aJHD2REJSA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.1.0.tgz", + "integrity": "sha512-01qvbIpOiKdbzzXDH84JeHunvCwBGFdZw94jS6kOGLSN5ms+1nBZtfe8WSuYMIPb1xPA+qyAiVgznFi2VCQ6UQ==", "license": "MIT" }, "node_modules/typescript": { diff --git a/package.json b/package.json index bc6965f..96679d8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.17" + "@start9labs/start-sdk": "0.3.6-alpha.18" }, "devDependencies": { "@types/node": "^22.1.0", From f23d9c19edc70ec7bc50c471008f622008383e3b Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Nov 2024 15:31:59 -0700 Subject: [PATCH 108/120] include dependency startos dirs --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 9ee887c..a2945a5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["startos/**/*.ts", "startos/versions/v0.3.6.0.ts"], + "include": ["startos/**/*.ts", "node_modules/**/startos"], "compilerOptions": { "target": "ES2018", "module": "CommonJS", From 2364040041597332baf7d8b7d8f52600b5541a9f Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 20 Nov 2024 19:56:22 -0700 Subject: [PATCH 109/120] alpha 20 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f7e4b1a..fb42d39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.18" + "@start9labs/start-sdk": "0.3.6-alpha.20" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.18", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.18.tgz", - "integrity": "sha512-oJp2+s5QyLjJl+ojf+jSujnqox4ITR28JZ7QDHpS6SkmfqbTRkYtx8fFz5h6GL9eZPRoHOwD+RONxxNNs5V7NQ==", + "version": "0.3.6-alpha.20", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.20.tgz", + "integrity": "sha512-PW6qenmR0KjbwOWAOholIIwH8T89MuP5wL7UddnnrRppbYVI6HgnLQ2U/P48+Den8FLrWLy+Ih+HfavFE3Doog==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 96679d8..b2e1387 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.18" + "@start9labs/start-sdk": "0.3.6-alpha.20" }, "devDependencies": { "@types/node": "^22.1.0", From 12952f8d3b289831922306ec8091a8df0686ca1c Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 21 Nov 2024 10:55:37 -0700 Subject: [PATCH 110/120] alpha 21 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb42d39..da792c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.20" + "@start9labs/start-sdk": "0.3.6-alpha.21" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.20", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.20.tgz", - "integrity": "sha512-PW6qenmR0KjbwOWAOholIIwH8T89MuP5wL7UddnnrRppbYVI6HgnLQ2U/P48+Den8FLrWLy+Ih+HfavFE3Doog==", + "version": "0.3.6-alpha.21", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.21.tgz", + "integrity": "sha512-/zmd+bpS/SNHKMs438QOV2iTxCA0BnCGBVFwx99t/54OSFdBf3vOY0WKvmIvMjDwXvnRoanyqsHMtjuaOVE9fA==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index b2e1387..543508b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.20" + "@start9labs/start-sdk": "0.3.6-alpha.21" }, "devDependencies": { "@types/node": "^22.1.0", From 0d1d1a649da2f237daeeda4d1f8593ca1168bf0a Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 22 Nov 2024 09:37:26 -0700 Subject: [PATCH 111/120] alpha 22 --- package-lock.json | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index da792c4..231d03a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.21" + "@start9labs/start-sdk": "0.3.6-alpha.22" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.21", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.21.tgz", - "integrity": "sha512-/zmd+bpS/SNHKMs438QOV2iTxCA0BnCGBVFwx99t/54OSFdBf3vOY0WKvmIvMjDwXvnRoanyqsHMtjuaOVE9fA==", + "version": "0.3.6-alpha.22", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.22.tgz", + "integrity": "sha512-TmzHolOU6Uh/T5yBffh5j+h2gFKu/HEB6FBpxoYJ9je8+uXGfJ0rOwa0nFzKAcNhqpi7rgfn/gqor8+QCkZS4w==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^6.1.0", + "ts-matches": "^6.2.1", "yaml": "^2.2.2" } }, @@ -151,9 +151,9 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, "node_modules/ts-matches": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.1.0.tgz", - "integrity": "sha512-01qvbIpOiKdbzzXDH84JeHunvCwBGFdZw94jS6kOGLSN5ms+1nBZtfe8WSuYMIPb1xPA+qyAiVgznFi2VCQ6UQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ts-matches/-/ts-matches-6.2.1.tgz", + "integrity": "sha512-qdnMgTHsGCEGGK6QiaNMY2vD9eQtRp2Q+pAxcOAzxHJKDKTBYsc1ISTg1zp8H2+EmtCB0eko/1TwYUA5/mUGug==", "license": "MIT" }, "node_modules/typescript": { diff --git a/package.json b/package.json index 543508b..dac157a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.21" + "@start9labs/start-sdk": "0.3.6-alpha.22" }, "devDependencies": { "@types/node": "^22.1.0", From cb2087a53edf7821e2254fde67fcf48999d1adb4 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 3 Dec 2024 14:36:17 -0700 Subject: [PATCH 112/120] alpha 23 --- package-lock.json | 8 ++++---- package.json | 2 +- startos/actions/setName.ts | 2 +- startos/main.ts | 11 +++++------ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 231d03a..a21a761 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.22" + "@start9labs/start-sdk": "0.3.6-alpha.23" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.22", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.22.tgz", - "integrity": "sha512-TmzHolOU6Uh/T5yBffh5j+h2gFKu/HEB6FBpxoYJ9je8+uXGfJ0rOwa0nFzKAcNhqpi7rgfn/gqor8+QCkZS4w==", + "version": "0.3.6-alpha.23", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.23.tgz", + "integrity": "sha512-b86Bn/+orwxyuWy+sor+n0uHAmuSByw8xfSZ+dEXZ9lxn5+340dXU7RNjkPsvZULHVlgYaugYWdeS/NU3q+eag==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index dac157a..10f38ba 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.22" + "@start9labs/start-sdk": "0.3.6-alpha.23" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/actions/setName.ts b/startos/actions/setName.ts index 5fb74fb..a7b7aba 100644 --- a/startos/actions/setName.ts +++ b/startos/actions/setName.ts @@ -32,7 +32,7 @@ export const setName = sdk.Action.withInput( inputSpec, // optionally pre-fill the input form - ({ effects }) => yamlFile.read.const(effects), + async ({ effects }) => yamlFile.read.const(effects), // the execution function async ({ effects, input }) => { diff --git a/startos/main.ts b/startos/main.ts index 13c5a41..c24f25a 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -25,18 +25,17 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * Each daemon defines its own health check, which can optionally be exposed to the user. */ return sdk.Daemons.of(effects, started, healthReceipts).addDaemon('primary', { - image: { id: 'hello-world' }, // Must match an Image ID declared in the manifest. - command: ['hello-world'], // The command to start the daemon. - mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), // Mount necessary volumes. ID must match manifest declaration. + image: { id: 'hello-world' }, + command: ['hello-world'], + mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { - display: 'Web Interface', // If null, the health check will NOT be displayed to the user. If provided, this string will be the name of the health check and displayed to the user. - // A function below determines the health status of this daemon + display: 'Web Interface', fn: () => sdk.healthCheck.checkPortListening(effects, uiPort, { successMessage: 'The web interface is ready', errorMessage: 'The web interface is not ready', }), }, - requires: [], // If this daemon depends on the successful initialization of one or more prior daemons, enter their IDs here. + requires: [], }) }) From ad5bf7b604c207a2e51c96cc6dc55653d4b9ca46 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 5 Dec 2024 11:42:35 -0700 Subject: [PATCH 113/120] beta 0 --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index a21a761..da8844c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.23" + "@start9labs/start-sdk": "0.3.6-beta.0" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-alpha.23", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-alpha.23.tgz", - "integrity": "sha512-b86Bn/+orwxyuWy+sor+n0uHAmuSByw8xfSZ+dEXZ9lxn5+340dXU7RNjkPsvZULHVlgYaugYWdeS/NU3q+eag==", + "version": "0.3.6-beta.0", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.0.tgz", + "integrity": "sha512-llAxxwxOgMTs2umBUk8oFZPVjUFybRD3qguOO+lr4ZtaCXUDZh+C737dza8WetyN7Eu6qp52kWpKpshvWOrKtw==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^6.2.1", + "ts-matches": "^6.1.0", "yaml": "^2.2.2" } }, diff --git a/package.json b/package.json index 10f38ba..49986c3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-alpha.23" + "@start9labs/start-sdk": "0.3.6-beta.0" }, "devDependencies": { "@types/node": "^22.1.0", From 7584825290e1ada9b20a33f9cb7ad4ec48587339 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 6 Dec 2024 11:41:04 -0700 Subject: [PATCH 114/120] beta 1 --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index da8844c..1b028d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.0" + "@start9labs/start-sdk": "0.3.6-beta.1" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-beta.0", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.0.tgz", - "integrity": "sha512-llAxxwxOgMTs2umBUk8oFZPVjUFybRD3qguOO+lr4ZtaCXUDZh+C737dza8WetyN7Eu6qp52kWpKpshvWOrKtw==", + "version": "0.3.6-beta.1", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.1.tgz", + "integrity": "sha512-zI9MciXhmlN4n6Z4XoScfRy4WD21k8SzgrPu1x1j4m1Vk6na97wigU7dAcgXAOEhuNkaabgHL/IAnTbQn+G75w==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", @@ -54,7 +54,7 @@ "isomorphic-fetch": "^3.0.0", "lodash.merge": "^4.6.2", "mime-types": "^2.1.35", - "ts-matches": "^6.1.0", + "ts-matches": "^6.2.1", "yaml": "^2.2.2" } }, diff --git a/package.json b/package.json index 49986c3..98d1f52 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.0" + "@start9labs/start-sdk": "0.3.6-beta.1" }, "devDependencies": { "@types/node": "^22.1.0", From 42a5edc51f1d304becd210dcf54693708c9a1f4d Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Fri, 10 Jan 2025 10:52:20 -0700 Subject: [PATCH 115/120] beta 3 --- README.md | 1 - package-lock.json | 8 ++++---- package.json | 2 +- startos/main.ts | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 00776b2..da01557 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ A bare bones project serving as a template for [StartOS Service Packaging](https ## Building from source -`npm i` `make` ## Creating your own project diff --git a/package-lock.json b/package-lock.json index 1b028d3..ef2dddb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.1" + "@start9labs/start-sdk": "0.3.6-beta.3" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-beta.1", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.1.tgz", - "integrity": "sha512-zI9MciXhmlN4n6Z4XoScfRy4WD21k8SzgrPu1x1j4m1Vk6na97wigU7dAcgXAOEhuNkaabgHL/IAnTbQn+G75w==", + "version": "0.3.6-beta.3", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.3.tgz", + "integrity": "sha512-362OC7XBwpIGz5vqwhkC2n0azia+cOSMoRBv9W+Sm/aEWgHCAm7+Jms2CmiVm77lZyk7bF1gbsQD3GZYR2va/Q==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 98d1f52..ee13a6b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.1" + "@start9labs/start-sdk": "0.3.6-beta.3" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/main.ts b/startos/main.ts index c24f25a..4df0b01 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -25,7 +25,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * Each daemon defines its own health check, which can optionally be exposed to the user. */ return sdk.Daemons.of(effects, started, healthReceipts).addDaemon('primary', { - image: { id: 'hello-world' }, + subcontainer: { id: 'hello-world' }, command: ['hello-world'], mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { From 213b81484d431f1c7e5d0eac517c6a46506ee407 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 14 Jan 2025 11:14:00 -0700 Subject: [PATCH 116/120] remove hasPrimary --- startos/interfaces.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/startos/interfaces.ts b/startos/interfaces.ts index 4786c30..e36f878 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -11,7 +11,6 @@ export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => { id: 'ui', description: 'The web interface of Hello World', type: 'ui', - hasPrimary: false, masked: false, schemeOverride: null, username: null, From 97bd511194a57131c48b4b17c06b30262e682b8e Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Tue, 28 Jan 2025 12:46:06 -0700 Subject: [PATCH 117/120] update to beta4 --- package-lock.json | 8 ++++---- package.json | 2 +- startos/interfaces.ts | 2 +- startos/main.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef2dddb..287d843 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.3" + "@start9labs/start-sdk": "0.3.6-beta.4" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-beta.3", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.3.tgz", - "integrity": "sha512-362OC7XBwpIGz5vqwhkC2n0azia+cOSMoRBv9W+Sm/aEWgHCAm7+Jms2CmiVm77lZyk7bF1gbsQD3GZYR2va/Q==", + "version": "0.3.6-beta.4", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.4.tgz", + "integrity": "sha512-q4YERQFaGJsrZfJXFHzr2aGTAFzQno41/m7Eq7r77T/YLVfc+sFhpZapB25lOlwNUxEH60DYKJmkhV/OaaoGjg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index ee13a6b..954e31c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.3" + "@start9labs/start-sdk": "0.3.6-beta.4" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/interfaces.ts b/startos/interfaces.ts index e36f878..6e88797 100644 --- a/startos/interfaces.ts +++ b/startos/interfaces.ts @@ -2,7 +2,7 @@ import { sdk } from './sdk' import { uiPort } from './utils' export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => { - const uiMulti = sdk.host.multi(effects, 'ui-multi') + const uiMulti = sdk.MultiHost.of(effects, 'ui-multi') const uiMultiOrigin = await uiMulti.bindPort(uiPort, { protocol: 'http', }) diff --git a/startos/main.ts b/startos/main.ts index 4df0b01..cd8969c 100644 --- a/startos/main.ts +++ b/startos/main.ts @@ -25,7 +25,7 @@ export const main = sdk.setupMain(async ({ effects, started }) => { * Each daemon defines its own health check, which can optionally be exposed to the user. */ return sdk.Daemons.of(effects, started, healthReceipts).addDaemon('primary', { - subcontainer: { id: 'hello-world' }, + subcontainer: { imageId: 'hello-world' }, command: ['hello-world'], mounts: sdk.Mounts.of().addVolume('main', null, '/data', false), ready: { From ead4855654dc264878c1e9984bf8691c97310b36 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 18 Feb 2025 09:40:31 -0700 Subject: [PATCH 118/120] beta 9 --- package-lock.json | 8 ++++---- package.json | 2 +- startos/versions/index.ts | 4 ++-- startos/versions/v0.3.6.0.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 287d843..daec4f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "hello-world-startos", "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.4" + "@start9labs/start-sdk": "0.3.6-beta.9" }, "devDependencies": { "@types/node": "^22.1.0", @@ -43,9 +43,9 @@ } }, "node_modules/@start9labs/start-sdk": { - "version": "0.3.6-beta.4", - "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.4.tgz", - "integrity": "sha512-q4YERQFaGJsrZfJXFHzr2aGTAFzQno41/m7Eq7r77T/YLVfc+sFhpZapB25lOlwNUxEH60DYKJmkhV/OaaoGjg==", + "version": "0.3.6-beta.9", + "resolved": "https://registry.npmjs.org/@start9labs/start-sdk/-/start-sdk-0.3.6-beta.9.tgz", + "integrity": "sha512-c9jlLlwUHLqxAZiAGiIeo2ag5orc8/L+6L/xVGRpNlqAEzb8PJPUPCaLtqC1guXstUMLxLgja1csj0p6tuZsBg==", "license": "MIT", "dependencies": { "@iarna/toml": "^2.2.5", diff --git a/package.json b/package.json index 954e31c..3e7af9a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "check": "tsc --noEmit" }, "dependencies": { - "@start9labs/start-sdk": "0.3.6-beta.4" + "@start9labs/start-sdk": "0.3.6-beta.9" }, "devDependencies": { "@types/node": "^22.1.0", diff --git a/startos/versions/index.ts b/startos/versions/index.ts index 339e78f..4b82476 100644 --- a/startos/versions/index.ts +++ b/startos/versions/index.ts @@ -1,4 +1,4 @@ import { VersionGraph } from '@start9labs/start-sdk' -import { v0360 } from './v0.3.6.0' +import { v_0_3_6_0 } from './v0.3.6.0' -export const versions = VersionGraph.of(v0360) +export const versions = VersionGraph.of(v_0_3_6_0) diff --git a/startos/versions/v0.3.6.0.ts b/startos/versions/v0.3.6.0.ts index ed8ffc7..31fa807 100644 --- a/startos/versions/v0.3.6.0.ts +++ b/startos/versions/v0.3.6.0.ts @@ -2,7 +2,7 @@ import { VersionInfo, IMPOSSIBLE } from '@start9labs/start-sdk' import { sdk } from '../sdk' import { setName } from '../actions/setName' -export const v0360 = VersionInfo.of({ +export const v_0_3_6_0 = VersionInfo.of({ version: '0.3.6:0', releaseNotes: 'Revamped for StartOS 0.3.6', migrations: { From 8a5d12133f6f8eb9aea30b826462d06d12494b4a Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Wed, 19 Feb 2025 16:55:48 +0100 Subject: [PATCH 119/120] grab PACKAGE_ID from manifest.ts --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bd51a6c..7c5aa15 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PACKAGE_ID := hello-world +PACKAGE_ID := $(shell grep -o "id: '[^']*'" startos/manifest.ts | sed "s/id: '\([^']*\)'/\1/") # Phony targets .PHONY: all clean install From 85dea08886181441ff8392f6d28b20e0e9f8d89d Mon Sep 17 00:00:00 2001 From: Mariusz Kogen Date: Fri, 21 Feb 2025 17:12:45 +0100 Subject: [PATCH 120/120] add build completion status --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 7c5aa15..53b3cbc 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ PACKAGE_ID := $(shell grep -o "id: '[^']*'" startos/manifest.ts | sed "s/id: '\( # Default target all: ${PACKAGE_ID}.s9pk + @echo " Done!" + @echo " Filesize: $(shell du -h $(PACKAGE_ID).s9pk) is ready" # Build targets ${PACKAGE_ID}.s9pk: $(shell start-cli s9pk list-ingredients)