syncer

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileTypeServerJS = "SERVER_JS"
	FileTypeHTML     = "HTML"
	FileTypeJSON     = "JSON"
)

Apps Script file types as used by the Script API.

Variables

This section is empty.

Functions

func ArchiveLocalFiles

func ArchiveLocalFiles(archiveRoot string, files []ProjectFile) error

ArchiveLocalFiles writes local files to the given archive root.

func BuildContent

func BuildContent(files []ProjectFile) *script.Content

BuildContent converts local files to a Script API content payload.

func DefaultFileExtensions

func DefaultFileExtensions() map[string][]string

DefaultFileExtensions returns the default Apps Script file extensions.

func SortFilesByPushOrder

func SortFilesByPushOrder(files []ProjectFile, filePushOrder []string, rootDir string)

SortFilesByPushOrder sorts files using filePushOrder rules.

Types

type Options

type Options struct {
	ProjectRoot        string
	RootDir            string
	Ignore             *config.ClaspIgnore
	FileExtensions     map[string][]string
	FilePushOrder      []string
	SkipSubdirectories bool
	// AllowSymlinks opts into following symlinked files during local file
	// collection. It is a CLI-level choice (--allow-symlinks /
	// GLASP_ALLOW_SYMLINKS), not part of .clasp.json, so callers set it after
	// building Options from config. When false (the default), symlinked files
	// are skipped rather than read, since a project shared over a symlinked
	// folder could otherwise cause push to read and upload arbitrary files
	// reachable via a link (e.g. one pointing outside the project).
	AllowSymlinks bool
	// OnSkip, when set, is called once for every candidate file
	// CollectLocalFiles decides not to collect for a reason a user might not
	// expect (matched .claspignore, a symlink, or a .d.ts declaration file).
	// It is not called for files that simply don't match a configured
	// extension (e.g. README.md in a typical project) — that is expected,
	// not surprising, behavior. Callers use this to surface a "N files
	// skipped" summary so a file missing from a push isn't a silent mystery.
	OnSkip func(SkippedFile)
}

Options defines settings for local/remote synchronization.

func OptionsFromConfig

func OptionsFromConfig(projectRoot string, cfg *config.ClaspConfig, ignore *config.ClaspIgnore) (Options, error)

OptionsFromConfig builds Options from a .clasp.json config.

type ProjectFile

type ProjectFile struct {
	// LocalPath is the project-relative path on disk (e.g. "src/Code.gs").
	LocalPath string
	// RemotePath is the Apps Script file name/path without extension (e.g. "Code" or "ui/page").
	RemotePath string
	// Type maps to Apps Script file types (SERVER_JS, HTML, JSON).
	Type string
	// Source is the file contents to send to or received from the Script API.
	Source string
}

ProjectFile represents a file mapped between local and remote.

func ApplyRemoteContent

func ApplyRemoteContent(opts Options, content *script.Content) ([]ProjectFile, error)

ApplyRemoteContent writes remote content to the local filesystem.

func CollectLocalFiles

func CollectLocalFiles(opts Options) ([]ProjectFile, error)

CollectLocalFiles scans local files and returns push-ready project files.

type SkipReason added in v0.5.2

type SkipReason string

SkipReason identifies why CollectLocalFiles did not collect a candidate file.

const (
	// SkipReasonIgnored means the path matched .claspignore (or a built-in
	// default ignore pattern such as node_modules/).
	SkipReasonIgnored SkipReason = "ignored"
	// SkipReasonDeclaration means the file is a TypeScript .d.ts declaration
	// file, which is never deployable and is always excluded.
	SkipReasonDeclaration SkipReason = "declaration"
	// SkipReasonSymlink means the file is a symlink that was skipped because
	// --allow-symlinks was not set.
	SkipReasonSymlink SkipReason = "symlink"
)

type SkippedFile added in v0.5.2

type SkippedFile struct {
	// Path is the file's path relative to ProjectRoot (slash-separated).
	Path   string
	Reason SkipReason
}

SkippedFile records one file CollectLocalFiles chose not to collect, reported via Options.OnSkip.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL