Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz committed Oct 24, 2021
2 parents 56dc878 + 97c33cb commit 183a7bb
Show file tree
Hide file tree
Showing 93 changed files with 18,442 additions and 3,348 deletions.
36 changes: 27 additions & 9 deletions .codesandbox/devtools.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
{
"previews": {
"3000": {
"name": "Playground",
"script": "yarn workspace @codesandbox/sandpack-playground dev"
},
"6006": {
"name": "Storybook",
"script": "yarn workspace @codesandbox/sandpack-react storybook"
}
"previews": {
"1234": {
"name": "Playground",
"command": "yarn workspace @codesandbox/sandpack-playground dev"
},
"6006": {
"name": "Storybook",
"command": "yarn workspace @codesandbox/sandpack-react storybook"
},
"3000": {
"name": "Docs",
"command": "yarn dev:docs"
}
},
"tasks": {
"setup": {
"name": "Install Dependencies",
"command": "yarn"
},
"build": {
"name": "Build Workspace",
"command": "yarn build"
},
"format": {
"name": "Format Workspace",
"command": "yarn format"
}
}
}
12 changes: 12 additions & 0 deletions .codesandbox/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"setupTasks": [
{
"name": "Installing Dependencies",
"command": "yarn install"
},
{
"name": "Building Workspace",
"command": "yarn build"
}
]
}
10 changes: 10 additions & 0 deletions .codesandbox/workspace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"default": {
"name": "Default",
"type": "SIDEKICK",
"items": [
{ "type": "PREVIEW", "port": "3000" },
{ "type": "PREVIEW", "port": "6006" }
]
}
}
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: 🐛 Bug Report
about: What went wrong?
title: 'Bug: '
labels: 'bug'
---

# Bug report

## Packages affected

- [ ] sandpack-client
- [ ] sandpack-react

## Description of the problem

## What were you doing when the problem occurred?

### What steps can we take to reproduce the problem?

<!--
Your best chance of getting this bug looked at quickly is to provide an example.
-->

### Link to sandbox: [link]() (optional)

### Your Environment

| Software | Name/Version |
| ----------------------- | ------------ |
| Sandpack-client version | |
| Sandpack-react version | |
| Browser | |
| Operating System | |
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/DOCUMENTATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: 📃 Documentation
about: Report an issue related to documentation
title: 'Documentation: '
labels: 'documentation'
---
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: 🌈 Feature
about: What cool thing would you like to add?
title: 'Feature request: '
labels: 'feature request'
---

# Tell us how you think we can improve Sandpack

## Packages affected

- [ ] sandpack-client
- [ ] sandpack-react

## What is this feature?

## How would your idea work?

## Do you have any examples of how you would like to see us implement it?
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
contact_links:
- name: Question
url: https://github.com/codesandbox/sandpack/discussions
about: Have any questions?
30 changes: 30 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## What kind of change does this pull request introduce?

<!-- Is it a Bug fix, feature, documentation update... -->

## What is the current behavior?

<!-- You can also link to an open issue here -->

## What is the new behavior?

<!-- if this is a feature change -->

## What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated.

1. Step A
2. Step B
3. Step C

## Checklist

<!-- Have you done all of these things? -->
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->

- [ ] Documentation
- [ ] Ready to be merged
<!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->

<!-- feel free to add additional comments -->
<!-- Thank you for contributing! -->
13 changes: 11 additions & 2 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ jobs:
- name: Setup | Install dependencies
run: yarn

- name: Prepare | Build dependencies
run: yarn build:deps

- name: Prepare | Build sandpack bundler
run: yarn build:sandpack

Expand Down Expand Up @@ -59,7 +62,11 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: "12.22.4"
registry-url: "https://npm.pkg.github.com/"

- name: Setup | Authenticate with Registry
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Setup | Configure git user
run: |
Expand All @@ -81,7 +88,9 @@ jobs:
path: bundler

- name: Prepare | Build
run: yarn run build:publish
run: |
yarn workspace @codesandbox/sandpack-client build:publish
yarn workspace @codesandbox/sandpack-react build:publish
- name: Release | Lerna Publish
run: lerna publish from-package --yes --canary #TODO - remove canary
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Prepare | Build dependencies
run: yarn build:deps

- name: Prepare | Build sandpack bundler
- name: Prepare | Build CodeSandbox bundler
run: yarn build:sandpack

- name: Archive bundler artifacts
Expand All @@ -59,7 +59,11 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: "12.22.4"
registry-url: "https://npm.pkg.github.com/"

- name: Setup | Authenticate with Registry
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Setup | Configure git user
run: |
Expand All @@ -81,7 +85,9 @@ jobs:
path: bundler

- name: Prepare | Build
run: yarn run build:publish
run: |
yarn workspace @codesandbox/sandpack-client build:publish
yarn workspace @codesandbox/sandpack-react build:publish
- name: Release | Lerna Publish
run: lerna publish from-package --yes --canary #TODO - remove canary
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{}
{
}
2 changes: 1 addition & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
`eslint ${filenames.join(" ")} --quiet --fix`,
`prettier --write ${filenames.join(" ")}`,
],
};
};
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@
"private": true,
"workspaces": [
"sandpack-client",
"sandpack-react"
"sandpack-react",
"website/docs",
"plugins/*"
],
"nohoist": [
"website/docs/**",
"**/html-minifier-terser"
],
"description": "",
"scripts": {
"lint": "eslint '**/*.ts?(x)' --fix",
"format": "prettier --write '**/*.ts?(x)'",
"format": "prettier --write '**/*.{js,jsx,ts,tsx,md,mdx}'",
"build": "yarn workspaces run build",
"build:publish": "yarn workspaces run build:publish",
"prepare": "husky install"
"prepare": "husky install",
"clean": "yarn workspaces run clean",
"dev:docs": "yarn workspace sandpack-docs start"
},
"repository": {
"type": "git",
Expand All @@ -28,6 +35,7 @@
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"commitlint": "^13.1.0",
"esbuild": "^0.12.21",
"eslint": "^7.5.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-react-app": "^6.0.0",
Expand Down
25 changes: 25 additions & 0 deletions plugins/docusaurus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@codesandbox/sandpack-docusaurus",
"private": true,
"version": "0.0.1",
"description": "",
"main": "src/index.js",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "echo 1"
},
"dependencies": {
"@codesandbox/sandpack-react": "0.1.13",
"@docusaurus/core": "2.0.0-beta.6",
"@docusaurus/utils-validation": "2.0.0-beta.6"
},
"peerDependencies": {
"react": "^16.8.4 || ^17.0.0",
"react-dom": "^16.8.4 || ^17.0.0"
},
"engines": {
"node": ">=12.13.0"
}
}
17 changes: 17 additions & 0 deletions plugins/docusaurus/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const { validateThemeConfig } = require("./validateThemeConfig");

function theme() {
return {
name: "docusaurus-sandpack",

getThemePath() {
return path.resolve(__dirname, "./theme");
},
};
}

module.exports = theme;

theme.validateThemeConfig = validateThemeConfig;
48 changes: 48 additions & 0 deletions plugins/docusaurus/src/theme/CodeBlock/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Sandpack } from "@codesandbox/sandpack-react";
import CodeBlock from "@theme-init/CodeBlock";
import React from "react";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";

import "./style.css";

const RenderSandpack = (props) => {
const { siteConfig } = useDocusaurusContext();
const sandpackPluginOptions = siteConfig.themeConfig.sandpack;

if (props.sandpack) {
const {
children,
template = "react",
file = "/App.js",
theme = sandpackPluginOptions.theme,
} = props;

const occurrences = children
.split(/(```(.*?[^\\])```)/gms)
.filter((line) => line.startsWith("```"));

const files = occurrences.reduce((acc, curr) => {
const [firstLine, ...content] = curr.replace(/```/g, "").split("\n");
const fileName = firstLine.match(/file=(.+)/)?.[1] ?? "";

return {
...acc,
[fileName]: {
code: content.join("\n"),
},
};
}, {});

return (
<Sandpack
files={occurrences.length ? files : { [file]: children }}
template={template}
theme={theme}
/>
);
}

return <CodeBlock {...props} />;
};

export default RenderSandpack;
5 changes: 5 additions & 0 deletions plugins/docusaurus/src/theme/CodeBlock/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "@codesandbox/sandpack-react/dist/index.css";

.sp-wrapper {
margin-bottom: 2em;
}
Loading

0 comments on commit 183a7bb

Please sign in to comment.