Skip to content

Commit 270aab7

Browse files
committed
Run 3.0 migration script
1 parent 81250fe commit 270aab7

22 files changed

+621
-0
lines changed

_temp_extension/.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
tests

_temp_extension/.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: 'tsconfig.json',
11+
sourceType: 'module'
12+
},
13+
plugins: ['@typescript-eslint'],
14+
rules: {
15+
'@typescript-eslint/interface-name-prefix': [
16+
'error',
17+
{ prefixWithI: 'always' }
18+
],
19+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
20+
'@typescript-eslint/no-explicit-any': 'off',
21+
'@typescript-eslint/no-namespace': 'off',
22+
'@typescript-eslint/no-use-before-define': 'off',
23+
'@typescript-eslint/quotes': [
24+
'error',
25+
'single',
26+
{ avoidEscape: true, allowTemplateLiterals: false }
27+
],
28+
curly: ['error', 'all'],
29+
eqeqeq: 'error',
30+
'prefer-arrow-callback': 'error'
31+
}
32+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
branches: '*'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Install node
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: '10.x'
19+
- name: Install Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.7'
23+
architecture: 'x64'
24+
- name: Install dependencies
25+
run: python -m pip install jupyterlab
26+
- name: Build the extension
27+
run: |
28+
jlpm
29+
jlpm run eslint:check
30+
python -m pip install .
31+
32+
jupyter labextension list 2>&1 | grep -ie "jupyterlab-code-snippets.*OK"
33+
python -m jupyterlab.browser_check

_temp_extension/.gitignore

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
*.bundle.*
2+
lib/
3+
node_modules/
4+
*.egg-info/
5+
.ipynb_checkpoints
6+
*.tsbuildinfo
7+
code_snippet/labextension
8+
9+
# Created by https://www.gitignore.io/api/python
10+
# Edit at https://www.gitignore.io/?templates=python
11+
12+
### Python ###
13+
# Byte-compiled / optimized / DLL files
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
18+
# C extensions
19+
*.so
20+
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
pip-wheel-metadata/
36+
share/python-wheels/
37+
.installed.cfg
38+
*.egg
39+
MANIFEST
40+
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.nox/
55+
.coverage
56+
.coverage.*
57+
.cache
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
.hypothesis/
62+
.pytest_cache/
63+
64+
# Translations
65+
*.mo
66+
*.pot
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Spyder project settings
87+
.spyderproject
88+
.spyproject
89+
90+
# Rope project settings
91+
.ropeproject
92+
93+
# Mr Developer
94+
.mr.developer.cfg
95+
.project
96+
.pydevproject
97+
98+
# mkdocs documentation
99+
/site
100+
101+
# mypy
102+
.mypy_cache/
103+
.dmypy.json
104+
dmypy.json
105+
106+
# Pyre type checker
107+
.pyre/
108+
109+
# End of https://www.gitignore.io/api/python
110+
111+
# OSX files
112+
.DS_Store

_temp_extension/.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
**/node_modules
3+
**/lib
4+
**/package.json

_temp_extension/.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

_temp_extension/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, Jay Ahn, Kiran Pinnipati All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
* Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

_temp_extension/MANIFEST.in

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
include LICENSE
2+
include README.md
3+
include pyproject.toml
4+
include jupyter-config/code_snippet.json
5+
6+
include package.json
7+
include install.json
8+
include ts*.json
9+
include yarn.lock
10+
11+
graft code_snippet/labextension
12+
13+
# Javascript files
14+
graft src
15+
graft style
16+
prune **/node_modules
17+
prune lib
18+
19+
# Patterns to exclude from any directory
20+
global-exclude *~
21+
global-exclude *.pyc
22+
global-exclude *.pyo
23+
global-exclude .git
24+
global-exclude .ipynb_checkpoints

_temp_extension/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# code_snippet
2+
3+
![Github Actions Status](https://github.com/jupytercalpoly/jupyterlab-code-snippets.git.git/workflows/Build/badge.svg)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupytercalpoly/jupyterlab-code-snippets.git.git/master?urlpath=lab)
4+
5+
EXPERIMENTAL: Save, reuse, and share code snippets using JupyterLab Code Snippets
6+
7+
8+
9+
## Requirements
10+
11+
* JupyterLab >= 3.0
12+
13+
## Install
14+
15+
```bash
16+
pip install code_snippet
17+
```
18+
19+
20+
## Contributing
21+
22+
### Development install
23+
24+
Note: You will need NodeJS to build the extension package.
25+
26+
The `jlpm` command is JupyterLab's pinned version of
27+
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
28+
`yarn` or `npm` in lieu of `jlpm` below.
29+
30+
```bash
31+
# Clone the repo to your local environment
32+
# Change directory to the code_snippet directory
33+
# Install package in development mode
34+
pip install -e .
35+
# Link your development version of the extension with JupyterLab
36+
jupyter labextension develop . --overwrite
37+
# Rebuild extension Typescript source after making changes
38+
jlpm run build
39+
```
40+
41+
You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
42+
43+
```bash
44+
# Watch the source directory in one terminal, automatically rebuilding when needed
45+
jlpm run watch
46+
# Run JupyterLab in another terminal
47+
jupyter lab
48+
```
49+
50+
With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
51+
52+
By default, the `jlpm run build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
53+
54+
```bash
55+
jupyter lab build --minimize=False
56+
```
57+
58+
### Uninstall
59+
60+
```bash
61+
pip uninstall code_snippet
62+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# a mybinder.org-ready environment for demoing code_snippet
2+
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
3+
#
4+
# conda env update --file binder/environment.yml
5+
# conda activate code_snippet-demo
6+
#
7+
name: code_snippet-demo
8+
9+
channels:
10+
- conda-forge
11+
12+
dependencies:
13+
# runtime dependencies
14+
- python >=3.8,<3.9.0a0
15+
- jupyterlab >=3,<4.0.0a0
16+
# labextension build dependencies
17+
- nodejs >=14,<15
18+
- pip
19+
- wheel
20+
# additional packages for demos
21+
# - ipywidgets

_temp_extension/binder/postBuild

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
""" perform a development install of code_snippet
3+
4+
On Binder, this will run _after_ the environment has been fully created from
5+
the environment.yml in this directory.
6+
7+
This script should also run locally on Linux/MacOS/Windows:
8+
9+
python3 binder/postBuild
10+
"""
11+
import subprocess
12+
import sys
13+
from pathlib import Path
14+
15+
16+
ROOT = Path.cwd()
17+
18+
def _(*args, **kwargs):
19+
""" Run a command, echoing the args
20+
21+
fails hard if something goes wrong
22+
"""
23+
print("\n\t", " ".join(args), "\n")
24+
return_code = subprocess.call(args, **kwargs)
25+
if return_code != 0:
26+
print("\nERROR", return_code, " ".join(args))
27+
sys.exit(return_code)
28+
29+
# verify the environment is self-consistent before even starting
30+
_(sys.executable, "-m", "pip", "check")
31+
32+
# install the labextension
33+
_(sys.executable, "-m", "pip", "install", "-e", ".")
34+
35+
# verify the environment the extension didn't break anything
36+
_(sys.executable, "-m", "pip", "check")
37+
38+
# list the extensions
39+
_("jupyter", "server", "extension", "list")
40+
41+
# initially list installed extensions to determine if there are any surprises
42+
_("jupyter", "labextension", "list")
43+
44+
45+
print("JupyterLab with code_snippet is ready to run with:\n")
46+
print("\tjupyter lab\n")

0 commit comments

Comments
 (0)