Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add core module #413

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
],
"rules": {
"no-use-before-define": "off",
"no-useless-constructor": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-use-before-define": "warn",
"prettier/prettier": "error",
Expand Down
4 changes: 2 additions & 2 deletions docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"dependencies": {
"@rediagram/aws": "^0.4.2",
"@rediagram/cli": "^0.1.5",
"@ts-graphviz/react": "^0.7.0",
"@ts-graphviz/react": "^0.9.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rediagram": "^0.2.5",
"ts-graphviz": "^0.13.1"
"ts-graphviz": "^0.16.0"
},
"devDependencies": {
"@types/react": "^16.9.41",
Expand Down
Binary file modified examples/gallery/img/AppEngineAndCloudEndpoints.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/ChefAutomateArchitectureOnAWS.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/ContentManagement.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/GitToS3WebHooks.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/HighPerformanceComputing.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/MyInfra.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/gallery/img/firebase.rediagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions examples/gallery/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@rediagram/gallery",
"version": "0.1.10",
"main": "index.js",
"license": "MIT",
"private": true,
"type": "module",
"scripts": {
"start": "rediagramc"
},
Expand All @@ -12,12 +12,12 @@
"@rediagram/cli": "^0.1.5",
"@rediagram/firebase": "^0.0.1",
"@rediagram/gcp": "^0.3.1",
"@ts-graphviz/react": "^0.7.0",
"@ts-graphviz/react": "^0.9.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rediagram": "^0.2.5",
"ts-graphviz": "^0.13.1"
"ts-graphviz": "^0.16.0"
},
"devDependencies": {
"@types/node": "^16.4.5",
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "rediagram",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"workspaces": [
Expand All @@ -14,7 +13,7 @@
"lerna": "lerna",
"test": "jest",
"prebuild": "lerna run --parallel clean",
"build": "yarn workspace @rediagram/common build && yarn workspace create-rediagram-project build && yarn workspace @rediagram/cdk build && yarn workspace @rediagram/cli build && yarn workspace rediagram build && yarn workspace @rediagram/aws build && yarn workspace @rediagram/gcp build && yarn workspace @rediagram/firebase build",
"build": "yarn workspace @rediagram/common build && yarn workspace create-rediagram-project build && yarn workspace @rediagram/cdk build && yarn workspace rediagram build && yarn workspace @rediagram/cli build && yarn workspace @rediagram/aws build && yarn workspace @rediagram/gcp build && yarn workspace @rediagram/firebase build",
"prewatch": "yarn build",
"watch": "lerna run --parallel watch",
"rediagram": "yarn workspace @rediagram/cli start",
Expand Down
9 changes: 6 additions & 3 deletions packages/aws/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "@rediagram/aws",
"version": "0.4.2",
"main": "lib/index.js",
"type": "module",
"exports": {
"import": "./lib/index.js"
},
"types": "lib/index.d.ts",
"license": "MIT",
"description": "Components for drawing AWS diagrams.",
Expand Down Expand Up @@ -31,12 +34,12 @@
"@rediagram/cdk": "^0.3.1"
},
"peerDependencies": {
"@ts-graphviz/react": "^0.7.0",
"@ts-graphviz/react": "^0.9.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rediagram": "*",
"ts-graphviz": "^0.13.1"
"ts-graphviz": "^0.16.0"
},
"devDependencies": {
"@types/node": "^16.4.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const options = [
input: './src/index.ts',
output: [
{
format: 'cjs',
format: 'module',
file: './lib/index.js',
},
],
external: ['@rediagram/cdk', 'react', '@ts-graphviz/react', 'prop-types', 'path'],
external: ['@rediagram/cdk', 'react', '@ts-graphviz/react', 'prop-types', 'node:path', 'node:url'],
plugins: [typescript()],
},
{
Expand Down
6 changes: 5 additions & 1 deletion packages/aws/src/assets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import path from 'path';
import path from 'node:path';
import url from 'node:url';

// eslint-disable-next-line no-underscore-dangle
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

export function resolveAsset(...paths: string[]): string {
return path.resolve(__dirname, '../assets', ...paths);
Expand Down
9 changes: 6 additions & 3 deletions packages/cdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "@rediagram/cdk",
"version": "0.3.1",
"main": "lib/index.js",
"type": "module",
"exports": {
"import": "./lib/index.js"
},
"types": "lib/index.d.ts",
"author": "kamiazya <yuki@kamiazya.tech>",
"description": "Component Development Kit for rediagram library.",
Expand All @@ -28,10 +31,10 @@
"watch": "tsc --watch"
},
"peerDependencies": {
"@ts-graphviz/react": "^0.7.0",
"@ts-graphviz/react": "^0.9.1",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"ts-graphviz": "^0.13.1"
"ts-graphviz": "^0.16.0"
},
"devDependencies": {
"@types/prop-types": "^15.7.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const options = [
input: './src/index.ts',
output: [
{
format: 'cjs',
format: 'module',
file: './lib/index.js',
},
],
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/rediagramc.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../lib/rediagramc');
#!/usr/bin/env -S node --experimental-loader esbuild-node-loader
import '../lib/rediagramc.js';
9 changes: 5 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "CLI for rediagram.",
"author": "kamiazya <yuki@kamiazya.tech>",
"homepage": "https://github.com/kamiazya/rediagram",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/kamiazya/rediagram.git",
Expand Down Expand Up @@ -32,26 +33,26 @@
"dependencies": {
"@rediagram/aws": "^0.4.2",
"@rediagram/common": "^0.0.3",
"@ts-graphviz/react": "^0.7.0",
"@ts-graphviz/react": "^0.9.1",
"@types/node": "^16.4.5",
"@types/prop-types": "^15.7.3",
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"chokidar": "^3.4.3",
"commander": "^6.1.0",
"esbuild-node-loader": "^0.6.3",
"fast-glob": "^3.2.4",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rediagram": "^0.2.5",
"sucrase": "^3.16.0",
"ts-graphviz": "^0.13.1",
"ts-graphviz": "^0.16.0",
"typescript": "^4.0.2"
},
"devDependencies": {
"rimraf": "^3.0.2",
"rollup": "^2.55.0",
"rollup-plugin-typescript2": "^0.30.0",
"ts-node": "^9.0.0"
"rollup-plugin-version-injector": "^1.3.3"
}
}
28 changes: 17 additions & 11 deletions packages/cli/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import typescript from 'rollup-plugin-typescript2';
import versionInjector from 'rollup-plugin-version-injector';

export default {
input: './src/rediagramc.ts',
output: [
{
format: 'cjs',
file: './lib/rediagramc.js',
},
],
external: ['commander', 'fast-glob', 'path', 'fs', 'sucrase/dist/register', '@rediagram/common', 'chokidar'],
plugins: [typescript()],
};
/** @type {import('rollup').RollupOptions[]} */
const options = [
{
input: './src/rediagramc.ts',
output: [
{
format: 'module',
file: './lib/rediagramc.js',
},
],
external: ['commander', 'fast-glob', 'path', 'fs', 'rediagram', 'chokidar'],
plugins: [typescript(), versionInjector()],
},
];

export default options;
10 changes: 0 additions & 10 deletions packages/cli/src/pkg.ts

This file was deleted.

39 changes: 21 additions & 18 deletions packages/cli/src/rediagramc.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import cmd from 'commander';
import glob from 'fast-glob';
import chokidar from 'chokidar';
import { CONFIG } from '@rediagram/common';
import { registerAll } from 'sucrase/dist/register';
import path from 'path';
import pkg from './pkg';
import { Rediagram } from 'rediagram';

type Options = {
watch: boolean;
};

function runRediagram(src: string) {
// eslint-disable-next-line no-console
console.log(src);
const resolved = path.resolve(src);
// eslint-disable-next-line global-require, import/no-dynamic-require
require(resolved);
delete require.cache[resolved];
}
const NAME = 'rediagramc';

const logger = Rediagram.logger.getChildLogger({ name: NAME });

cmd
.name('rediagramc')
.version(pkg.version)
.name(NAME)
.version('[VI]{version}[/VI]')
.arguments('[pattarns...]')
.option('-w, --watch', 'Watch files for changes and rerun rediagram related to changed files.', false)
.action(async function rediagramc(this: Options, pattarns: string[]): Promise<void> {
registerAll();
const paths =
pattarns.length >= 1
? pattarns
: [...CONFIG.scope.getIncludesPattarns(), ...CONFIG.scope.getExcludesPattarns().map((p) => `!${p}`)];
: [...Rediagram.config.scope.includes, ...Rediagram.config.scope.excludes.map((p) => `!${p}`)];
if (this.watch) {
chokidar.watch(paths).on('add', runRediagram).on('change', runRediagram);
chokidar
.watch(paths)
.on('add', async (src) => {
logger.info('Added', src);
await Rediagram.run(src);
})
.on('change', async (src) => {
logger.info('Changed', src);
await Rediagram.run(src);
});
} else {
const sources = await glob(paths, {
dot: true,
extglob: true,
onlyFiles: true,
});
sources.forEach(runRediagram);
sources.forEach(async (src) => {
logger.info('Start', src);
await Rediagram.run(src);
});
}
})
.parse(process.argv);
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"declaration": false
"declaration": true
},
"include": [
"src/**/*.ts",
Expand Down
20 changes: 16 additions & 4 deletions packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"name": "@rediagram/common",
"version": "0.0.3",
"main": "lib/index.js",
"type": "module",
"exports": {
"import": "./lib/index.js"
},
"types": "lib/index.d.ts",
"author": "kamiazya <yuki@kamiazya.tech>",
"description": "Common config and utility for rediagram.",
Expand All @@ -27,14 +30,23 @@
"build": "rollup -c && prettier --write './lib/*'",
"watch": "tsc --watch"
},
"dependencies": {
"@ts-graphviz/node": "^0.4.0",
"@ts-graphviz/react": "^0.9.1",
"cosmiconfig": "^7.0.1",
"fs-extra": "^10.0.0",
"sharp": "^0.29.1",
"svgo": "^2.7.0",
"svgson": "^5.2.1",
"tslog": "^3.2.1"
},
"devDependencies": {
"@types/sharp": "^0.29.2",
"@types/svgo": "^2.4.2",
"rollup": "^2.55.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-dts": "^3.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"typescript": "^4.0.2"
},
"dependencies": {
"cosmiconfig": "^7.0.0"
}
}
14 changes: 12 additions & 2 deletions packages/common/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ const options = [
input: './src/index.ts',
output: [
{
format: 'cjs',
format: 'module',
file: './lib/index.js',
},
],
external: ['path', 'cosmiconfig'],
external: [
'path',
'cosmiconfig',
'fs-extra',
'tslog',
'sharp',
'@ts-graphviz/react',
'@ts-graphviz/node',
'node:path',
'rehype',
],
plugins: [typescript()],
},
{
Expand Down
Loading