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

Re-organize lib/dashboard/ #8587

Merged
merged 45 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4765864
Initial re-organization of `lib/dashboard/`
somebody1234 Dec 19, 2023
fd7a15e
Basic testing and fixes for ESBuild
somebody1234 Dec 19, 2023
08b3d1a
Fix build script errors
somebody1234 Dec 20, 2023
f6fc8ef
Finish refactoring directory structure
somebody1234 Dec 20, 2023
43a62d1
Fix `npm run dev` for GUI2
somebody1234 Dec 20, 2023
882543e
Fix `tsconfig.json`
somebody1234 Dec 20, 2023
61fc07c
Fix more errors
somebody1234 Dec 20, 2023
89dd2b1
Fix errors in `./run ide build`
somebody1234 Dec 20, 2023
a28ed0e
Fix React error
somebody1234 Dec 20, 2023
5d13be0
Trigger CI
somebody1234 Dec 20, 2023
c9510f6
Add namespace import TS plugin
somebody1234 Dec 21, 2023
cfcb665
Fix TS plugin; refactor `hooks/` and `providers/`
somebody1234 Dec 21, 2023
93d0e99
Refactor `events/`
somebody1234 Dec 21, 2023
7a449b2
Add prettier imports plugin; sort imports
somebody1234 Dec 21, 2023
fc5c29a
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Dec 21, 2023
231059c
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 1, 2024
e818875
Make HMR less broken (part 1/?)
somebody1234 Jan 1, 2024
9e4ee78
Make HMR less broken (part 2/?)
somebody1234 Jan 1, 2024
80d10ab
Make HMR less broken (part 3/?)
somebody1234 Jan 2, 2024
a08909b
Change all component file names to `PascalCase`
somebody1234 Jan 2, 2024
a561c8d
Make HMR less broken (part 4/?)
somebody1234 Jan 2, 2024
d6e67f7
Remove barrel exports back into improve HMR
somebody1234 Jan 2, 2024
a478d54
Change provider file names to `PascalCase`
somebody1234 Jan 2, 2024
fa3720e
Fix React error
somebody1234 Jan 2, 2024
9636b52
Fix import order
somebody1234 Jan 2, 2024
224ef80
Attempt to fix lint CI
somebody1234 Jan 2, 2024
a42df39
Fix TS errors
somebody1234 Jan 3, 2024
cdea9fe
Fix TS errors
somebody1234 Jan 3, 2024
49812bb
Fix TS plugin
somebody1234 Jan 3, 2024
b451fb0
Run prettier
somebody1234 Jan 3, 2024
41c5259
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 5, 2024
ccec27b
Fix lint error
somebody1234 Jan 5, 2024
ca5c9d2
Trigger CI
somebody1234 Jan 5, 2024
b172a8c
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 8, 2024
995e227
Run prettier
somebody1234 Jan 9, 2024
b0edaf9
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 9, 2024
037f51d
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 9, 2024
c1c011a
Extract most enums out to their own file
somebody1234 Jan 9, 2024
0ec724a
Fix bug with labels
somebody1234 Jan 9, 2024
ad37a73
Move `vue-react-wrapper` dependency to correct location
somebody1234 Jan 9, 2024
93b2391
Merge branch 'develop' into wip/sb/reorganize-dashboard
somebody1234 Jan 10, 2024
fd5f024
Avoid multi-line destructures when possible
somebody1234 Jan 10, 2024
bd4ab5f
Fix `package-lock.json`
somebody1234 Jan 10, 2024
58dd19e
Trigger CI
somebody1234 Jan 10, 2024
f461145
Fix issue with missing SWC binaries
somebody1234 Jan 10, 2024
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
4 changes: 2 additions & 2 deletions app/gui2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"dev": "vite",
"build": "npm --workspace enso-authentication run compile && run-p typecheck build-only",
"build": "npm --workspace enso-dashboard run compile && run-p typecheck build-only",
"build:cloud": "cross-env CLOUD_BUILD=true npm run build",
"preview": "vite preview",
"test": "vitest run && playwright test --reporter=html",
Expand Down Expand Up @@ -47,7 +47,7 @@
"@vueuse/core": "^10.4.1",
"codemirror": "^6.0.1",
"culori": "^3.2.0",
"enso-authentication": "^1.0.0",
"enso-dashboard": "^0.1.0",
"events": "^3.3.0",
"fast-diff": "^1.3.0",
"hash-sum": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion app/gui2/src/components/GraphEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import * as set from 'lib0/set'
import { toast } from 'react-toastify'
import type { ExprId, NodeMetadata } from 'shared/yjsModel'
import { computed, onMounted, onScopeDispose, onUnmounted, ref, watch } from 'vue'
import { ProjectManagerEvents } from '../../../ide-desktop/lib/dashboard/src/authentication/src/dashboard/projectManager'
import { ProjectManagerEvents } from '../../../ide-desktop/lib/dashboard/src/utilities/projectManager'
import { type Usage } from './ComponentBrowser/input'

const EXECUTION_MODES = ['design', 'live']
Expand Down
4 changes: 2 additions & 2 deletions app/gui2/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { baseConfig, configValue, mergeConfig } from '@/util/config'
import { isDevMode } from '@/util/detect'
import { urlParams } from '@/util/urlParams'
import { run as runDashboard } from 'enso-authentication'
import { isOnLinux } from 'enso-common/src/detect'
import * as dashboard from 'enso-dashboard'
import 'enso-dashboard/src/tailwind.css'

const INITIAL_URL_KEY = `Enso-initial-url`
Expand Down Expand Up @@ -106,7 +106,7 @@ function main() {
const projectManagerUrl = config.engine.projectManagerUrl || PROJECT_MANAGER_URL
const initialProjectName = config.startup.project || null

runDashboard({
dashboard.run({
appRunner,
logger: console,
supportsLocalBackend: !IS_CLOUD_BUILD,
Expand Down
2 changes: 1 addition & 1 deletion app/gui2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [],
"references": [
{
"path": "../ide-desktop/lib/dashboard/src/authentication/tsconfig.json"
"path": "../ide-desktop/lib/dashboard/tsconfig.json"
},
{
"path": "./tsconfig.node.json"
Expand Down
8 changes: 8 additions & 0 deletions app/ide-desktop/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"javascript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifierEnding": "minimal",
"typescript.preferences.importModuleSpecifierEnding": "minimal",
"javascript.updateImportsOnFileMove.enabled": "always",
"typescript.updateImportsOnFileMove.enabled": "always"
}
41 changes: 0 additions & 41 deletions app/ide-desktop/debugGlobals.ts

This file was deleted.

19 changes: 3 additions & 16 deletions app/ide-desktop/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const NAME = 'enso'
* `yargs` is a modules we explicitly want the default imports of.
* `node:process` is here because `process.on` does not exist on the namespace import. */
const DEFAULT_IMPORT_ONLY_MODULES =
'node:process|chalk|string-length|yargs|yargs\\u002Fyargs|sharp|to-ico|connect|morgan|serve-static|create-servers|electron-is-dev|fast-glob|esbuild-plugin-.+|opener|tailwindcss.*|enso-assets.*|@modyfi\\u002Fvite-plugin-yaml|validator.+'
const ALLOWED_DEFAULT_IMPORT_MODULES = `${DEFAULT_IMPORT_ONLY_MODULES}|postcss`
'@vitejs\\u002Fplugin-react|node:process|chalk|string-length|yargs|yargs\\u002Fyargs|sharp|to-ico|connect|morgan|serve-static|create-servers|electron-is-dev|fast-glob|esbuild-plugin-.+|opener|tailwindcss.*|enso-assets.*|@modyfi\\u002Fvite-plugin-yaml|validator.+'
const OUR_MODULES = 'enso-.*'
const RELATIVE_MODULES =
'bin\\u002Fproject-manager|bin\\u002Fserver|config\\u002Fparser|authentication|config|debug|detect|file-associations|index|ipc|log|naming|paths|preload|project-management|security|url-associations'
'bin\\u002Fproject-manager|bin\\u002Fserver|config\\u002Fparser|authentication|config|debug|detect|file-associations|index|ipc|log|naming|paths|preload|project-management|security|url-associations|#\\u002F.*'
const ALLOWED_DEFAULT_IMPORT_MODULES = `${DEFAULT_IMPORT_ONLY_MODULES}|postcss|${RELATIVE_MODULES}`
const STRING_LITERAL = ':matches(Literal[raw=/^["\']/], TemplateLiteral)'
const JSX = ':matches(JSXElement, JSXFragment)'
const NOT_PASCAL_CASE = '/^(?!do[A-Z])(?!_?([A-Z][a-z0-9]*)+$)/'
Expand Down Expand Up @@ -89,10 +89,6 @@ const RESTRICTED_SYNTAXES = [
selector: `:matches(ImportDefaultSpecifier[local.name=/^${NAME}/i], ImportNamespaceSpecifier > Identifier[name=/^${NAME}/i])`,
message: `Don't prefix modules with \`${NAME}\``,
},
{
selector: 'ExportAllDeclaration',
message: 'No re-exports',
},
{
selector: 'TSTypeLiteral',
message: 'No object types - use interfaces instead',
Expand Down Expand Up @@ -299,7 +295,6 @@ export default [
],
},
],
'sort-imports': ['error', { allowSeparatedGroups: true }],
'no-constant-condition': ['error', { checkLoops: false }],
'no-restricted-properties': [
'error',
Expand Down Expand Up @@ -516,10 +511,6 @@ export default [
property: 'useDebugCallback',
message: 'Avoid leaving debugging statements when committing code',
},
{
property: '$d$',
message: 'Avoid leaving debugging statements when committing code',
},
],
},
},
Expand Down Expand Up @@ -559,10 +550,6 @@ export default [
property: 'useDebugCallback',
message: 'Avoid leaving debugging statements when committing code',
},
{
property: '$d$',
message: 'Avoid leaving debugging statements when committing code',
},
{
object: 'page',
property: 'type',
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"dmg-license": "^1.0.11"
},
"scripts": {
"typecheck": "npm run --workspace=enso-gui2 compile-server && tsc --noEmit",
"typecheck": "npm run --workspace=enso-gui2 compile-server && tsc --build",
"start": "tsx start.ts",
"build": "tsx bundle.ts",
"dist": "tsx dist.ts",
Expand Down
6 changes: 2 additions & 4 deletions app/ide-desktop/lib/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
"include": [
".",
"../content",
"../dashboard",
"../types",
"../../utils.ts",
"../../../../build.json"
],
"references": [
{
"path": "../../../gui2/tsconfig.server.json"
}
{ "path": "../../../gui2/tsconfig.server.json" },
{ "path": "../dashboard" }
]
}
6 changes: 0 additions & 6 deletions app/ide-desktop/lib/client/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import * as childProcess from 'node:child_process'
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import * as url from 'node:url'
import process from 'node:process'

import * as esbuild from 'esbuild'
Expand All @@ -35,8 +34,6 @@ interface Watches {
// === Constants ===
// =================

/** The path of this file. */
const THIS_PATH = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
const IDE_DIR_PATH = paths.getIdeDirectory()
const PROJECT_MANAGER_BUNDLE_PATH = paths.getProjectManagerBundlePath()

Expand Down Expand Up @@ -110,9 +107,6 @@ const ALL_BUNDLES_READY = new Promise<Watches>((resolve, reject) => {
},
})
contentOpts.pure.splice(contentOpts.pure.indexOf('assert'), 1)
;(contentOpts.inject = contentOpts.inject ?? []).push(
path.resolve(THIS_PATH, '..', '..', 'debugGlobals.ts')
)
contentOpts.outdir = path.resolve(IDE_DIR_PATH, 'assets')
contentOpts.define.REDIRECT_OVERRIDE = JSON.stringify('http://localhost:8080')
const contentBuilder = await esbuild.context(contentOpts)
Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/content/esbuild-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function bundlerOptions(args: Arguments) {
'.ttf': 'copy',
},
entryPoints: [
pathModule.resolve(THIS_PATH, 'src', 'index.ts'),
pathModule.resolve(THIS_PATH, 'src', 'entrypoint.ts'),
pathModule.resolve(THIS_PATH, 'src', 'index.html'),
pathModule.resolve(THIS_PATH, 'src', 'run.js'),
pathModule.resolve(THIS_PATH, 'src', 'style.css'),
Expand Down
4 changes: 2 additions & 2 deletions app/ide-desktop/lib/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "https://github.com/enso-org/ide/issues"
},
"scripts": {
"typecheck": "tsc --noEmit",
"typecheck": "tsc --build",
"build": "tsx bundle.ts",
"watch": "tsx watch.ts",
"start": "tsx start.ts"
Expand All @@ -37,7 +37,7 @@
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"enso-authentication": "^1.0.0",
"enso-dashboard": "^0.1.0",
"esbuild": "^0.19.3",
"esbuild-plugin-copy-directories": "^1.0.0",
"esbuild-plugin-time": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as toastify from 'react-toastify'
import * as app from 'ensogl-runner/src/runner'
import * as common from 'enso-common'
import * as contentConfig from 'enso-content-config'
import * as dashboard from 'enso-authentication'
import * as dashboard from 'enso-dashboard'
import * as detect from 'enso-common/src/detect'
import * as gtag from 'enso-common/src/gtag'

Expand Down
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/content/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<link rel="stylesheet" href="./style.css" />
<!-- Generated by the build script based on the Enso Font package. -->
<link rel="stylesheet" href="./ensoFont.css" />
<script type="module" src="./index.js" defer></script>
<script type="module" src="./entrypoint.js" defer></script>
<script type="module" src="./run.js" defer></script>
</head>
<body>
Expand Down
16 changes: 7 additions & 9 deletions app/ide-desktop/lib/content/src/remoteLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* {@link RemoteLogger} provides a convenient way to manage remote logging with access token authorization. */

import * as app from 'ensogl-runner/src/runner'
import * as authConfig from '../../dashboard/src/authentication/src/config'
import * as authConfig from '../../dashboard/src/utilities/config'

const logger = app.log.logger

Expand Down Expand Up @@ -50,14 +50,12 @@ export async function remoteLog(
metadata: unknown
): Promise<void> {
try {
const headers: HeadersInit = new Headers()
headers.set('Content-Type', 'application/json')
headers.set('Authorization', `Bearer ${accessToken}`)
const response = await fetch(REMOTE_LOG_URL, {
method: 'POST',
headers,
body: JSON.stringify({ message, metadata }),
})
const headers: HeadersInit = [
['Content-Type', 'application/json'],
['Authorization', `Bearer ${accessToken}`],
]
const body = JSON.stringify({ message, metadata })
const response = await fetch(REMOTE_LOG_URL, { method: 'POST', headers, body })
if (!response.ok) {
const errorMessage = `Error while sending log to a remote: Status ${response.status}.`
try {
Expand Down
9 changes: 2 additions & 7 deletions app/ide-desktop/lib/content/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"extends": "../../tsconfig.json",
"include": [
"../types",
"../../utils.ts",
"../../../../build.json",
"../dashboard",
"."
]
"include": ["../types", "../../utils.ts", "../../../../build.json", "."],
"references": [{ "path": "../dashboard" }]
}
1 change: 0 additions & 1 deletion app/ide-desktop/lib/content/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ async function watch() {
})
)
opts.pure.splice(opts.pure.indexOf('assert'), 1)
;(opts.inject = opts.inject ?? []).push(path.resolve(THIS_PATH, '..', '..', 'debugGlobals.ts'))
opts.define.REDIRECT_OVERRIDE = JSON.stringify('http://localhost:8080')
// This is safe as this entry point is statically known.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Expand Down
36 changes: 36 additions & 0 deletions app/ide-desktop/lib/dashboard/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/** @file Prettier configuration. */
// @ts-check
/** @type {import("@ianvs/prettier-plugin-sort-imports").PrettierConfig} */
module.exports = {
overrides: [
{
files: ['*.[j|t]s', '*.[j|t]sx', '*.m[j|t]s', '*.c[j|t]s'],
options: {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
printWidth: 100,
tabWidth: 4,
semi: false,
singleQuote: true,
trailingComma: 'es5',
arrowParens: 'avoid',
plugins: ['@ianvs/prettier-plugin-sort-imports'],
// This plugin's options
importOrder: [
'^react$',
'',
'<THIRD_PARTY_MODULES>',
'',
'^enso-',
'',
'^#[/](?!components[/]).*$',
'',
'^#[/]components[/]',
'',
'^[.]',
],
importOrderParserPlugins: ['typescript', 'jsx', 'importAssertions'],
importOrderTypeScriptVersion: '5.0.0',
},
},
],
}
2 changes: 1 addition & 1 deletion app/ide-desktop/lib/dashboard/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function bundle() {
})
opts.entryPoints.push(
path.resolve(THIS_PATH, 'src', 'index.html'),
path.resolve(THIS_PATH, 'src', 'index.ts')
path.resolve(THIS_PATH, 'src', 'entrypoint.ts')
)
opts.metafile = ANALYZE
opts.loader['.html'] = 'copy'
Expand Down
12 changes: 8 additions & 4 deletions app/ide-desktop/lib/dashboard/esbuild-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import * as url from 'node:url'

import type * as esbuild from 'esbuild'
import * as esbuildPluginNodeModules from '@esbuild-plugins/node-modules-polyfill'
import type * as esbuild from 'esbuild'
import esbuildPluginInlineImage from 'esbuild-plugin-inline-image'
import esbuildPluginTime from 'esbuild-plugin-time'
import esbuildPluginYaml from 'esbuild-plugin-yaml'

import postcss from 'postcss'
import tailwindcss from 'tailwindcss'
import tailwindcssNesting from 'tailwindcss/nesting/index.js'

import * as tailwindConfig from './tailwind.config'
import * as utils from '../../utils'
import * as tailwindConfig from './tailwind.config'

// =================
// === Constants ===
Expand Down Expand Up @@ -67,7 +66,9 @@ export function esbuildPluginGenerateTailwind(): esbuild.Plugin {
)
build.onLoad({ filter: /tailwind\.css$/ }, async loadArgs => {
const content = await fs.readFile(loadArgs.path, 'utf8')
const result = await cssProcessor.process(content, { from: loadArgs.path })
const result = await cssProcessor.process(content, {
from: loadArgs.path,
})
return {
contents: result.content,
loader: 'css',
Expand Down Expand Up @@ -117,6 +118,9 @@ export function bundlerOptions(args: Arguments) {
esbuildPluginYaml.yamlPlugin({}),
esbuildPluginGenerateTailwind(),
],
alias: {
'#': './src',
},
define: {
// We are defining constants, so it should be `CONSTANT_CASE`.
/* eslint-disable @typescript-eslint/naming-convention */
Expand Down
Loading
Loading