This document provides guidance for AI coding agents working in this repository.
This is @lando/pantheon, a Node.js Lando plugin that integrates with Pantheon hosting. It provides local development environments mimicking Pantheon's stack and commands to sync code, database, and files.
- Language: JavaScript (CommonJS, not ES modules)
- Node Version: >=20.0.0
- Style Guide: Google JavaScript Style Guide (via ESLint)
- Testing: Mocha + Chai
npm run lint # Run linter
npm run test:unit # Run all unit tests with coverage
npm run test # Run lint + unit tests together
npm run test:leia # Run integration tests (requires Lando)
# Run a single test file
npx mocha --timeout 5000 test/auth.spec.js
# Run tests matching a pattern
npx mocha --timeout 5000 --grep "pattern" test/**/*.spec.jsbuilders/ # Lando service builders (pantheon-*.js)
config/ # Configuration templates (.conf.tpl, .vcl, etc.)
lib/ # Core library code (auth, client, utils)
scripts/ # Shell scripts for containers
test/ # Unit tests (*.spec.js)
utils/ # Utility modules
examples/ # Leia fixtures. See examples/AGENTS.md — remote landobot sites use master, not main.
Every file must start with 'use strict'; followed by imports:
'use strict';
// Modules
const _ = require('lodash');
const fs = require('fs');
const {someFunc} = require('./lib/utils');- Use
constwithrequire()(CommonJS) - External/built-in modules first, then local modules
| Type | Convention | Examples |
|---|---|---|
| Variables | camelCase | siteInfo, configPath |
| Constants | SCREAMING_SNAKE_CASE | DRUSH_VERSION |
| Functions | camelCase, get/is prefix |
getHash, isWordPressy |
| Classes | PascalCase | PantheonApiClient |
| Files | kebab-case | pantheon-mariadb.js |
- Indentation: 2 spaces
- Max line length: 140 characters
- Quotes: Single quotes
- Semicolons: Required
- Arrow parens: Omit when possible (
x => x)
Function declarations MUST have JSDoc comments:
/**
* Gets framework-specific tooling configuration
* @param {string} framework - Framework type
* @param {number} [drush=8] - Drush version
* @return {Object} Tooling configuration
*/
const getTooling = (framework, drush = 8) => { };try {
await api.auth();
} catch (error) {
throw (_.has(error, 'response.data')) ? new Error(error.response.data) : error;
}This codebase heavily uses Lodash. Prefer Lodash methods:
_.get(options, 'search.version', '3') // Safe property access
_.merge({}, config, options) // Deep merge
_.has(err, 'response.data') // Check property existsmodule.exports = async (app, lando) => { };
module.exports = class PantheonApiClient { };
module.exports = {
name: 'pantheon',
builder: (parent, config) => class extends parent { },
};
exports.getPantheonConfig = () => { };// Modules // Section headers
// @NOTE: explanation... // Notes
// @TODO: task description // TODOsTest files: test/*.spec.js using Mocha + Chai:
'use strict';
const chai = require('chai');
chai.should();
describe('ModuleName', () => {
describe('#methodName', () => {
it('should do something expected', () => {
result.should.equal(expected);
});
});
});lodash- Utility functions (use extensively)axios- HTTP client for Pantheon APIjs-yaml- YAML parsing@lando/*- Lando service plugins
path.join(options.root, 'pantheon.yml')
path.resolve(__dirname, '..', 'config')builder: (parent, config) => class LandoPantheon extends parent {
constructor(id, options = {}) {
options = _.merge({}, config, options, utils.getPantheonConfig());
super(id, options);
}
}