Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Details:
- Drafts monorepo structure, based on Lerna (for publishing) and
  Preconstruct (for building, and linking for dev). The stack is based
  on sigma.js v3's one.
- Drafts packages/storybook, to allow writing stories in there but also
  in each workspace independently.
  • Loading branch information
jacomyal committed Jun 11, 2024
0 parents commit 306233b
Show file tree
Hide file tree
Showing 19 changed files with 334 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/dist/*
**/build/*
**/node_modules/*

# Doc and examples
**/storybook-static/*
37 changes: 37 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"env": {
"jest": true,
"browser": true
},
"root": true,
"ignorePatterns": ["*.js", "*.d.ts"],
"parser": "@typescript-eslint/parser",
"plugins": ["import", "@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"prettier",
"plugin:storybook/recommended"
],
"rules": {
"no-prototype-builtins": "off",
"no-console": "warn",
"import/extensions": [
"warn",
"never",
{
"json": "always",
"glsl": "always"
}
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
]
}
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.tgz
*.log
*.swp
.DS_Store
.idea
.vscode
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/dist/*
**/build/*
**/node_modules/*

# Doc and examples
**/storybook-static/*
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"trailingComma": "all",
"printWidth": 120,
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderGroupNamespaceSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}
12 changes: 12 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (C) 2013-2024, Alexis Jacomy, Guillaume Plique https://www.sigmajs.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gephi TypeScript utils

TODO
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ["@babel/preset-env", "@babel/preset-typescript"],
};
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "independent",
"private": false,
"push": false,
"includeMergedTags": true
}
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@gephi/root",
"description": "Various TypeScript helper modules used in the web Gephi ecosystem",
"homepage": "https://gephi.org",
"bugs": "http://github.com/gephi/typescript-utils/issues",
"workspaces": [
"packages/*"
],
"scripts": {
"clean": "npm exec --workspaces -- npx rimraf node_modules && npx rimraf node_modules",
"build": "preconstruct build",
"prettify": "prettier --write .",
"lint": "eslint .",
"test": "npm run test --workspaces",
"start": "npm run start --workspace=@gephi/ts-utils-storybook",
"postinstall": "preconstruct dev",
"postpublish": "preconstruct dev",
"prepublishOnly": "npm run lint && npm run test && npm run build"
},
"dependencies": {
"@babel/core": "^7.24.0",
"@babel/preset-typescript": "^7.23.3",
"@preconstruct/cli": "^2.8.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-storybook": "^0.8.0",
"lerna": "^8.1.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"typescript": "^5.4.2",
"typescript-eslint": "^7.2.0"
},
"preconstruct": {
"packages": [],
"exports": {
"importConditionDefaultExport": "default"
}
}
}
2 changes: 2 additions & 0 deletions packages/storybook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
storybook-static
38 changes: 38 additions & 0 deletions packages/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { StorybookConfig } from "@storybook/html-vite";
import { dirname, join } from "path";
import { mergeConfig } from "vite";

/** @type { import('@storybook/html-vite').StorybookConfig } */
const config: StorybookConfig = {
stories: ["../stories/**/stories.ts", "../../**/src/**/*.mdx", "../../**/src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
addons: [
getAbsolutePath("@storybook/addon-links"),
getAbsolutePath("@storybook/addon-essentials"),
getAbsolutePath("@storybook/addon-interactions"),
getAbsolutePath("@storybook/addon-storysource"),
],
framework: getAbsolutePath("@storybook/html-vite"),
typescript: {
check: true,
},
docs: {
autodocs: "tag",
},
core: {
disableTelemetry: true,
},
staticDirs: ["../public"],
logLevel: "debug",
async viteFinal(config) {
return mergeConfig(config, {
resolve: {
preserveSymlinks: false,
},
});
},
};
export default config;

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, "package.json")));
}
7 changes: 7 additions & 0 deletions packages/storybook/.storybook/manager.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { addons } from "@storybook/manager-api";

import theme from "./theme";

addons.setConfig({
theme,
});
41 changes: 41 additions & 0 deletions packages/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Preview } from "@storybook/html";

const forceReloadDecorator: Preview["decorators"] = (storyFn, context) => {
if (context.globals.shouldReload) {
// Change search params of the iframe
const searchParams = new URLSearchParams(window.parent.location.search);
searchParams.set(
"args",
Object.keys(context.args)
.map((k) => `${k}:${context.args[k]}`)
.join(";"),
);
history.pushState(null, "", "?" + searchParams.toString());

// reload iframe
window.location.reload();

// The reload is fired, but the story renderer is already started.
// To avoid blink effect and console error, we return the template inside a full
// invisible div
return `<div style="height:100%;width:100%;visibility:hidden">${storyFn()}</div>`;
}

context.globals.shouldReload = true;
return storyFn();
};

const preview: Preview = {
decorators: [forceReloadDecorator],
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
},
},
};

export default preview;
14 changes: 14 additions & 0 deletions packages/storybook/.storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { create } from "@storybook/theming/create";

export default create({
base: "light",
fontCode: "monospace",
brandTitle: "Gephi TypeScript utils",
brandUrl: "https://gephi.org/",
brandImage: "https://gephi.org/gephi-lite/gephi-logo.svg",
brandTarget: "_self",
colorPrimary: "#000000",
colorSecondary: "#ffffff",
textColor: "#000000",
textInverseColor: "#ffffff",
});
18 changes: 18 additions & 0 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@gephi/ts-utils-storybook",
"private": true,
"devDependencies": {
"@storybook/addon-essentials": "^8.0.0",
"@storybook/addon-interactions": "^8.0.0",
"@storybook/addon-links": "^8.0.0",
"@storybook/addon-storysource": "^8.0.0",
"@storybook/html": "^8.0.0",
"@storybook/html-vite": "^8.0.0",
"@storybook/web-components": "^8.0.0",
"storybook": "^8.0.0"
},
"scripts": {
"start": "storybook dev -p 6006",
"build": "storybook build"
}
}
4 changes: 4 additions & 0 deletions packages/storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["./types/raw.d.ts", ".storybook/*.tsx", "stories"]
}
58 changes: 58 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"compileOnSave": false,
"compilerOptions": {
"allowJs": false,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"baseUrl": ".",
"declaration": true,
"diagnostics": false,
"emitBOM": false,
"emitDecoratorMetadata": false,
"esModuleInterop": true,
"experimentalDecorators": false,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"importsNotUsedAsValues": "remove",
"inlineSourceMap": false,
"inlineSources": false,
"isolatedModules": false,
"jsx": "react",
"lib": ["dom", "dom.iterable", "esnext"],
"listEmittedFiles": false,
"listFiles": false,
"module": "commonjs",
"moduleResolution": "node",
"noEmit": false,
"noEmitHelpers": false,
"noEmitOnError": false,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitUseStrict": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"paths": {
"*": ["@types/*"]
},
"preserveConstEnums": true,
"pretty": true,
"removeComments": true,
"resolveJsonModule": true,
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"strictBindCallApply": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"stripInternal": true,
"suppressExcessPropertyErrors": false,
"suppressImplicitAnyIndexErrors": false,
"target": "es6"
}
}
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.base.json",
"files": [],
"references": [
{ "path": "./packages/demo" },
{ "path": "./packages/test" },
{ "path": "./packages/storybook" },
{ "path": "./packages/sigma" },
{ "path": "./packages/node-border" },
{ "path": "./packages/node-image" },
{ "path": "./packages/node-piechart" },
{ "path": "./packages/edge-curve" }
],
"watchOptions": {
"excludeDirectories": ["**/node_modules"]
},
"compilerOptions": {
"noFallthroughCasesInSwitch": false
}
}

0 comments on commit 306233b

Please sign in to comment.