Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe), packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier (CLI app), vendor/zapier-platform, and research/zapier vendor corpus. Gate 0 structure checks pass. Product code and research are not yet wired.
This commit is contained in:
commit
b4150c8250
864 changed files with 6814366 additions and 0 deletions
2
vendor/zapier-platform.UPSTREAM
vendored
Normal file
2
vendor/zapier-platform.UPSTREAM
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
upstream: git@github.com:zapier/zapier-platform.git
|
||||
source-clone: /Users/marchon/research/zapier-platform
|
||||
58
vendor/zapier-platform/.cursor/rules/main.md
vendored
Normal file
58
vendor/zapier-platform/.cursor/rules/main.md
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# Cursor Rules for Zapier Platform
|
||||
|
||||
You are working on the Zapier Platform monorepo containing packages for the Zapier Developer Platform Experience.
|
||||
|
||||
## Repository Documentation
|
||||
|
||||
For detailed repository information, reference these documentation files:
|
||||
|
||||
### Primary Documentation
|
||||
- README.md - Repository overview, package descriptions, all doc links
|
||||
- CONTRIBUTING.md - Setup, testing workflow, pnpm linking
|
||||
- ARCHITECTURE.md - Repository structure and organization
|
||||
|
||||
### Quick Reference (docs-dev/)
|
||||
- docs-dev/package-info.md - Package purposes and relationships
|
||||
- docs-dev/commands.md - Command cheat sheet and workflows
|
||||
- docs-dev/install-dev.md - Development CLI setup
|
||||
|
||||
## Development Guidelines
|
||||
|
||||
When working with this codebase:
|
||||
|
||||
1. **Documentation updates**: Always update existing markdown files (README.md, CONTRIBUTING.md, etc.) or `docs-dev/` files instead of this .cursor/rules file for repository information changes.
|
||||
|
||||
2. **Package relationships**: Reference `docs-dev/package-info.md` to understand package interdependencies before making changes across packages.
|
||||
|
||||
3. **Testing workflow**:
|
||||
- Use `pnpm validate` at root for comprehensive validation
|
||||
- Individual package testing requires `cd` into the specific package directory first
|
||||
- Follow existing Mocha patterns with `.only` for focused testing
|
||||
|
||||
4. **Monorepo patterns**:
|
||||
- Root-level commands use pnpm workspaces
|
||||
- Package-specific commands require navigating to package directory
|
||||
- TypeScript types are auto-generated via husky hooks - no manual intervention needed
|
||||
|
||||
5. **Code style**:
|
||||
- Follow existing code conventions within each package
|
||||
- Use existing utility functions and established patterns
|
||||
- Maintain consistency with the package's existing architecture
|
||||
|
||||
## Key Commands
|
||||
|
||||
For complete command reference, see docs-dev/commands.md.
|
||||
|
||||
Essential commands:
|
||||
- `pnpm test` - Run all tests across all packages
|
||||
- `pnpm validate` - Full validation (test + smoke-test + lint)
|
||||
- `pnpm generate-types` - Generate TypeScript declarations
|
||||
- Individual packages: `cd packages/[package-name]` then `pnpm test`
|
||||
|
||||
## Package Structure
|
||||
|
||||
- zapier-platform-cli (packages/cli/) - Developer-facing CLI tool
|
||||
- zapier-platform-core (packages/core/) - Runtime functionality for Zapier apps
|
||||
- zapier-platform-schema (packages/schema/) - App structure validation source of truth
|
||||
- zapier-platform-legacy-scripting-runner (packages/legacy-scripting-runner/) - Legacy compatibility layer
|
||||
- schema-to-ts (schema-to-ts/) - TypeScript declaration generator
|
||||
106
vendor/zapier-platform/.gitignore
vendored
Normal file
106
vendor/zapier-platform/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/node
|
||||
# Edit at https://www.gitignore.io/?templates=node
|
||||
|
||||
### Node ###
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# End of https://www.gitignore.io/api/node
|
||||
|
||||
example-apps/*/yarn.lock
|
||||
example-apps/*/package-lock.json
|
||||
example-apps/typescript/lib
|
||||
|
||||
boilerplate/build
|
||||
|
||||
.vscode
|
||||
|
||||
.idea/
|
||||
|
||||
.DS_Store
|
||||
|
||||
.pnpm-store/
|
||||
1
vendor/zapier-platform/.husky/.gitignore
vendored
Normal file
1
vendor/zapier-platform/.husky/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
_
|
||||
1
vendor/zapier-platform/.husky/pre-commit
vendored
Executable file
1
vendor/zapier-platform/.husky/pre-commit
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
pnpm -r precommit && lint-staged
|
||||
3
vendor/zapier-platform/.npmrc
vendored
Normal file
3
vendor/zapier-platform/.npmrc
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# This project uses pnpm, but just in case npm is used, we want to avoid running
|
||||
# pre/post install scripts by accident.
|
||||
ignore-scripts = true
|
||||
7
vendor/zapier-platform/.prettierignore
vendored
Normal file
7
vendor/zapier-platform/.prettierignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
packages/cli/scaffold/
|
||||
package.json
|
||||
package-lock.json
|
||||
packages/cli/src/generators/templates/
|
||||
.yarn
|
||||
|
||||
/.nx/workspace-data
|
||||
1
vendor/zapier-platform/.tool-versions
vendored
Normal file
1
vendor/zapier-platform/.tool-versions
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
pnpm 10.26.2
|
||||
3
vendor/zapier-platform/.yarnrc
vendored
Normal file
3
vendor/zapier-platform/.yarnrc
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# This project uses pnpm, but just in case npm is used, we want to avoid running
|
||||
# pre/post install scripts by accident.
|
||||
ignore-scripts true
|
||||
12
vendor/zapier-platform/ARCHITECTURE.md
vendored
Normal file
12
vendor/zapier-platform/ARCHITECTURE.md
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# `zapier-platform` Architecture
|
||||
|
||||
## Purpose
|
||||
|
||||
- The `zapier/zapier-platform` repository is structured as a [monorepo](https://en.wikipedia.org/wiki/Monorepo), where separate but related code lives together.
|
||||
|
||||
## Technical Organization
|
||||
|
||||
- The root folder mostly holds tooling scripts, tooling configuration, examples, and documentation for the platform as a whole.
|
||||
- The `schema-to-ts` folder contains a custom package that generates TypeScript declarations for `zapier-platform-core` based on the `zapier-platform-schema`'s generated `exported-schema.json` file. These generated type declarations are bundled into `zapier-platform-core` and shipped to end-users as part of that NPM package. Type declarations are configured to be generated via the `generate-types` NPM script, which runs automatically as part of a `husky` precommit hook.
|
||||
- The individual packages are found in the `packages` directory. Each has its own `ARCHITECTURE.md` file outlining the code for that specific package.
|
||||
- The `boilerplate` directory holds a "bare minimum" app that we include with each `zapier-platform-core` version (AKA Platform Version). We use this in combination with the Visual Builder to ship apps that that skip the build step.
|
||||
11
vendor/zapier-platform/CHANGELOG.md
vendored
Normal file
11
vendor/zapier-platform/CHANGELOG.md
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
## Moved
|
||||
|
||||
Go to [Platform News](https://docs.zapier.com/platform/news) for the latest updates, release notes, changelogs, and tips.
|
||||
|
||||
## Changelog Archive for Older Releases
|
||||
|
||||
Changelogs for older versions are archived in the [changelog](https://github.com/zapier/zapier-platform/tree/main/changelog) directory.
|
||||
|
||||
- [v14 - v16](https://github.com/zapier/zapier-platform/tree/main/changelog/v14-v16.md)
|
||||
- [v10 - v13](https://github.com/zapier/zapier-platform/tree/main/changelog/v10-v13.md)
|
||||
- [v0 - v9](https://github.com/zapier/zapier-platform/tree/main/changelog/v0-v9.md)
|
||||
23
vendor/zapier-platform/CLAUDE.md
vendored
Normal file
23
vendor/zapier-platform/CLAUDE.md
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Documentation Reference
|
||||
|
||||
### Primary Documentation (read these first)
|
||||
- **[README.md](README.md)** - Repository overview, package descriptions, all doc links
|
||||
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - Setup, testing workflow, package linking
|
||||
- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Repository structure and organization
|
||||
|
||||
### Quick Reference (for task-oriented work)
|
||||
- **[docs-dev/install-dev.md](docs-dev/install-dev.md)** - Development CLI setup
|
||||
- **[docs-dev/commands.md](docs-dev/commands.md)** - Command cheat sheet
|
||||
- **[docs-dev/package-info.md](docs-dev/package-info.md)** - Package purposes and relationships
|
||||
|
||||
## Claude-Specific Workflow Notes
|
||||
|
||||
1. **Documentation updates**: Update existing markdown files (README.md, CONTRIBUTING.md, etc.) or `docs-dev/` files, not this CLAUDE.md
|
||||
2. **Testing workflow**: Use `pnpm validate` at root for full validation, or `cd` into specific packages for targeted testing
|
||||
3. **TypeScript types**: Generated automatically via husky hooks - no manual intervention needed
|
||||
4. **Package development**: Always understand package relationships from `docs-dev/package-info.md` before making changes
|
||||
5. **Monorepo commands**: Use pnpm from root; individual packages need `cd` first
|
||||
73
vendor/zapier-platform/CONTRIBUTING.md
vendored
Normal file
73
vendor/zapier-platform/CONTRIBUTING.md
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Contributing
|
||||
|
||||
## Terms
|
||||
|
||||
This contributor guide is mainly for Zapier employees. However, zapier-platform is a public repo. Everyone is welcome to submit a pull request (PR). For non-employees, you must agree to the terms of service listed at https://zapier.com/developer-platform/tos (the link is also included in the [LICENSE](license) file) before submitting a PR.
|
||||
|
||||
## Local Setup
|
||||
|
||||
Install [pnpm][pnpm] if you haven't. We recommend using [asdf](asdf) to install and manage your
|
||||
Node.js and pnpm versions.
|
||||
|
||||
Clone this repo with git:
|
||||
|
||||
```bash
|
||||
git clone git@github.com:zapier/zapier-platform.git
|
||||
cd zapier-platform
|
||||
```
|
||||
|
||||
In the repo directory, install dependencies with pnpm:
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
|
||||
That's it! Now you have a local environment for development.
|
||||
|
||||
## Running Tests
|
||||
|
||||
For detailed testing commands and workflow, see [docs-dev/commands.md](docs-dev/commands.md).
|
||||
|
||||
Quick overview:
|
||||
- `pnpm test` - Run all tests for all packages
|
||||
- `pnpm validate` - Full validation (test + smoke-test + lint)
|
||||
- Individual packages: `cd` into package directory first, then `pnpm test`
|
||||
|
||||
## Testing Guidelines
|
||||
|
||||
### Writing Quality Tests
|
||||
|
||||
When writing tests, especially for generators and complex components, follow these guidelines to ensure tests are robust and maintainable:
|
||||
|
||||
#### ✅ DO: Test Actual Component Behavior
|
||||
|
||||
Always test the actual behavior of the component being tested.
|
||||
|
||||
#### ❌ DON'T: Use Simulation-Based Testing
|
||||
|
||||
Never extract logic from the component and test it in isolation. This creates brittle tests that don't reflect actual behavior.
|
||||
|
||||
#### Why Simulation Testing is Problematic
|
||||
|
||||
1. **Duplication**: Simulated logic can diverge from actual implementation
|
||||
2. **False confidence**: Tests may pass while actual functionality is broken
|
||||
3. **Maintenance burden**: Changes require updating both implementation and simulation
|
||||
4. **Missing integration issues**: Doesn't test how components interact with their environment
|
||||
|
||||
## Development CLI Setup
|
||||
|
||||
For setting up the development version of the CLI, see [docs-dev/install-dev.md](docs-dev/install-dev.md).
|
||||
|
||||
## Package Linking for Integration Development
|
||||
|
||||
For linking development versions of core and schema packages to your integration projects, see the "Package Linking" section in [docs-dev/commands.md](docs-dev/commands.md).
|
||||
|
||||
## Releasing a New Version
|
||||
|
||||
**Zapier employees only.** Refer to this [internal doc][releasing] on how to cut a release.
|
||||
|
||||
|
||||
[license]: https://github.com/zapier/zapier-platform/blob/main/LICENSE
|
||||
[pnpm]: https://pnpm.io/installation
|
||||
[asdf]: https://asdf-vm.com
|
||||
[releasing]: https://coda.io/d/_di0MgBhlCWf/Releasing-a-New-zapier-platform-Version_su5eD
|
||||
3
vendor/zapier-platform/LICENSE
vendored
Normal file
3
vendor/zapier-platform/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Copyright (c) Zapier, Inc.
|
||||
|
||||
This repository is part of Zapier Platform. By downloading, installing, accessing, or using any part of the Zapier Platform, including this repository, you agree to the Zapier Platform Agreement, which can be found at: https://zapier.com/platform/tos. If you do not agree to the Zapier Platform Agreement, you may not download, install, access, or use any part of the Zapier Platform, including this repository.
|
||||
30
vendor/zapier-platform/README.md
vendored
Normal file
30
vendor/zapier-platform/README.md
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Zapier Platform
|
||||
|
||||
[](https://github.com/zapier/zapier-platform/actions/workflows/ci.yaml)
|
||||
|
||||
This is the main monorepo for all public code that powers the Zapier Platform Experience.
|
||||
|
||||
## Contents
|
||||
|
||||
It consists of a few main packages:
|
||||
|
||||
- [`zapier-platform-cli`](packages/cli): The CLI that devs can use to perform common tasks with their apps (such as `push`, `promote`, etc)
|
||||
- [`zapier-platform-core`](packages/core): The package which all apps depend on; it provides functionality at runtime
|
||||
- [`zapier-platform-schema`](packages/schema): The source of truth for what's allowed in the structure a Zapier app; not typically installed directly
|
||||
- [`zapier-platform-legacy-scripting-runner`](packages/legacy-scripting-runner): If your app started as a Legacy Web Builder app, this provides a shim that keeps your app running seamlessly
|
||||
- [`example-apps/*`](example-apps): A varied set of example apps to help you get started
|
||||
- [`schema-to-ts`](schema-to-ts): Custom tooling to generate TypeScript declarations for `zapier-platform-core` using `zapier-platform-schema`'s output schemas
|
||||
|
||||
## Docs
|
||||
|
||||
* Public-facing docs:
|
||||
- [Platform Docs](https://docs.zapier.com/platform)
|
||||
- [CLI Command Reference](packages/cli/docs/cli.md)
|
||||
- [Schema Reference](packages/schema/docs/build/schema.md)
|
||||
- [Platform News](https://docs.zapier.com/platform/news) ([RSS feed](https://docs.zapier.com/platform/news.xml)) - latest updates, release notes, changelogs, and tips
|
||||
- [Old Changelog Archive](changelog) - old changelogs before v17
|
||||
* Internal-facing docs:
|
||||
- Testing out new features that haven't been released to npm yet? See [docs-dev/install-dev.md](docs-dev/install-dev.md)
|
||||
- Learn about how this repo is structured in [ARCHITECTURE.md](ARCHITECTURE.md)
|
||||
- Looking to contribute to this repo? See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
- Quick reference for development tasks? See [docs-dev/](docs-dev/)
|
||||
5
vendor/zapier-platform/boilerplate/README.md
vendored
Normal file
5
vendor/zapier-platform/boilerplate/README.md
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Zapier Platform Boilerplate
|
||||
|
||||
Boilerplate is an empty Zapier integration project. We use it to build a zip
|
||||
providing all the necessary dependencies for integrations developed on visual
|
||||
builder.
|
||||
1
vendor/zapier-platform/boilerplate/index.js
vendored
Normal file
1
vendor/zapier-platform/boilerplate/index.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
module.exports = {}; // Ignored
|
||||
18
vendor/zapier-platform/boilerplate/package.json
vendored
Normal file
18
vendor/zapier-platform/boilerplate/package.json
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "zapier-platform-boilerplate",
|
||||
"version": "1.0.0",
|
||||
"description": "A boilerplate that allows running a buildless app.",
|
||||
"homepage": "https://zapier.com/",
|
||||
"author": "Zapier <partners@zapier.com>",
|
||||
"license": "UNLICENSED",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=10",
|
||||
"npm": ">=5.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"zapier-platform-core": "PLACEHOLDER",
|
||||
"zapier-platform-legacy-scripting-runner": "PLACEHOLDER"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
7
vendor/zapier-platform/boilerplate/pnpm-workspace.yaml
vendored
Normal file
7
vendor/zapier-platform/boilerplate/pnpm-workspace.yaml
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Don't use symlinks in node_modules so we can zip it
|
||||
nodeLinker: hoisted
|
||||
|
||||
# When building from local code (no args to build.sh), the line below is
|
||||
# replaced with an overrides section so core's transitive dependency on
|
||||
# zapier-platform-schema resolves from a local tarball instead of npm.
|
||||
# OVERRIDES_PLACEHOLDER
|
||||
281
vendor/zapier-platform/boilerplate/scripts/build.sh
vendored
Executable file
281
vendor/zapier-platform/boilerplate/scripts/build.sh
vendored
Executable file
|
|
@ -0,0 +1,281 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on any command failure; in pipelines, fail if any command (not just the
|
||||
# last) returns non-zero.
|
||||
set -eo pipefail
|
||||
|
||||
#
|
||||
# Build boilerplate - a zip file that is generated as if you `zapier-platform build` an empty CLI
|
||||
# app. This zip file acts as a runtime for all the UI apps.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# $ ./scripts/build.sh [CORE_VERSION] [LEGACY_SCRIPTING_RUNNER_VERSION]
|
||||
#
|
||||
# This scripts accepts two optional arguments - core and legacy-scripting-runner
|
||||
# versions. If the version is specified, that packgage will be downloaded from npm
|
||||
# instead of built from local.
|
||||
#
|
||||
# For example, this builds core and legacy-scripting-runner from local code:
|
||||
#
|
||||
# $ ./scripts/build.sh
|
||||
#
|
||||
# Download both core and legacy-scripting-runner from npm:
|
||||
#
|
||||
# $ ./scripts/build.sh 9.7.1 3.8.5
|
||||
#
|
||||
# Build core from local and download legacy-scripting-runner from npm:
|
||||
#
|
||||
# $ ./scripts/build.sh '' 3.8.5
|
||||
#
|
||||
# Download core from npm and build legacy-scripting-runner from local:
|
||||
#
|
||||
# $ ./scripts/build.sh 9.7.1
|
||||
#
|
||||
|
||||
update_deps() {
|
||||
package_json=$1
|
||||
core_version=$2
|
||||
lsr_version=$3
|
||||
|
||||
cmd_for_core="s|\"zapier-platform-core\": \"[^\"]*\""
|
||||
cmd_for_core+="|\"zapier-platform-core\": \"$core_version\"|g"
|
||||
|
||||
cmd_for_lsr="s|\"zapier-platform-legacy-scripting-runner\": \"[^\"]*\""
|
||||
cmd_for_lsr+="|\"zapier-platform-legacy-scripting-runner\": \"$lsr_version\"|g"
|
||||
|
||||
sed -i.bak "$cmd_for_core" "$package_json"
|
||||
sed -i.bak "$cmd_for_lsr" "$package_json"
|
||||
|
||||
rm -f "$package_json.bak"
|
||||
}
|
||||
|
||||
inspect_build() {
|
||||
local zip_file=$1
|
||||
local expected_core=$2
|
||||
local expected_schema=$3
|
||||
local expected_lsr=$4
|
||||
|
||||
temp_dir="`dirname $zip_file`/_temp"
|
||||
unzip -q $zip_file -d $temp_dir
|
||||
|
||||
# Build a JSON object of expected versions and compare against actual
|
||||
actual=$(find $temp_dir/node_modules -maxdepth 2 -name package.json -path "*/zapier-platform-*/*" | xargs cat | jq -s '
|
||||
map({(.name): .version}) | add')
|
||||
echo "$actual" | jq .
|
||||
|
||||
rm -rf $temp_dir
|
||||
|
||||
expected=$(jq -n \
|
||||
--arg core "$expected_core" \
|
||||
--arg schema "$expected_schema" \
|
||||
--arg lsr "$expected_lsr" \
|
||||
'{"zapier-platform-core": $core, "zapier-platform-schema": $schema, "zapier-platform-legacy-scripting-runner": $lsr}')
|
||||
|
||||
if echo "$actual" | jq -e --argjson expected "$expected" '. == $expected' > /dev/null 2>&1; then
|
||||
echo "All dependency versions match ✅"
|
||||
else
|
||||
echo "ERROR: dependency version mismatch ❌"
|
||||
echo "Expected: $expected"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_size() {
|
||||
local min_mb=3
|
||||
local max_mb=10
|
||||
local min_bytes=$((min_mb * 1024 * 1024))
|
||||
local max_bytes=$((max_mb * 1024 * 1024))
|
||||
local file_size=$(stat -f%z "$1" 2>/dev/null || stat -c%s "$1")
|
||||
local size_mb=$(echo "scale=2; $file_size / 1024 / 1024" | bc)
|
||||
if [[ $file_size -lt $min_bytes || $file_size -gt $max_bytes ]]; then
|
||||
echo "ERROR: zip file size ${size_mb} MB is outside expected range (${min_mb}-${max_mb} MB) ❌"
|
||||
return 1
|
||||
else
|
||||
echo "Zip file size ${size_mb} MB is within expected range (${min_mb}-${max_mb} MB) ✅"
|
||||
fi
|
||||
}
|
||||
|
||||
test_build() {
|
||||
temp_dir="`dirname $1`/_temp"
|
||||
unzip -q $1 -d $temp_dir
|
||||
|
||||
pushd $temp_dir > /dev/null
|
||||
local rc=0
|
||||
node zapierwrapper.js || rc=$?
|
||||
popd > /dev/null
|
||||
rm -rf $temp_dir
|
||||
|
||||
if [[ $rc -eq 0 ]]; then
|
||||
echo "Entry point can be loaded successfully ✅"
|
||||
else
|
||||
echo "Entry point failed to load ❌"
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
|
||||
# Get the absolute path of the directory holding this script file
|
||||
SCRIPT_DIR=$(dirname $0)
|
||||
pushd $SCRIPT_DIR > /dev/null
|
||||
SCRIPT_DIR=$(pwd)
|
||||
popd > /dev/null
|
||||
|
||||
REPO_DIR=$(dirname $(dirname $SCRIPT_DIR))
|
||||
CORE_DIR="$REPO_DIR/packages/core"
|
||||
SCHEMA_DIR="$REPO_DIR/packages/schema"
|
||||
LSR_DIR="$REPO_DIR/packages/legacy-scripting-runner"
|
||||
BOILERPLATE_DIR="$REPO_DIR/boilerplate"
|
||||
|
||||
BUILD_DIR="$BOILERPLATE_DIR/build"
|
||||
|
||||
# Restore modified files on exit (success or failure)
|
||||
cleanup() {
|
||||
local exit_code=$?
|
||||
# Restore pnpm-workspace.yaml if a backup exists
|
||||
if [ -f "$BOILERPLATE_DIR/pnpm-workspace.yaml.bak" ]; then
|
||||
mv "$BOILERPLATE_DIR/pnpm-workspace.yaml.bak" "$BOILERPLATE_DIR/pnpm-workspace.yaml"
|
||||
fi
|
||||
# Restore package.json placeholders
|
||||
update_deps "$BOILERPLATE_DIR/package.json" PLACEHOLDER PLACEHOLDER
|
||||
exit $exit_code
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Prevent leftover old builds from being included in new build
|
||||
if [ -d $BUILD_DIR ]; then
|
||||
echo "Removing existing boilerplate/build directory..."
|
||||
rm -r "$BUILD_DIR"
|
||||
fi
|
||||
|
||||
# Prevent stale dependencies from being included in new build
|
||||
if [ -d "$BOILERPLATE_DIR/node_modules" ]; then
|
||||
echo "Removing existing boilerplate/node_modules directory..."
|
||||
rm -r "$BOILERPLATE_DIR/node_modules"
|
||||
fi
|
||||
|
||||
mkdir -p $BUILD_DIR
|
||||
|
||||
# Copy files
|
||||
cp "$CORE_DIR/include/zapierwrapper.js" "$BOILERPLATE_DIR/"
|
||||
|
||||
# Get core version
|
||||
if [ "$1" == "" ]; then
|
||||
pushd $CORE_DIR > /dev/null
|
||||
CORE_VERSION="$(node -p "require('./package.json').version")"
|
||||
popd > /dev/null
|
||||
else
|
||||
CORE_VERSION=$1
|
||||
fi
|
||||
|
||||
# core, schema, and cli are always published together, so they should use the same
|
||||
# version
|
||||
SCHEMA_VERSION=$CORE_VERSION
|
||||
|
||||
# Get legacy-scripting-runner version
|
||||
if [ "$2" == "" ]; then
|
||||
pushd $LSR_DIR > /dev/null
|
||||
LSR_VERSION="$(node -p "require('./package.json').version")"
|
||||
popd > /dev/null
|
||||
else
|
||||
LSR_VERSION=$2
|
||||
fi
|
||||
|
||||
TARGET_FILE="$BUILD_DIR/$CORE_VERSION.zip"
|
||||
rm -f $TARGET_FILE
|
||||
|
||||
# Build core and legacy-scripting-runner locally. Needs to generate a unique filename
|
||||
# with a timestamp to avoid the package manager using any cache.
|
||||
TIMESTAMP=`date +"%s"`
|
||||
CORE_PACK_FILENAME="core-$TIMESTAMP.tgz"
|
||||
SCHEMA_PACK_FILENAME="schema-$TIMESTAMP.tgz"
|
||||
LSR_PACK_FILENAME="lsr-$TIMESTAMP.tgz"
|
||||
|
||||
echo "Building..."
|
||||
|
||||
# Patch boilerplate's package.json with appropriate dependency versions
|
||||
if [ "$1" == "" ]; then
|
||||
echo "> core from local, version $CORE_VERSION"
|
||||
|
||||
pushd $CORE_DIR > /dev/null
|
||||
pnpm pack --out "$BOILERPLATE_DIR/$CORE_PACK_FILENAME"
|
||||
popd > /dev/null
|
||||
|
||||
# Also pack schema so core's transitive dependency resolves locally
|
||||
# instead of from npm (which may not have the current version yet)
|
||||
echo "> schema from local"
|
||||
pushd $SCHEMA_DIR > /dev/null
|
||||
pnpm pack --out "$BOILERPLATE_DIR/$SCHEMA_PACK_FILENAME"
|
||||
popd > /dev/null
|
||||
|
||||
if [ "$2" == "" ]; then
|
||||
echo "> legacy-scripting-runner from local, version $LSR_VERSION"
|
||||
|
||||
pushd $LSR_DIR > /dev/null
|
||||
pnpm pack --out "$BOILERPLATE_DIR/$LSR_PACK_FILENAME"
|
||||
popd > /dev/null
|
||||
|
||||
# Replace core and legacy-scripting-runner versions in package.json
|
||||
update_deps "$BOILERPLATE_DIR/package.json" "./$CORE_PACK_FILENAME" "./$LSR_PACK_FILENAME"
|
||||
else
|
||||
echo "> legacy-scripting-runner from npm, version $LSR_VERSION"
|
||||
|
||||
# Replace core and legacy-scripting-runner versions in package.json
|
||||
update_deps "$BOILERPLATE_DIR/package.json" "./$CORE_PACK_FILENAME" $LSR_VERSION
|
||||
fi
|
||||
else
|
||||
echo "> core from from npm, version $CORE_VERSION"
|
||||
|
||||
if [ "$2" == "" ]; then
|
||||
echo "> legacy-scripting-runner from local, version $LSR_VERSION"
|
||||
|
||||
pushd $LSR_DIR > /dev/null
|
||||
pnpm pack --out "$BOILERPLATE_DIR/$LSR_PACK_FILENAME"
|
||||
popd > /dev/null
|
||||
|
||||
# Replace core and legacy-scripting-runner versions in package.json
|
||||
update_deps "$BOILERPLATE_DIR/package.json" $CORE_VERSION "./$LSR_PACK_FILENAME"
|
||||
else
|
||||
echo "> legacy-scripting-runner from npm, version: $LSR_VERSION"
|
||||
|
||||
# Replace core and legacy-scripting-runner versions in package.json
|
||||
update_deps "$BOILERPLATE_DIR/package.json" $CORE_VERSION $LSR_VERSION
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install boilerplate deps
|
||||
pushd $BOILERPLATE_DIR > /dev/null
|
||||
echo "{\"version\": \"1.0.0\", \"platformVersion\": \"$CORE_VERSION\"}" > definition.json
|
||||
|
||||
# When building core from local, replace the placeholder in pnpm-workspace.yaml
|
||||
# with an override so schema resolves from the local tarball
|
||||
if [ "$1" == "" ]; then
|
||||
sed -i.bak "s|# OVERRIDES_PLACEHOLDER|overrides:\n zapier-platform-schema: \"./$SCHEMA_PACK_FILENAME\"|" pnpm-workspace.yaml
|
||||
fi
|
||||
|
||||
pnpm install --no-lockfile
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
# Monkey patch boilerplate package.json so zapier-platform-core and
|
||||
# zapier-platform-legacy-scripting-runner have version numbers specified instead
|
||||
# of local file path
|
||||
update_deps "$BOILERPLATE_DIR/package.json" $CORE_VERSION $LSR_VERSION
|
||||
|
||||
pushd $BOILERPLATE_DIR > /dev/null
|
||||
|
||||
# Build the zip!
|
||||
# the node-X segment in the next line should match the latest major version
|
||||
zip -9 -R $TARGET_FILE '*.js' '*.cjs' '*.json'
|
||||
|
||||
# Remove generated files
|
||||
rm -f zapierwrapper.js definition.json core-*.tgz schema-*.tgz lsr-*.tgz
|
||||
rm -rf node_modules
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
echo -e "\nDone! Here's your output zip file (size should be 4-6 MB normally):"
|
||||
ls -hl $TARGET_FILE
|
||||
|
||||
check_size $TARGET_FILE
|
||||
inspect_build $TARGET_FILE $CORE_VERSION $SCHEMA_VERSION $LSR_VERSION
|
||||
test_build $TARGET_FILE
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue