Skip to content

Commit 1817212

Browse files
authored
Merge pull request #7 from grafana/update-docs
Update docs
2 parents 619cd4e + 20eacc9 commit 1817212

19 files changed

+84
-66
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup go
2323
uses: actions/setup-go@v5
2424
with:
25-
go-version: "1.21"
25+
go-version: "1.22.4"
2626
cache: false
2727
- name: Go linter
2828
uses: golangci/golangci-lint-action@v3

.github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v5
1919
with:
20-
go-version: "1.21"
20+
go-version: "1.22.4"
2121
- name: Run GoReleaser
2222
uses: goreleaser/goreleaser-action@v5
2323
with:
2424
distribution: goreleaser
25-
version: "1.22.0"
25+
version: "2.0.1"
2626
args: release --clean
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install Go
2424
uses: actions/setup-go@v5
2525
with:
26-
go-version: "1.21"
26+
go-version: "1.22.4"
2727
- name: Checkout code
2828
uses: actions/checkout@v4
2929

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/node_modules
55
/package.json
66
/yarn.lock
7+
test*.db

.goreleaser.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
project_name: k6deps
2+
version: 2
23
before:
34
hooks:
45
- go mod tidy
@@ -9,7 +10,7 @@ builds:
910
goos: ["darwin", "linux", "windows"]
1011
goarch: ["amd64", "arm64"]
1112
ldflags:
12-
- '-s -w -X main.version={{.Version}} -X main.appname={{.ProjectName}}'
13+
- "-s -w -X main.version={{.Version}} -X main.appname={{.ProjectName}}"
1314
dir: cmd/k6deps
1415
source:
1516
enabled: true

cmd/cmd.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package cmd contains deps cobra command factory function.
1+
// Package cmd contains k6deps cobra command factory function.
22
package cmd
33

44
import (
@@ -48,7 +48,7 @@ func New() *cobra.Command {
4848
opts := new(options)
4949

5050
cmd := &cobra.Command{
51-
Use: "deps [flags] [script-file]",
51+
Use: "k6deps [flags] [script-file]",
5252
Short: "Extension dependency detection for k6.",
5353
Long: help,
5454
Args: cobra.MaximumNArgs(1),

cmd/cmd_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Test_New(t *testing.T) {
1515

1616
root := cmd.New()
1717

18-
require.Equal(t, "deps [flags] [script-file]", root.Use)
18+
require.Equal(t, "k6deps [flags] [script-file]", root.Use)
1919

2020
dir := t.TempDir()
2121

cmd/k6deps/main.go

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package main
44
import (
55
"log"
66
"os"
7-
"strings"
87

98
"github.com/grafana/k6deps/cmd"
109
"github.com/spf13/cobra"
@@ -22,7 +21,6 @@ func main() {
2221

2322
func newCmd(args []string) *cobra.Command {
2423
cmd := cmd.New()
25-
cmd.Use = strings.Replace(cmd.Use, cmd.Name(), appname, 1)
2624
cmd.Version = version
2725
cmd.SetArgs(args)
2826

examples/combined.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use k6 >= 0.50";
2+
"use k6 with k6/x/faker >= 0.3.0";
3+
"use k6 with k6/x/sql >= 0.4.0";
4+
5+
import faker from "./faker.js";
6+
import sqlite from "./sqlite.js";
7+
8+
export { setup, teardown } from "./sqlite.js";
9+
10+
export default () => {
11+
faker();
12+
sqlite();
13+
};

examples/device.js

-14
This file was deleted.

examples/faker.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// source: https://github.com/szkiba/xk6-faker/blob/v0.3.0/examples/custom-faker.js
2+
import { Faker } from "k6/x/faker";
3+
4+
const faker = new Faker(11);
5+
6+
export default function () {
7+
console.log(faker.person.firstName());
8+
}
9+
10+
// output: Josiah

examples/script.js

-12
This file was deleted.

examples/sqlite.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// source: https://github.com/grafana/xk6-sql/blob/v0.4.0/examples/sqlite3_test.js
2+
import sql from "k6/x/sql";
3+
4+
const db = sql.open("sqlite3", "./test.db");
5+
6+
export function setup() {
7+
db.exec(`CREATE TABLE IF NOT EXISTS keyvalues (
8+
id integer PRIMARY KEY AUTOINCREMENT,
9+
key varchar NOT NULL,
10+
value varchar);`);
11+
}
12+
13+
export function teardown() {
14+
db.close();
15+
}
16+
17+
export default function () {
18+
db.exec("INSERT INTO keyvalues (key, value) VALUES('plugin-name', 'k6-plugin-sql');");
19+
20+
let results = sql.query(db, "SELECT * FROM keyvalues WHERE key = $1;", "plugin-name");
21+
for (const row of results) {
22+
console.log(`key: ${row.key}, value: ${row.value}`);
23+
}
24+
}

examples/user.js

-14
This file was deleted.

go.mod

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
module github.com/grafana/k6deps
22

3-
go 1.21
3+
go 1.22.4
44

55
require (
66
github.com/Masterminds/semver/v3 v3.2.1
7-
github.com/evanw/esbuild v0.21.3
7+
github.com/evanw/esbuild v0.21.5
88
github.com/grafana/clireadme v0.1.0
99
github.com/grafana/k6pack v0.2.0
10-
github.com/spf13/cobra v1.8.0
10+
github.com/spf13/cobra v1.8.1
1111
github.com/stretchr/testify v1.9.0
12-
golang.org/x/term v0.18.0
12+
golang.org/x/term v0.21.0
1313
)
1414

1515
require (
@@ -19,6 +19,6 @@ require (
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
2020
github.com/rogpeppe/go-internal v1.12.0 // indirect
2121
github.com/spf13/pflag v1.0.5 // indirect
22-
golang.org/x/sys v0.18.0 // indirect
22+
golang.org/x/sys v0.21.0 // indirect
2323
gopkg.in/yaml.v3 v3.0.1 // indirect
2424
)

go.sum

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
22
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
3-
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
3+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
44
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7-
github.com/evanw/esbuild v0.21.3 h1:SeawdSUXrp+Auz8K8AxvgmpjqfYhvJkdxqpgqgxuXmk=
8-
github.com/evanw/esbuild v0.21.3/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
7+
github.com/evanw/esbuild v0.21.5 h1:oShm8TT5QUhf6vM7teg0nmd14eHu64dPmVluC2f4DMg=
8+
github.com/evanw/esbuild v0.21.5/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
99
github.com/grafana/clireadme v0.1.0 h1:KYEYSnYdSzmHf3bufaK6fQZ5j4dzvM/T+G6Ba+qNnAM=
1010
github.com/grafana/clireadme v0.1.0/go.mod h1:Wy4KIG2ZBGMYAYyF9l7qAy+yoJVasqk/txsRgoRI3gc=
1111
github.com/grafana/k6pack v0.2.0 h1:Y8udypzuzFdcFMRHnP5VkdjYXWLb/ouKzm4ct3OqPmg=
@@ -21,17 +21,17 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
2121
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
2222
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
2323
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
24-
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
25-
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
24+
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
25+
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
2626
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
2727
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
2828
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
2929
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3030
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
31-
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
32-
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
33-
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
34-
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
31+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
32+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
33+
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
34+
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
3535
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3636
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
3737
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

releases/v0.1.2.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
k6deps `v0.1.2` is here 🎉!
2+
3+
**New features**:
4+
5+
- add support for searching the manifest file without a script parameter, starting from the current directory
6+
7+
**Fixes**:
8+
9+
- accept k6 as valid dependency name
10+

releases/v0.1.3.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
k6deps `v0.1.3` is here 🎉!
2+
3+
This is a maintenance release.

tools/gendoc/main.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package main
33

44
import (
55
_ "embed"
6-
"strings"
76

87
"github.com/grafana/clireadme"
98
"github.com/grafana/k6deps/cmd"
109
)
1110

1211
func main() {
1312
root := cmd.New()
14-
root.Use = strings.ReplaceAll(root.Use, "deps", "k6deps")
1513
clireadme.Main(root, 1)
1614
}

0 commit comments

Comments
 (0)