Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: Move package.json and other front-end collateral into 'site'#128

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bryphe-coder merged 5 commits intomainfrombryphe/refactor/package-to-site
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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
8 changes: 7 additions & 1 deletion.github/workflows/coder.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,9 +61,11 @@ jobs:

- name: Install node_modules
run: yarn install
working-directory: site

- name: "yarn lint"
run: yarn lint
working-directory: site

gen:
name: "style/gen"
Expand DownExpand Up@@ -113,6 +115,7 @@ jobs:

- name: Install node_modules
run: yarn install
working-directory: site

- name: "make ${{ matrix.style }}"
run: "make --output-sync -j ${{ matrix.style }}"
Expand DownExpand Up@@ -194,15 +197,18 @@ jobs:
node-version: "14"

- run: yarn install
working-directory: site

- run: yarn build
working-directory: site

- run: yarn test:coverage
working-directory: site

- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
files: ./site/coverage/lcov.info
flags: unittest-js
fail_ci_if_error: true
5 changes: 4 additions & 1 deletion.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,9 +16,12 @@ yarn-error.log

# Front-end ignore
.next/
site/.eslintcache
site/.next/
site/node_modules/
site/yarn-error.log
coverage/

# Build
bin/
site/out/
site/out/
8 changes: 4 additions & 4 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,9 +26,9 @@ fmt/prettier:
@echo "--- prettier"
# Avoid writing files in CI to reduce file write activity
ifdef CI
yarn run format:check
cd site &&yarn run format:check
else
yarn run format:write
cd site &&yarn run format:write
endif
.PHONY: fmt/prettier

Expand DownExpand Up@@ -74,6 +74,6 @@ provisionersdk/proto: provisionersdk/proto/provisioner.proto
.PHONY: provisionersdk/proto

site/out:
yarn build
yarn export
cd site &&yarn build
cd site &&yarn export
.PHONY: site/out
36 changes: 0 additions & 36 deletionsjest.config.js
View file
Open in desktop

This file was deleted.

5 changes: 4 additions & 1 deletion.eslintignore → site/.eslintignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,4 +2,7 @@
# COPY PASTA OF .gitignore
###############################################################################
node_modules
vendor
vendor
out
coverage
.next
3 changes: 1 addition & 2 deletions.eslintrc.yaml → site/.eslintrc.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,7 @@ parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: 2018
project:
- "./tsconfig.json"
- "./site/tsconfig.json"
- "./tsconfig.test.json"
sourceType: module
ecmaFeatures:
jsx: true
Expand Down
5 changes: 2 additions & 3 deletions.prettierignore → site/.prettierignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,5 @@ yarn-error.log

# Front-end ignore
.next/
site/.next/
site/out/
coverage/
coverage/
out/
File renamed without changes.
3 changes: 3 additions & 0 deletions_jest/setupTests.ts → site/_jest/setupTests.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,3 +5,6 @@
// Set up 'next-router-mock' to with our front-end tests:
// https://github.com/scottrippey/next-router-mock#quick-start
jest.mock("next/router", () => require("next-router-mock"))

// Suppress isolated modules warning
export {}
7 changes: 6 additions & 1 deletionsite/components/ErrorSummary/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
import React from "react"

export interface ErrorSummaryProps {
error: Error
error: Error | undefined
}

export const ErrorSummary: React.FC<ErrorSummaryProps> = ({ error }) => {
// TODO: More interesting error page

if (typeof error === "undefined") {
return <div>{"Unknown error"}</div>
}

return <div>{error.toString()}</div>
}
File renamed without changes.
41 changes: 41 additions & 0 deletionssite/jest.config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
module.exports = {
projects: [
{
globals: {
"ts-jest": {
tsconfig: "tsconfig.test.json",
},
},
coverageReporters: ["text", "lcov"],
displayName: "test",
preset: "ts-jest",
roots: ["<rootDir>"],
setupFilesAfterEnv: ["<rootDir>/_jest/setupTests.ts"],
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testEnvironment: "jsdom",
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
testPathIgnorePatterns: ["/node_modules/", "/__tests__/fakes"],
moduleDirectories: ["node_modules", "<rootDir>"],
},
{
displayName: "lint",
runner: "jest-runner-eslint",
testMatch: ["<rootDir>/**/*.js", "<rootDir>/**/*.ts", "<rootDir>/**/*.tsx"],
testPathIgnorePatterns: ["/.next/", "/out/", "/_jest/", "jest.config.js", "jest-runner.*.js", "next.config.js"],
},
],
collectCoverageFrom: [
"<rootDir>/**/*.js",
"<rootDir>/**/*.ts",
"<rootDir>/**/*.tsx",
"!<rootDir>/**/*.stories.tsx",
"!<rootDir>/.next/**/*.*",
"!<rootDir>/api.ts",
"!<rootDir>/dev.ts",
"!<rootDir>/next-env.d.ts",
"!<rootDir>/next.config.js",
"!<rootDir>/out/**/*.*",
],
}
8 changes: 4 additions & 4 deletionspackage.json → site/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,10 @@
"repository": "https://github.com/coder/coder",
"private": true,
"scripts": {
"build": "NODE_ENV=production next build site",
"build:dev": "next build site",
"dev": "ts-nodesite/dev.ts",
"export": "next export site",
"build": "NODE_ENV=production next build",
"build:dev": "next build",
"dev": "ts-node dev.ts",
"export": "next export",
"format:check": "prettier --check '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}'",
"format:write": "prettier --write '**/*.{css,html,js,json,jsx,md,ts,tsx,yaml,yml}' && sql-formatter -l postgresql ./database/query.sql -o ./database/query.sql",
"lint": "jest --selectProjects lint",
Expand Down
4 changes: 2 additions & 2 deletionssite/pages/projects/[organization]/[project]/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -78,8 +78,8 @@ const ProjectPage: React.FC = () => {
<div className={styles.root}>
<Navbar user={me} onSignOut={signOut} />
<Header
title={firstOrItem(project)}
description={firstOrItem(organization)}
title={firstOrItem(project, "")}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

There were a couple places where the type-checks became stricter! I figured it was easier to leave them on in the stricter mode, and fix them, then to figure out how to turn them off

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yup, agreed!

bryphe-coder reacted with hooray emoji
description={firstOrItem(organization, "")}
subTitle={`${workspaces.length} workspaces`}
action={{
text: "Create Workspace",
Expand Down
6 changes: 3 additions & 3 deletionssite/tsconfig.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
Expand All@@ -13,12 +12,13 @@
"isolatedModules": true,
"lib": ["dom", "dom.iterable", "esnext"],
"skipLibCheck": true,
"strict": false,
"strict": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"moduleResolution": "node"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "_jest"]
}
2 changes: 2 additions & 0 deletionstsconfig.json → site/tsconfig.test.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"jsx": "react",
"downlevelIteration": true,
"strict": true,
"strictNullChecks": true,
"esModuleInterop": true
}
}
6 changes: 3 additions & 3 deletionssite/util/array.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,15 +3,15 @@ import { firstOrItem } from "./array"
describe("array", () => {
describe("firstOrItem", () => {
it("returns null if empty array", () => {
expect(firstOrItem([])).toBeNull()
expect(firstOrItem([], null)).toBeNull()
})

it("returns first item if array with more one item", () => {
expect(firstOrItem(["a", "b"])).toEqual("a")
expect(firstOrItem(["a", "b"], "c")).toEqual("a")
})

it("returns item if single item", () => {
expect(firstOrItem("c")).toEqual("c")
expect(firstOrItem("c", "d")).toEqual("c")
})
})
})
8 changes: 6 additions & 2 deletionssite/util/array.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,9 +4,13 @@
* - If an array with 1 or more elements, returns the first element
* - If a single item, returns that item
*/
export const firstOrItem = <T>(itemOrItems: T | T[]): T | null => {
export const firstOrItem = <T>(itemOrItems:undefined |T | T[], defaults: T): T => {
if (Array.isArray(itemOrItems)) {
return itemOrItems.length > 0 ? itemOrItems[0] : null
return itemOrItems.length > 0 ? itemOrItems[0] : defaults
}

if (typeof itemOrItems === "undefined") {
return defaults
}

return itemOrItems
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp