Skip to content

Commit 87187cc

Browse files
Merge pull request #1071 from Py4Js/development
Merge development branch into master
2 parents 0a97146 + e820fc1 commit 87187cc

File tree

9 files changed

+113
-104
lines changed

9 files changed

+113
-104
lines changed

.github/workflows/deploy.yaml

Lines changed: 56 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,56 @@
1-
# on:
2-
# push:
3-
# branches: [main]
4-
5-
# jobs:
6-
# build:
7-
# runs-on: ubuntu-latest
8-
# steps:
9-
# - name: Checkout repository
10-
# uses: actions/checkout@v3
11-
12-
# - name: Setup Node
13-
# uses: actions/setup-node@v3
14-
# with:
15-
# node-version: "lts/*"
16-
# registry-url: "https://registry.npmjs.org"
17-
18-
# - name: Install dependencies
19-
# run: yarn --ignore-engines
20-
21-
#- name: Run tests
22-
# run: yarn run test
23-
24-
# - name: Build project
25-
# run: yarn run build #--target npm
26-
27-
# - name: Create zip lib
28-
# uses: vimtor/action-zip@v1
29-
# with:
30-
# files: library/
31-
# dest: pyscript-react.zip
32-
33-
# - name: Get current tag
34-
# run: |
35-
# echo "current_tag=v`grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/'`" >> $GITHUB_ENV
36-
37-
# - name: Create new tag
38-
# uses: rickstaa/action-create-tag@v1
39-
# id: "tag_create"
40-
# with:
41-
# tag: "${{ env.current_tag }}"
42-
# tag_exists_error: true
43-
# message: "Latest release"
44-
45-
# - name: Create GitHub realese
46-
# uses: "marvinpinto/action-automatic-releases@latest"
47-
# with:
48-
# repo_token: "${{ secrets.GITHUB_TOKEN }}"
49-
# automatic_release_tag: "${{ env.current_tag }}"
50-
# prerelease: false
51-
# files: |
52-
# LICENSE
53-
# pyscript-react.zip
54-
55-
# - name: Publish to npm 🚀
56-
# run: |
57-
# cd library
58-
# yarn publish
59-
# cd ..
60-
# for dir in library/*; do
61-
# if [ -d "$dir" ]; then
62-
# cd "$dir"
63-
# yarn publish
64-
# cd ../../
65-
# fi
66-
# done
67-
# env:
68-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1+
on:
2+
push:
3+
branches: [main]
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repository
9+
uses: actions/checkout@v3
10+
- name: Setup Node
11+
uses: actions/setup-node@v3
12+
with:
13+
node-version: "lts/*"
14+
registry-url: "https://registry.npmjs.org"
15+
- name: Install dependencies
16+
run: yarn --ignore-engines
17+
- name: Build project
18+
run: yarn run build #--target npm
19+
- name: Create zip lib
20+
uses: vimtor/action-zip@v1
21+
with:
22+
files: library/
23+
dest: pyscript-react.zip
24+
- name: Get current tag
25+
run: |
26+
echo "current_tag=v`grep version package.json | sed 's/.*"version": "\(.*\)".*/\1/'`" >> $GITHUB_ENV
27+
- name: Create new tag
28+
uses: rickstaa/action-create-tag@v1
29+
id: "tag_create"
30+
with:
31+
tag: "${{ env.current_tag }}"
32+
tag_exists_error: true
33+
message: "Latest release"
34+
- name: Create GitHub realese
35+
uses: "marvinpinto/action-automatic-releases@latest"
36+
with:
37+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
38+
automatic_release_tag: "${{ env.current_tag }}"
39+
prerelease: false
40+
files: |
41+
LICENSE
42+
pyscript-react.zip
43+
- name: Publish to npm 🚀
44+
run: |
45+
cd library
46+
yarn publish
47+
cd ..
48+
for dir in library/*; do
49+
if [ -d "$dir" ]; then
50+
cd "$dir"
51+
yarn publish
52+
cd ../../
53+
fi
54+
done
55+
env:
56+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"sort-package-json": "^2.4.1",
8686
"source-map-loader": "^4.0.1",
8787
"storybook": "^7.0.7",
88+
"super-expressive": "^2.0.0",
8889
"ts-jest": "^29.1.0",
8990
"ts-node": "^10.9.1",
9091
"ts-patch": "^2.1.0",

source/library/components/py-config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
PyConfigFetch,
3+
PyConfigFetchItem,
34
PyConfigInterpreters,
45
PyConfigProperties,
56
PyConfigPropertiesBase,
@@ -16,6 +17,7 @@ import PyConfig from "./py-config";
1617
export type {
1718
PyConfigInterpreters,
1819
PyConfigFetch,
20+
PyConfigFetchItem,
1921
PyConfigSplashscreen,
2022
PyConfigSharedJsonProperties,
2123
PyConfigPropertiesWithJsonType,

source/library/components/py-config/py-config.tsx

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import propTypes from "prop-types";
22
import { WeakValidationMap, useEffect, useMemo } from "react";
3-
4-
import {
5-
PyConfigInterpreters,
6-
PyConfigSplashscreen,
7-
} from "~root/source/library/components/py-config/py-config.types";
8-
93
import type {
104
PyConfigFetch,
5+
PyConfigFetchItem,
6+
PyConfigInterpreters,
117
PyConfigProperties,
128
PyConfigPropertiesBase,
9+
PyConfigSplashscreen,
1310
PyConfigTag,
1411
} from "./py-config.types";
1512

@@ -54,10 +51,6 @@ const PyConfig: PyConfigTag = <T extends object>({
5451
// eslint-disable-next-line sonarjs/cognitive-complexity
5552
const config: string = useMemo((): string => {
5653
if (type === "json") {
57-
const transformedFiles: string[] = [
58-
...(fetch?.files || []),
59-
...(children?.fetch?.files || []),
60-
];
6154
const transformedPlugins: string[] = [
6255
...(plugins || []),
6356
...(children?.plugins || []),
@@ -66,10 +59,16 @@ const PyConfig: PyConfigTag = <T extends object>({
6659
...(packages || []),
6760
...(children?.packages || []),
6861
];
69-
const transformedFetch: PyConfigFetch = {
70-
files: transformedFiles.length ? transformedFiles : undefined,
71-
...children?.fetch,
72-
};
62+
const transformedFetch: PyConfigFetch = [
63+
...(fetch || []),
64+
...(children?.fetch || []),
65+
].map(({ files, ...restItem }: PyConfigFetchItem): PyConfigFetchItem => {
66+
const transformedFiles: string[] = [...(files || [])];
67+
return {
68+
files: transformedFiles.length ? transformedFiles : undefined,
69+
...restItem,
70+
};
71+
});
7372
const transformedInterpreters: Omit<PyConfigInterpreters, "source"> & {
7473
src?: string;
7574
} = {
@@ -89,7 +88,7 @@ const PyConfig: PyConfigTag = <T extends object>({
8988
interpreters: checkForAnyKey(transformedInterpreters)
9089
? transformedInterpreters
9190
: undefined,
92-
fetch: checkForAnyKey(transformedFetch) ? transformedFetch : undefined,
91+
fetch: transformedFetch.length ? transformedFetch : undefined,
9392
packages: transformedPackages.length ? transformedPackages : undefined,
9493
plugins: transformedPlugins.length ? transformedPlugins : undefined,
9594
...children,
@@ -127,10 +126,18 @@ PyConfig.propTypes = {
127126
name: propTypes.string,
128127
language: propTypes.string,
129128
}),
130-
fetch: propTypes.shape({
131-
files: propTypes.arrayOf(propTypes.string),
132-
}),
133-
packages: propTypes.arrayOf(propTypes.string),
129+
fetch: propTypes.arrayOf(
130+
propTypes.shape({
131+
files: propTypes.oneOfType([
132+
propTypes.arrayOf(propTypes.string),
133+
propTypes.instanceOf(Set),
134+
]),
135+
}),
136+
),
137+
packages: propTypes.oneOfType([
138+
propTypes.arrayOf(propTypes.string),
139+
propTypes.instanceOf(Set),
140+
]),
134141
plugins: propTypes.arrayOf(propTypes.string),
135142
} as WeakValidationMap<PyConfigPropertiesBase>;
136143

source/library/components/py-config/py-config.types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ export type PyConfigInterpreters = {
1010
name?: string;
1111
language?: string;
1212
};
13+
export type PyConfigFetchItem = { files?: string[] | Set<string> };
1314

14-
export type PyConfigFetch = {
15-
files?: string[] | Set<string>;
16-
};
15+
export type PyConfigFetch = PyConfigFetchItem[];
1716

1817
export type PyConfigSplashscreen = {
1918
autoclose?: boolean;

source/library/components/py-script/py-script.story.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ PyScriptFoliumExample.args = {
6161
export const PyScriptFoliumWithTomlConfigExample: StoryFn<typeof PyScript> =
6262
Template.bind({});
6363

64-
PyScriptFoliumExample.args = {
64+
PyScriptFoliumWithTomlConfigExample.args = {
6565
source: "/folium_map.py",
6666
output: "folium",
6767
generateOutputTag: true,

source/library/index.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ import PyButton, {
1212
type PyButtonTag,
1313
} from "./components/py-button";
1414
import PyConfig, {
15-
PyConfigFetch,
16-
PyConfigInterpreters,
17-
PyConfigProperties,
18-
PyConfigPropertiesBase,
19-
PyConfigPropertiesWithChildren,
20-
PyConfigPropertiesWithJsonType,
21-
PyConfigPropertiesWithTomlType,
22-
PyConfigPropertiesWithoutChildren,
23-
PyConfigSharedJsonProperties,
24-
PyConfigSplashscreen,
25-
PyConfigTag,
15+
type PyConfigFetch,
16+
type PyConfigFetchItem,
17+
type PyConfigInterpreters,
18+
type PyConfigProperties,
19+
type PyConfigPropertiesBase,
20+
type PyConfigPropertiesWithChildren,
21+
type PyConfigPropertiesWithJsonType,
22+
type PyConfigPropertiesWithTomlType,
23+
type PyConfigPropertiesWithoutChildren,
24+
type PyConfigSharedJsonProperties,
25+
type PyConfigSplashscreen,
26+
type PyConfigTag,
2627
} from "./components/py-config";
2728
import PyEnv, {
2829
type PyEnvChildrenAsObject,
@@ -123,6 +124,7 @@ export type {
123124
PyButtonTag,
124125
PyConfigInterpreters,
125126
PyConfigFetch,
127+
PyConfigFetchItem,
126128
PyConfigSplashscreen,
127129
PyConfigSharedJsonProperties,
128130
PyConfigPropertiesWithJsonType,

source/scripts/build/wrappers/get-entrypoints/get-entrypoints.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { globSync } from "glob";
2-
import { join } from "path";
2+
import { join, sep } from "path";
3+
import SuperExpressive from "super-expressive";
34
import type { GetEntrypoints } from "~root/source/scripts/build/wrappers/get-entrypoints/get-entrypoints.types";
45

56
const getEntrypoints: GetEntrypoints = (): Record<string, string> => {
@@ -21,7 +22,11 @@ const getEntrypoints: GetEntrypoints = (): Record<string, string> => {
2122
splittedFile.pop();
2223
const deletedExtensionFile = splittedFile.join();
2324
const fixedFileName = deletedExtensionFile.replace(
24-
/^(source\\library\\)/,
25+
SuperExpressive()
26+
.startOfInput.string("source")
27+
.string(sep)
28+
.string("library")
29+
.toRegex(),
2530
"",
2631
);
2732
accumulator[fixedFileName] = join(process.cwd(), file);

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15422,6 +15422,11 @@ stylis@4.1.3:
1542215422
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7"
1542315423
integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==
1542415424

15425+
super-expressive@^2.0.0:
15426+
version "2.0.0"
15427+
resolved "https://registry.yarnpkg.com/super-expressive/-/super-expressive-2.0.0.tgz#646c4c6b7d813d47196cf144df36366f90bec456"
15428+
integrity sha512-jtCS9dEBPxtq4jd0v33LnRPI0kYQP1npHxzl+Pk+IOuufIn5Pyo0AXiU6ypvhO3vZevqEE9AE3YDD7aWp+RxRg==
15429+
1542515430
supports-color@^5.3.0:
1542615431
version "5.5.0"
1542715432
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"

0 commit comments

Comments
 (0)