diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 27cfbc62..728a8c1c 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -9,8 +9,8 @@
# This also holds true for GitHub teams.
# Rescript
-*.res @OAGr @quinn-dougherty
-*.resi @OAGr @quinn-dougherty
+*.res @OAGr
+*.resi @OAGr
# Typescript
*.tsx @Hazelfire @OAGr
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 9c9c86c3..4e459652 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -8,6 +8,13 @@ updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
- interval: "daily"
+ interval: "weekly"
+ commit-message:
+ prefix: "⬆️"
+ open-pull-requests-limit: 100
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
commit-message:
prefix: "⬆️"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index acd96119..8150d00a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,22 +19,34 @@ jobs:
should_skip_lang: ${{ steps.skip_lang_check.outputs.should_skip }}
should_skip_components: ${{ steps.skip_components_check.outputs.should_skip }}
should_skip_website: ${{ steps.skip_website_check.outputs.should_skip }}
+ should_skip_vscodeext: ${{ steps.skip_vscodeext_check.outputs.should_skip }}
+ should_skip_cli: ${{ steps.skip_cli_check.outputs.should_skip }}
steps:
- id: skip_lang_check
name: Check if the changes are about squiggle-lang src files
- uses: fkirc/skip-duplicate-actions@v3.4.1
+ uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/squiggle-lang/**"]'
- id: skip_components_check
name: Check if the changes are about components src files
- uses: fkirc/skip-duplicate-actions@v3.4.1
+ uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/components/**"]'
- id: skip_website_check
name: Check if the changes are about website src files
- uses: fkirc/skip-duplicate-actions@v3.4.1
+ uses: fkirc/skip-duplicate-actions@v4.0.0
with:
paths: '["packages/website/**"]'
+ - id: skip_vscodeext_check
+ name: Check if the changes are about vscode extension src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/vscode-ext/**"]'
+ - id: skip_cli_check
+ name: Check if the changes are about cli src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/cli/**"]'
lang-lint:
name: Language lint
@@ -46,7 +58,7 @@ jobs:
shell: bash
working-directory: packages/squiggle-lang
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Install Dependencies
run: cd ../../ && yarn
- name: Check rescript lint
@@ -67,7 +79,9 @@ jobs:
shell: bash
working-directory: packages/squiggle-lang
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 2
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript codebase
@@ -93,12 +107,12 @@ jobs:
shell: bash
working-directory: packages/components
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with:
dry: true
- prettier_options: --check packages/components
+ prettier_options: --check packages/components --ignore-path packages/components/.prettierignore
components-bundle-build:
name: Components bundle and build
@@ -110,7 +124,7 @@ jobs:
shell: bash
working-directory: packages/components
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript codebase in squiggle-lang
@@ -130,7 +144,7 @@ jobs:
shell: bash
working-directory: packages/website
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Check javascript, typescript, and markdown lint
uses: creyD/prettier_action@v4.2
with:
@@ -147,10 +161,61 @@ jobs:
shell: bash
working-directory: packages/website
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3
- name: Install dependencies from monorepo level
run: cd ../../ && yarn
- name: Build rescript in squiggle-lang
run: cd ../squiggle-lang && yarn build
+ - name: Build components
+ run: cd ../components && yarn build
- name: Build website assets
run: yarn build
+
+ vscode-ext-lint:
+ name: VS Code extension lint
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_vscodeext != 'true' }}
+ defaults:
+ run:
+ shell: bash
+ working-directory: packages/vscode-ext
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies from monorepo level
+ run: cd ../../ && yarn
+ - name: Lint the VSCode Extension source code
+ run: yarn lint
+
+ vscode-ext-build:
+ name: VS Code extension build
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ (needs.pre_check.outputs.should_skip_components != 'true') || (needs.pre_check.outputs.should_skip_lang != 'true') }} || (needs.pre_check.outputs.should_skip_vscodeext != 'true') }}
+ defaults:
+ run:
+ shell: bash
+ working-directory: packages/vscode-ext
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies from monorepo level
+ run: cd ../../ && yarn
+ - name: Build
+ run: yarn compile
+
+ cli-lint:
+ name: CLI lint
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_cli != 'true' }}
+ defaults:
+ run:
+ shell: bash
+ working-directory: packages/cli
+ steps:
+ - uses: actions/checkout@v3
+ - name: Check javascript, typescript, and markdown lint
+ uses: creyD/prettier_action@v4.2
+ with:
+ dry: true
+ prettier_options: --check packages/cli
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 2aef3ae3..f7b7cfe7 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -12,12 +12,6 @@
name: "CodeQL"
on:
- push:
- branches:
- - master
- - production
- - staging
- - develop
schedule:
- cron: "42 19 * * 0"
@@ -39,11 +33,11 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v1
+ uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +48,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
- uses: github/codeql-action/autobuild@v1
+ uses: github/codeql-action/autobuild@v2
- name: Install dependencies
run: yarn
- name: Build rescript
@@ -71,4 +65,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
new file mode 100644
index 00000000..f4bbbf9e
--- /dev/null
+++ b/.github/workflows/release-please.yml
@@ -0,0 +1,140 @@
+name: Run Release Please
+
+on:
+ push:
+ branches:
+ - develop
+
+jobs:
+ pre_check:
+ name: Precheck for skipping redundant jobs
+ runs-on: ubuntu-latest
+ outputs:
+ should_skip_lang: ${{ steps.skip_lang_check.outputs.should_skip }}
+ should_skip_components: ${{ steps.skip_components_check.outputs.should_skip }}
+ should_skip_website: ${{ steps.skip_website_check.outputs.should_skip }}
+ should_skip_vscodeext: ${{ steps.skip_vscodeext_check.outputs.should_skip }}
+ should_skip_cli: ${{ steps.skip_cli_check.outputs.should_skip }}
+ steps:
+ - id: skip_lang_check
+ name: Check if the changes are about squiggle-lang src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/squiggle-lang/**"]'
+ - id: skip_components_check
+ name: Check if the changes are about components src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/components/**"]'
+ - id: skip_website_check
+ name: Check if the changes are about website src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/website/**"]'
+ - id: skip_vscodeext_check
+ name: Check if the changes are about vscode extension src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/vscode-ext/**"]'
+ - id: skip_cli_check
+ name: Check if the changes are about cli src files
+ uses: fkirc/skip-duplicate-actions@v4.0.0
+ with:
+ paths: '["packages/cli/**"]'
+
+ relplz-lang:
+ name: for squiggle-lang
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_lang != 'true' }}
+ steps:
+ - name: Release please (squiggle-lang)
+ uses: google-github-actions/release-please-action@v3
+ id: release
+ with:
+ token: ${{secrets.GITHUB_TOKEN}}
+ command: manifest-pr
+ path: packages/squiggle-lang
+ bump-patch-for-minor-pre-major: true
+ skip-github-release: true
+ # - name: Publish: Checkout source
+ # uses: actions/checkout@v2
+ # # these if statements ensure that a publication only occurs when
+ # # a new release is created:
+ # if: ${{ steps.release.outputs.release_created }}
+ # - name: Publish: Install dependencies
+ # run: yarn
+ # if: ${{ steps.release.outputs.release_created }}
+ # - name: Publish
+ # run: cd packages/squiggle-lang && yarn publish
+ # env:
+ # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
+ # if: ${{ steps.release.outputs.release_created }}
+ relplz-components:
+ name: for components
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_components != 'true' }}
+ steps:
+ - name: Release please (components)
+ uses: google-github-actions/release-please-action@v3
+ with:
+ token: ${{secrets.GITHUB_TOKEN}}
+ command: manifest-pr
+ path: packages/components
+ bump-patch-for-minor-pre-major: true
+ skip-github-release: true
+ # - name: Publish: Checkout source
+ # uses: actions/checkout@v2
+ # # these if statements ensure that a publication only occurs when
+ # # a new release is created:
+ # if: ${{ steps.release.outputs.release_created }}
+ # - name: Publish: Install dependencies
+ # run: yarn
+ # if: ${{ steps.release.outputs.release_created }}
+ # - name: Publish
+ # run: cd packages/components && yarn publish
+ # env:
+ # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
+ relplz-website:
+ name: for website
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_website != 'true' }}
+ steps:
+ - name: Release please (website)
+ uses: google-github-actions/release-please-action@v3
+ with:
+ token: ${{secrets.GITHUB_TOKEN}}
+ command: manifest-pr
+ path: packages/website
+ bump-patch-for-minor-pre-major: true
+ skip-github-release: true
+ relplz-vscodeext:
+ name: for vscode-ext
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_vscodeext != 'true' }}
+ steps:
+ - name: Release please (vscode-ext)
+ uses: google-github-actions/release-please-action@v3
+ with:
+ token: ${{secrets.GITHUB_TOKEN}}
+ command: manifest-pr
+ path: packages/vscode-ext
+ bump-patch-for-minor-pre-major: true
+ skip-github-release: true
+ relplz-cl:
+ name: for cli
+ runs-on: ubuntu-latest
+ needs: pre_check
+ if: ${{ needs.pre_check.outputs.should_skip_cli != 'true' }}
+ steps:
+ - name: Release please (cli)
+ uses: google-github-actions/release-please-action@v3
+ with:
+ token: ${{secrets.GITHUB_TOKEN}}
+ command: manifest-pr
+ path: packages/cli
+ bump-patch-for-minor-pre-major: true
+ skip-github-release: true
diff --git a/.prettierignore b/.prettierignore
index 54df33a4..8090b3f3 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -11,3 +11,5 @@ packages/squiggle-lang/.nyc_output/
packages/squiggle-lang/coverage/
packages/squiggle-lang/.cache/
packages/website/build/
+packages/squiggle-lang/src/rescript/Reducer/Reducer_Peggy/Reducer_Peggy_GeneratedParser.js
+packages/vscode-ext/media/vendor/
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
new file mode 100644
index 00000000..1f1ac6f3
--- /dev/null
+++ b/.release-please-manifest.json
@@ -0,0 +1,7 @@
+{
+ "packages/cli": "0.0.3",
+ "packages/components": "0.3.1",
+ "packages/squiggle-lang": "0.3.0",
+ "packages/vscode-ext": "0.3.1",
+ "packages/website": "0.3.0"
+}
diff --git a/README.md b/README.md
index 137fb1cb..e182f539 100644
--- a/README.md
+++ b/README.md
@@ -12,11 +12,12 @@ _An estimation language_.
- [Gallery](https://www.squiggle-language.com/docs/Discussions/Gallery)
- [Squiggle playground](https://squiggle-language.com/playground)
-- [Language basics](https://www.squiggle-language.com/docs/Features/Language)
-- [Squiggle functions source of truth](https://www.squiggle-language.com/docs/Features/Functions)
+- [Language basics](https://www.squiggle-language.com/docs/Guides/Language)
+- [Squiggle functions source of truth](https://www.squiggle-language.com/docs/Guides/Functions)
- [Known bugs](https://www.squiggle-language.com/docs/Discussions/Bugs)
- [Original lesswrong sequence](https://www.lesswrong.com/s/rDe8QE5NvXcZYzgZ3)
- [Author your squiggle models as Observable notebooks](https://observablehq.com/@hazelfire/squiggle)
+- [Use squiggle in VS Code](https://marketplace.visualstudio.com/items?itemName=QURI.vscode-squiggle)
## Our deployments
@@ -39,8 +40,8 @@ the packages can be found in `packages`.
of the calculation.
- `packages/website` is the main descriptive website for squiggle,
it is hosted at `squiggle-language.com`.
-
-The playground depends on the components library which then depends on the language. This means that if you wish to work on the components library, you will need to build (no need to bundle) the language, and as of this writing playground doesn't really work.
+- `packages/vscode-ext` is the VS Code extension for writing estimation functions.
+- `packages/cli` is an experimental way of using imports in squiggle, which is also on [npm](https://www.npmjs.com/package/squiggle-cli-experimental).
# Develop
diff --git a/package.json b/package.json
index 9db41bf5..dcab983e 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"lint:all": "prettier --check . && cd packages/squiggle-lang && yarn lint:rescript"
},
"devDependencies": {
- "prettier": "^2.6.2"
+ "prettier": "^2.7.1"
},
"workspaces": [
"packages/*"
diff --git a/packages/cli/.gitignore b/packages/cli/.gitignore
new file mode 100644
index 00000000..03087060
--- /dev/null
+++ b/packages/cli/.gitignore
@@ -0,0 +1,4 @@
+## Artifacts
+*.swp
+/node_modules/
+yarn-error.log
\ No newline at end of file
diff --git a/packages/cli/README.md b/packages/cli/README.md
new file mode 100644
index 00000000..7b0d0038
--- /dev/null
+++ b/packages/cli/README.md
@@ -0,0 +1,22 @@
+## Squiggle CLI
+
+This package can be used to incorporate a very simple `import` system into Squiggle.
+
+To use, write special files with a `.squiggleU` file type. In these files, you can write lines like,
+
+```
+@import(models/gdp_over_time.squiggle, gdpOverTime)
+gdpOverTime(2.5)
+```
+
+The imports will be replaced with the contents of the file in `models/gdp_over_time.squiggle` upon compilation. The `.squiggleU` file will be converted into a `.squiggle` file with the `import` statement having this replacement.
+
+## Running
+
+### `npx squiggle-cli-experimental compile`
+
+Runs compilation in the current directory and all of its subdirectories.
+
+### `npx squiggle-cli-experimental watch`
+
+Watches `.squiggleU` files in the current directory (and subdirectories) and rebuilds them when they are saved. Note that this will _not_ rebuild files when their dependencies are changed, just when they are changed directly.
diff --git a/packages/cli/index.js b/packages/cli/index.js
new file mode 100755
index 00000000..95956b86
--- /dev/null
+++ b/packages/cli/index.js
@@ -0,0 +1,96 @@
+#!/usr/bin/env node
+
+import fs from "fs";
+import path from "path";
+import indentString from "indent-string";
+import chokidar from "chokidar";
+import chalk from "chalk";
+import { Command } from "commander";
+import glob from "glob";
+
+const processFile = (fileName, seen = []) => {
+ const normalizedFileName = path.resolve(fileName);
+ if (seen.includes(normalizedFileName)) {
+ throw new Error(`Recursive dependency for file ${fileName}`);
+ }
+
+ const fileContents = fs.readFileSync(fileName, "utf-8");
+ if (!fileName.endsWith(".squiggleU")) {
+ return fileContents;
+ }
+
+ const regex = /\@import\(\s*([^)]+?)\s*\)/g;
+ const matches = Array.from(fileContents.matchAll(regex)).map((r) =>
+ r[1].split(/\s*,\s*/)
+ );
+ const newContent = fileContents.replaceAll(regex, "");
+ const appendings = [];
+
+ matches.forEach((r) => {
+ const importFileName = r[0];
+ const rename = r[1];
+ const item = fs.statSync(importFileName);
+ if (item.isFile()) {
+ const data = processFile(importFileName, [...seen, normalizedFileName]);
+ if (data) {
+ const importString = `${rename} = {\n${indentString(data, 2)}\n}\n`;
+ appendings.push(importString);
+ }
+ } else {
+ console.log(
+ chalk.red(`Import Error`) +
+ `: ` +
+ chalk.cyan(importFileName) +
+ ` not found in file ` +
+ chalk.cyan(fileName) +
+ `. Make sure the @import file names all exist in this repo.`
+ );
+ }
+ });
+ const imports = appendings.join("\n");
+
+ const newerContent = imports.concat(newContent);
+ return newerContent;
+};
+
+const run = (fileName) => {
+ const content = processFile(fileName);
+ const parsedPath = path.parse(path.resolve(fileName));
+ const newFilename = `${parsedPath.dir}/${parsedPath.name}.squiggle`;
+ fs.writeFileSync(newFilename, content);
+ console.log(chalk.cyan(`Updated ${fileName} -> ${newFilename}`));
+};
+
+const compile = () => {
+ glob("**/*.squiggleU", (_err, files) => {
+ files.forEach(run);
+ });
+};
+
+const watch = () => {
+ chokidar
+ .watch("**.squiggleU")
+ .on("ready", () => console.log(chalk.green("Ready!")))
+ .on("change", (event, _) => {
+ run(event);
+ });
+};
+
+const program = new Command();
+
+program
+ .name("squiggle-utils")
+ .description("CLI to transform squiggle files with @imports")
+ .version("0.0.1");
+
+program
+ .command("watch")
+ .description("watch files and compile on the fly")
+ .action(watch);
+
+program
+ .command("compile")
+ .description("compile all .squiggleU files into .squiggle files")
+ .action(compile);
+
+program.parse();
diff --git a/packages/cli/package.json b/packages/cli/package.json
new file mode 100644
index 00000000..2890d2a4
--- /dev/null
+++ b/packages/cli/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "squiggle-cli-experimental",
+ "version": "0.0.3",
+ "main": "index.js",
+ "homepage": "https://squiggle-language.com",
+ "author": "Quantified Uncertainty Research Institute",
+ "bin": "index.js",
+ "type": "module",
+ "scripts": {
+ "start": "node ."
+ },
+ "license": "MIT",
+ "dependencies": {
+ "chalk": "^5.0.1",
+ "chokidar": "^3.5.3",
+ "commander": "^9.4.0",
+ "fs": "^0.0.1-security",
+ "glob": "^8.0.3",
+ "indent-string": "^5.0.0"
+ }
+}
diff --git a/packages/components/.prettierignore b/packages/components/.prettierignore
index 5e03c80e..af9301cf 100644
--- a/packages/components/.prettierignore
+++ b/packages/components/.prettierignore
@@ -1,2 +1,4 @@
dist/
storybook-static
+src/styles/base.css
+src/styles/forms.css
diff --git a/packages/components/.storybook/preview.js b/packages/components/.storybook/preview.js
index f089c7f9..a128782c 100644
--- a/packages/components/.storybook/preview.js
+++ b/packages/components/.storybook/preview.js
@@ -1,3 +1,15 @@
+import "../src/styles/main.css";
+import "!style-loader!css-loader!postcss-loader!../src/styles/main.css";
+import { SquiggleContainer } from "../src/components/SquiggleContainer";
+
+export const decorators = [
+ (Story) => (
+
Loading...
, + ssr: false, + } +); + +export function DynamicSquiggleChart({ squiggleString }) { + if (squiggleString == "") { + return null; + } else { + return ( +{children}
+); diff --git a/packages/components/src/components/ui/Toggle.tsx b/packages/components/src/components/ui/Toggle.tsx new file mode 100644 index 00000000..bbf9a5ee --- /dev/null +++ b/packages/components/src/components/ui/Toggle.tsx @@ -0,0 +1,47 @@ +import { RefreshIcon } from "@heroicons/react/solid"; +import clsx from "clsx"; +import React from "react"; + +type IconType = (props: React.ComponentProps<"svg">) => JSX.Element; + +type Props = { + status: boolean; + onChange: (status: boolean) => void; + texts: [string, string]; + icons: [IconType, IconType]; + spinIcon?: boolean; +}; + +export const Toggle: React.FC