这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions cli/internal/fs/package_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,13 @@ import (
"github.com/pascaldekloe/name"
)

// TurboCacheOptions are configuration for Turborepo cache

type TurboConfigJSON struct {
Base string `json:"baseBranch,omitempty"`
GlobalDependencies []string `json:"globalDependencies,omitempty"`
TurboCacheOptions string `json:"cacheOptions,omitempty"`
Outputs []string `json:"outputs,omitempty"`
RemoteCacheUrl string `json:"remoteCacheUrl,omitempty"`
Pipeline map[string]Pipeline
}

// Camelcase string with optional args.
func Camelcase(s string, v ...interface{}) string {
return name.CamelCase(fmt.Sprintf(s, v...), true)
}

var requiredFields = []string{"Name", "Version"}

type Pipeline struct {
Outputs []string `json:"outputs,omitempty"`
Cache *bool `json:"cache,omitempty"`
DependsOn []string `json:"dependsOn,omitempty"`
}

// PackageJSON represents NodeJS package.json
type PackageJSON struct {
Name string `json:"name,omitempty"`
Expand Down
49 changes: 49 additions & 0 deletions cli/internal/fs/turbo_json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package fs

// TurboConfigJSON is the root turborepo configuration
type TurboConfigJSON struct {
// Base Git branch
BaseBranch string `json:"baseBranch,omitempty"`
// Global root filesystem dependencies
GlobalDependencies []string `json:"globalDependencies,omitempty"`
// HashInputCommands are an array of commands whose outputs (stdout/stderr)
// will be included in the global hash value. This value is included in all
// other package-task hashes
HashInputCommands []string `json:"hashInputCommands,omitempty"`
// HashEnvVars are a list of environment variables whose key-values will be
// included in the global hash. This is useful for when you want hashes to
// change based on the value of an env var
HashEnvVars []string `json:"hashEnvVariables,omitempty"`
// CacheOptions configure how Turbo will cache tasks
CacheOptions struct {
// RemoteCacheUrl is the Remote Cache API URL
RemoteCacheUrl string `json:"remoteCacheUrl,omitempty"`
// RemoteOnly forces Turbo to only fetch/put artifacts to the remote cache
// and avoid local caching
RemoteOnly bool `json:"remoteCacheOnly,omitempty"`
// LocalCacheDirectory is the relative path to the local filesystem cache
// directory
LocalCacheDirectory string `json:"localCacheDirectory,omitempty"`
// Workers are the number of cache workers in the async cache worker pool
// use to store task artifacts. Default is runtime.NumCPU() + 2,
Workers int `json:"cacheWorkers"`
} `json:"cacheOptions,omitempty"`
// Pipeline is a map of Turbo pipeline entries which define the task graph
// and cache behavior on a per task or per package-task basis.
Pipeline map[string]Pipeline
}

// Pipeline specifies the relationship(s) between package.json
// scripts (i.e. tasks) and caching behavior in a concise manner.
type Pipeline struct {
// Outputs are an array of globs relative to the package to
// be cached
Outputs []string `json:"outputs,omitempty"`
// Cache is a boolean of whether or not the task should
// cached
Cache *bool `json:"cache,omitempty"`
// DependsOn defines both per-task and topological task dependencies.
// Topological dependencies are prefixed with a delimiter (^) whereas
// intra-package dependencies are not.
DependsOn []string `json:"dependsOn,omitempty"`
}
23 changes: 23 additions & 0 deletions turbomod/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node

// turbomod
const fs = require("fs");
const path = require("path");
const util = require("util");

const packageJsonRaw = fs.readFileSync(
path.join(process.cwd(), "package.json")
);
const packageJson = JSON.parse(packageJsonRaw);
const { turbo, ...rest } = packageJson;
fs.writeFileSync(
path.join(process.cwd(), "package.json"),
JSON.stringify(rest, null, 2)
);
if (turbo) {
fs.writeFileSync(
path.join(process.cwd(), "turbo.json"),
JSON.stringify(turbo, null, 2),
"utf-8"
);
}
6 changes: 6 additions & 0 deletions turbomod/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "turbomod",
"version": "1.0.0",
"main": "index.js",
"license": "MPL-2.0"
}