Skip to content

Commit

Permalink
Merge pull request #2497 from evidence-dev/release-2024-09-05
Browse files Browse the repository at this point in the history
Release 2024 09 05
  • Loading branch information
kwongz authored Sep 5, 2024
2 parents 330532a + 3a6273a commit 3b318f4
Show file tree
Hide file tree
Showing 66 changed files with 1,320 additions and 225 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-items-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/preprocess': patch
---

properly typecheck .cjs/.js files in preprocess
5 changes: 5 additions & 0 deletions .changeset/fast-otters-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/universal-sql': patch
---

Set 644 permissions when writing parquet files
5 changes: 5 additions & 0 deletions .changeset/few-beds-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

fixed boxplot duplicates
5 changes: 5 additions & 0 deletions .changeset/hip-zoos-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/evidence': patch
---

preview command uses VITE_EVIDENCE_SPA environment variable to serve build in SPA mode
5 changes: 5 additions & 0 deletions .changeset/rich-chairs-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/components': patch
---

Added scroll-to for prop sections in docs
7 changes: 7 additions & 0 deletions .changeset/rotten-lies-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@evidence-dev/evidence': patch
'@evidence-dev/preprocess': patch
'@evidence-dev/sdk': patch
---

Fix noisy "Failed to pre-render columns" log during build
5 changes: 5 additions & 0 deletions .changeset/strong-cheetahs-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/component-utilities': patch
---

Add hmr error handling for reserved words query names
5 changes: 5 additions & 0 deletions .changeset/two-carrots-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

selected tabs with id prop selection persist on refresh/link shared
5 changes: 5 additions & 0 deletions .changeset/wise-games-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@evidence-dev/core-components': patch
---

added default values for queries in button groups
2 changes: 1 addition & 1 deletion e2e/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dev": "evidence dev --open /",
"sources": "evidence sources",
"preview": "evidence preview",
"test:preview": "cross-env playwright test",
"test:preview": "playwright test",
"test:dev": "cross-env DEV=true playwright test"
},
"engines": {
Expand Down
Empty file added e2e/basic/sources/.gitkeep
Empty file.
5 changes: 0 additions & 5 deletions e2e/basic/sources/needful_things/connection.yaml

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion e2e/basic/sources/needful_things/orders.sql

This file was deleted.

156 changes: 156 additions & 0 deletions e2e/create-e2e-project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/usr/bin/env node

import { spawn } from 'node:child_process';
import { readFile, writeFile, unlink, mkdir } from 'node:fs/promises';
import chalk from 'chalk';
import sade from 'sade';
import ora from 'ora';

/** @typedef {import('child_process').SpawnOptions} SpawnOptions */

// prettier-ignore
const playwrightConfig =
`import { defineConfig } from '@playwright/test';
import { config } from '../playwright-config';
export default defineConfig(config);`

// prettier-ignore
const defaultTestFile =
`// @ts-check
import { test, expect } from '@playwright/test';
import { waitForDevModeToLoad } from '../../test-utils';
test('has title', async ({ page }) => {
await page.goto('/');
await waitForDevModeToLoad(page);
await expect(page).toHaveTitle(/Welcome to Evidence/);
});`

const testScripts = {
test: undefined,
'test:preview': 'playwright test',
'test:dev': 'cross-env DEV=true playwright test'
};

/** @type {Partial<SpawnOptions>} */
const globalSpawnOpts = {
shell: true
};

/**
* @param {string} command
* @param {SpawnOptions} options
*/
const spawnAsync = async (command, options) => {
return new Promise((resolve, reject) => {
const child = spawn(command, {
...globalSpawnOpts,
...options
});

child.on('exit', (code) => {
if (code === 0) {
resolve();
} else {
reject();
}
});
});
};

/**
*
* @param {string} path
* @param {(packageJson: any) => any} updater
* @returns {Promise<void>}
*/
const updatePackageJson = async (path, updater) => {
const rawPackageJson = await readFile(path, 'utf-8');
const packageJson = JSON.parse(rawPackageJson);
const modifiedPackageJson = updater(packageJson);
await writeFile(path, JSON.stringify(modifiedPackageJson, null, '\t'));
};

/**
* @param {string} name
* @param {{ debug?: boolean }} options
*/
const run = async (name, options) => {
const { debug } = options;

const spinner = ora({ isEnabled: !debug });

try {
globalSpawnOpts.stdio = debug ? 'inherit' : 'ignore';

spinner.start('Cloning template...');
await spawnAsync(`npx degit https://github.com/evidence-dev/template ${name}`);
spinner.stopAndPersist({ symbol: '✔ ', text: 'Cloned template' });

spinner.start('Modifying package.json...');
await updatePackageJson(`${name}/package.json`, (packageJson) => {
const dependencies = packageJson.dependencies ?? {};
Object.entries(dependencies).forEach(([name, version]) => {
if (name.startsWith('@evidence-dev/')) {
dependencies[name] = 'workspace:*';
} else {
dependencies[name] = version;
}
});
return {
...packageJson,
name: `e2e-${name}`,
private: true,
dependencies,
scripts: {
...packageJson.scripts,
...testScripts
}
};
});
spinner.stopAndPersist({ symbol: '✔ ', text: 'Modified package.json' });

spinner.start('Installing dependencies...');
await unlink(`${name}/package-lock.json`);
await spawnAsync(`pnpm i -D cross-env --ignore-scripts`, { cwd: name });
// TODO the bulk of the time running this command is spent running our postinstall script, which is unnecessary
await spawnAsync(
`pnpm create playwright@latest --lang=js --no-browsers --no-examples --quiet`,
{ cwd: name }
);
spinner.stopAndPersist({ symbol: '✔ ', text: 'Installed dependencies' });

spinner.start('Configuring playwright...');
await writeFile(`${name}/playwright.config.js`, playwrightConfig);
spinner.stopAndPersist({ symbol: '✔ ', text: 'Configured playwright' });

spinner.start('Creating test file...');
await mkdir(`${name}/tests`);
await writeFile(`${name}/tests/tests.spec.js`, defaultTestFile);
spinner.stopAndPersist({ symbol: '✔ ', text: 'Created test file' });

spinner.start('Formatting files...');
await spawnAsync(`pnpm format`, { cwd: '..' });
spinner.stopAndPersist({ symbol: '✔ ', text: 'Formatted files' });

console.log(chalk.green(`\nE2E Test Project '${name}' created successfully!`));
console.log(chalk.dim(`Use test:dev and test:preview to run your tests`));
} catch (e) {
spinner.stopAndPersist({ symbol: '❌' });
console.error(chalk.red('An error occurred while creating the project'));
if (e) {
console.error(e);
}
}
};

//////////////////////////////////////////

sade('create-e2e-project <name>')
.describe('Create a new Evidence project from the template that is ready for E2E testing')
.option('--debug', 'Enable debug mode')
.example('my-tests')
.action(run)
.parse(process.argv);
3 changes: 3 additions & 0 deletions e2e/hmr/pages/error-handling/reserved-word-query-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```sql my_query
select 1
```
14 changes: 14 additions & 0 deletions e2e/hmr/tests/tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,17 @@ test.describe('sources', () => {
await expect(page.getByText('Loaded 100 orders')).toBeVisible();
});
});

test.describe('error handling', () => {
test('reserved word in query name', async ({ page }) => {
await page.goto('/error-handling/reserved-word-query-name/');

await waitForDevModeToLoad(page);

editFile('pages/error-handling/reserved-word-query-name.md', (content) =>
content.replace('my_query', 'new')
);

await expect(page.getByText('"new" cannot be used as a query name')).toBeVisible();
});
});
5 changes: 4 additions & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"private": true,
"type": "module",
"devDependencies": {
"@playwright/test": "^1.45.3"
"@playwright/test": "^1.45.3",
"chalk": "^5.3.0",
"ora": "^8.1.0",
"sade": "^1.8.1"
}
}
14 changes: 14 additions & 0 deletions e2e/spa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.evidence/template
.svelte-kit
build
node_modules
.DS_Store
static/data
*.options.yaml
.vscode/settings.json
.env
.evidence/meta
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
3 changes: 3 additions & 0 deletions e2e/spa/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
loglevel=error
audit=false
fund=false
44 changes: 44 additions & 0 deletions e2e/spa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Evidence Template Project

## Using Codespaces

If you are using this template in Codespaces, click the `Start Evidence` button in the bottom status bar. This will install dependencies and open a preview of your project in your browser - you should get a popup prompting you to open in browser.

Or you can use the following commands to get started:

```bash
npm install
npm run sources
npm run dev -- --host 0.0.0.0
```

See [the CLI docs](https://docs.evidence.dev/cli/) for more command information.

**Note:** Codespaces is much faster on the Desktop app. After the Codespace has booted, select the hamburger menu → Open in VS Code Desktop.

## Get Started from VS Code

The easiest way to get started is using the [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=evidence-dev.evidence):

1. Install the extension from the VS Code Marketplace
2. Open the Command Palette (Ctrl/Cmd + Shift + P) and enter `Evidence: New Evidence Project`
3. Click `Start Evidence` in the bottom status bar

## Get Started using the CLI

```bash
npx degit evidence-dev/template my-project
cd my-project
npm install
npm run sources
npm run dev
```

Check out the docs for [alternative install methods](https://docs.evidence.dev/getting-started/install-evidence) including Docker, Github Codespaces, and alongside dbt.

## Learning More

- [Docs](https://docs.evidence.dev/)
- [Github](https://github.com/evidence-dev/evidence)
- [Slack Community](https://slack.evidence.dev/)
- [Evidence Home Page](https://www.evidence.dev)
20 changes: 20 additions & 0 deletions e2e/spa/evidence.plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

components:
# This loads all of evidence's core charts and UI components
# You probably don't want to edit this dependency unless you know what you are doing
"@evidence-dev/core-components": {}

datasources:
# You can add additional datasources here by adding npm packages.
# Make to also add them to `package.json`.
"@evidence-dev/bigquery": { }
"@evidence-dev/csv": { }
"@evidence-dev/databricks": { }
"@evidence-dev/duckdb": { }
"@evidence-dev/mssql": { }
"@evidence-dev/mysql": { }
"@evidence-dev/postgres": { }
"@evidence-dev/snowflake": { }
"@evidence-dev/sqlite": { }
"@evidence-dev/trino": { }
"@evidence-dev/motherduck": { }
45 changes: 45 additions & 0 deletions e2e/spa/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "e2e-spa",
"version": "0.0.1",
"scripts": {
"build": "cross-env VITE_EVIDENCE_SPA=true evidence build",
"build:strict": "cross-env VITE_EVIDENCE_SPA=true evidence build:strict",
"dev": "evidence dev --open /",
"sources": "evidence sources",
"preview": "cross-env VITE_EVIDENCE_SPA=true evidence preview",
"test:preview": "playwright test",
"test:dev": "echo e2e/spa has no dev mode tests"
},
"engines": {
"npm": ">=7.0.0",
"node": ">=18.0.0"
},
"type": "module",
"dependencies": {
"@evidence-dev/bigquery": "workspace:*",
"@evidence-dev/core-components": "workspace:*",
"@evidence-dev/csv": "workspace:*",
"@evidence-dev/databricks": "workspace:*",
"@evidence-dev/duckdb": "workspace:*",
"@evidence-dev/evidence": "workspace:*",
"@evidence-dev/motherduck": "workspace:*",
"@evidence-dev/mssql": "workspace:*",
"@evidence-dev/mysql": "workspace:*",
"@evidence-dev/postgres": "workspace:*",
"@evidence-dev/snowflake": "workspace:*",
"@evidence-dev/sqlite": "workspace:*",
"@evidence-dev/trino": "workspace:*"
},
"overrides": {
"jsonwebtoken": "9.0.0",
"trim@<0.0.3": ">0.0.3",
"sqlite3": "5.1.5",
"axios": "^1.7.4"
},
"private": true,
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/node": "^22.5.4",
"cross-env": "^7.0.3"
}
}
1 change: 1 addition & 0 deletions e2e/spa/pages/[param].md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This page uses a query param: {params.param}
1 change: 1 addition & 0 deletions e2e/spa/pages/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Index
Loading

0 comments on commit 3b318f4

Please sign in to comment.