Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit 1b75105

Browse files
Make plugin version optional (#133)
* Don't require plugins to have a version * Remove version numbers from examples * Library => SDK in metadata * Update CHANGELOG.md
1 parent 4471379 commit 1b75105

File tree

19 files changed

+19
-24
lines changed

19 files changed

+19
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## UNRELEASED
44

55
- Add functions and example for accessing PostgreSQL [#119](https://github.com/hypermodeAI/functions-as/pull/119)
6+
- Make plugin version optional [#133](https://github.com/hypermodeAI/functions-as/pull/133)
67

78
## 2024-07-10 - Version 0.9.4
89

examples/classification/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/classification/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "classification-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Classification Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/collection/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/collection/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "collection-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Collection Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/embedding/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/embedding/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "embedding-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Embedding Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/graphql/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/graphql/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "graphql-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions GraphQL Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/http/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/http/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "http-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions HTTP Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/postgresql/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/postgresql/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "postgresql-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Example using PostgreSQL database",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/simple/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/simple/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "simple-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Simple Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

examples/textgeneration/package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/textgeneration/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "text-generation-example",
33
"private": true,
4-
"version": "1.0.0",
54
"description": "Hypermode Functions Text Generation Example",
65
"author": "Hypermode, Inc.",
76
"license": "MIT",

src/bin/build-plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if (!npmPath) {
1414
process.exit(1);
1515
}
1616

17-
if (!pkg || !ver) {
18-
console.error("A package name and version must be defined in package.json.");
17+
if (!pkg) {
18+
console.error("A package name must be defined in package.json.");
1919
process.exit(1);
2020
}
2121

src/transform/src/metadata.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class HypermodeMetadata {
1414
buildId: string;
1515
buildTs: string;
1616
plugin: string;
17-
library: string;
17+
sdk: string;
1818
gitRepo?: string;
1919
gitCommit?: string;
2020
functions: FunctionSignature[] = [];
@@ -26,7 +26,7 @@ export class HypermodeMetadata {
2626
m.buildId = new Xid().toString();
2727
m.buildTs = new Date().toISOString();
2828
m.plugin = getPluginInfo();
29-
m.library = getHypermodeInfo();
29+
m.sdk = getSdkInfo();
3030

3131
if (isGitRepo()) {
3232
m.gitRepo = getGitRepo();
@@ -104,8 +104,8 @@ export class HypermodeMetadata {
104104

105105
writeHeader("Plugin Metadata:");
106106
writeTable([
107-
["Plugin Name", this.plugin],
108-
["Library", this.library],
107+
["Name", this.plugin],
108+
["SDK", this.sdk],
109109
["Build ID", this.buildId],
110110
["Build Timestamp", this.buildTs],
111111
this.gitRepo ? ["Git Repo", this.gitRepo] : undefined,
@@ -132,7 +132,7 @@ export class HypermodeMetadata {
132132
}
133133
}
134134

135-
function getHypermodeInfo(): string {
135+
function getSdkInfo(): string {
136136
const filePath = path.join(
137137
path.dirname(fileURLToPath(import.meta.url)),
138138
"..",
@@ -141,12 +141,22 @@ function getHypermodeInfo(): string {
141141
);
142142
const json = readFileSync(filePath).toString();
143143
const lib = JSON.parse(json);
144-
return `${lib.name}@${lib.version}`;
144+
return `${lib.name.split("/")[1]}@${lib.version}`;
145145
}
146146

147147
function getPluginInfo(): string {
148148
const pluginName = process.env.npm_package_name;
149149
const pluginVersion = process.env.npm_package_version;
150+
151+
if (!pluginName) {
152+
throw new Error("Missing name in package.json");
153+
}
154+
155+
if (!pluginVersion) {
156+
// versionless plugins are allowed
157+
return pluginName;
158+
}
159+
150160
return `${pluginName}@${pluginVersion}`;
151161
}
152162

0 commit comments

Comments
 (0)