1

我努力理解这个keystonejs项目https://github.com/keystonejs/keystone的目标,它基于其中的许多模块和其中的许多 package.json。

它也包含根 package.json。

它基于 react 17 和节点 14/16 和 graphql。

包结构根

子模块的封装结构

根包.json

{
  "name": "@keystone-6/mono-repo",
  "description": "KeystoneJS monorepo for all the @keystone-6 packages",
  "private": true,
  "version": "0.0.0",
  "author": "The KeystoneJS Development Team",
  "license": "MIT",
  "repository": "https://github.com/keystonejs/keystone",
  "homepage": "https://github.com/keystonejs/keystone",
  "scripts": {
    "prisma": "prisma",
    "docs": "manypkg run @keystone-6/website dev",
    "coverage": "cross-env DISABLE_LOGGING=true NODE_ENV=test jest --runInBand --coverage",
    "format:file": "prettier --write",
    "format": "prettier --write \"**/*.{js,json,ts,tsx,md,mdx}\" && remark . --output",
    "fresh": "yarn clean && yarn",
    "clean": "rimraf \"**/node_modules\" \"**/yarn-error.log\" \"**/out.log\" \"**/.DS_Store\" \"**/dist\"",
    "lint:eslint": "eslint . --ext ts,tsx,js",
    "lint:prettier": "prettier --list-different \"**/*.{js,json,ts,tsx}\"",
    "lint:markdown": "remark . --frail --quiet",
    "lint:types": "tsc",
    "lint": "yarn lint:prettier && yarn lint:eslint && yarn lint:markdown && yarn lint:types && yarn lint:filters",
    "test": "yarn lint && yarn test:unit",
    "test:unit": "cross-env DISABLE_LOGGING=true NODE_ENV=test jest --no-watchman --runInBand --logHeapUsage",
    "test:unit:debug": "cross-env NODE_ENV=test node --inspect-brk `which jest` --runInBand",
    "test:admin-ui": "yarn jest tests/admin-ui-tests",
    "benchmark": "yarn workspace @keystone-6/benchmarks-legacy go",
    "changeset": "changeset",
    "publish-changed": "yarn build && changeset publish --public",
    "version-packages": "changeset version",
    "build": "preconstruct build",
    "prepare": "manypkg check && preconstruct dev && yarn run --silent contributing-guide && node scripts/generate-artifacts-for-projects",
    "contributing-guide": "is-ci && exit 0 || chalk -t \"{bold  Contributing to KeystoneJS?}\" && terminal-link \" Read the full Contributing Guide\" \"https://github.com/keystonejs/keystone/blob/main/CONTRIBUTING.md\"",
    "npm-tag": "manypkg npm-tag",
    "update": "manypkg upgrade",
    "update-project-schemas": "cross-env UPDATE_SCHEMAS=1 node scripts/generate-artifacts-for-projects",
    "generate-filters": "cd prisma-utils && yarn generate",
    "lint:filters": "cd prisma-utils && yarn verify"
  },
  "dependencies": {
    "@babel/core": "^7.16.0",
    "@babel/plugin-proposal-class-properties": "^7.16.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@babel/plugin-transform-runtime": "^7.16.0",
    "@babel/preset-env": "^7.16.0",
    "@babel/preset-react": "^7.16.0",
    "@babel/preset-typescript": "^7.16.0",
    "@changesets/changelog-github": "^0.4.1",
    "@changesets/cli": "^2.18.0",
    "@jest/test-sequencer": "^27.3.1",
    "@manypkg/cli": "^0.19.1",
    "@preconstruct/cli": "2.1.5",
    "@preconstruct/eslint-plugin-format-js-tag": "^0.2.0",
    "@testing-library/jest-dom": "^5.15.0",
    "@types/babel__core": "^7.1.16",
    "@types/jest": "^27.0.2",
    "@types/node-fetch": "^2.5.12",
    "@types/normalize-path": "3.0.0",
    "@typescript-eslint/eslint-plugin": "^5.7.0",
    "@typescript-eslint/parser": "^5.7.0",
    "chalk-cli": "^5.0.0",
    "cross-env": "^7.0.3",
    "eslint": "^7.32.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jest": "^25.2.4",
    "eslint-plugin-react": "^7.27.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "is-ci": "^3.0.1",
    "jest": "^27.3.1",
    "prettier": "^2.5.0",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "remark-cli": "^6.0.1",
    "remark-frontmatter": "^1.3.3",
    "remark-toc": "^5.1.1",
    "rimraf": "^3.0.2",
    "terminal-link-cli": "^3.0.0",
    "typescript": "^4.4.4"
  },
  "prettier": {
    "proseWrap": "preserve",
    "singleQuote": true,
    "trailingComma": "es5",
    "printWidth": 100,
    "arrowParens": "avoid",
    "overrides": [
      {
        "files": "docs/**",
        "options": {
          "embeddedLanguageFormatting": "off"
        }
      }
    ]
  },
  "remarkConfig": {
    "settings": {
      "commonmark": true,
      "fences": true,
      "listItemIndent": "1",
      "rule": "-",
      "ruleSpaces": false
    },
    "plugins": [
      "remark-frontmatter",
      "remark-toc"
    ]
  },
  "workspaces": {
    "packages": [
      "design-system/packages/*",
      "design-system/website",
      "docs",
      "examples-staging/*",
      "examples/*",
      "packages/*",
      "tests/admin-ui-tests",
      "tests/api-tests",
      "tests/benchmarks",
      "tests/examples-smoke-tests",
      "tests/test-projects/*",
      "prisma-utils",
      "scripts/*"
    ]
  },
  "preconstruct": {
    "packages": [
      "packages/*",
      "design-system/packages/*",
      "prisma-utils",
      "scripts/*"
    ]
  },
  "manypkg": {
    "defaultBranch": "main"
  },
  "jest": {
    "setupFilesAfterEnv": [
      "./tests/jest/setup.ts"
    ],
    "testSequencer": "./tests/jest/jest-sequencer.js",
    "testEnvironment": "node",
    "testPathIgnorePatterns": [
      "/node_modules/"
    ],
    "transformIgnorePatterns": [
      "/node_modules/",
      "\\.pnp\\.[^\\/]+$"
    ],
    "collectCoverageFrom": [
      "packages/**/*.{js,ts,tsx}",
      "!**/*.d.ts",
      "!packages/**/dist/**",
      "!packages/keystone/src/fields/**/test-fixtures.{js,ts}"
    ]
  },
  "resolutions": {
    "babel-plugin-remove-graphql-queries": "2.7.2"
  },
  "engines": {
    "node": "^14.15 || ^16.13"
  }
}

这个存储库代码 keystonejs 框架本身吗?如果是,我应该在本地 keystonejs 框架中使用它作为依赖项吗?

我们可以在本地运行这个项目吗?或者我们可以创建这个 docker 图像吗?

谁能给我一些建议,因为我无法理解这个回购背后的主要目的?

即使我尝试在 dockerfile 下面创建它的图像,但没有成功,最终遇到了一些与 yarn 的运行命令相关的问题

# https://docs.docker.com/samples/library/node/
ARG NODE_VERSION=16.13
# https://github.com/Yelp/dumb-init/releases
ARG DUMB_INIT_VERSION=1.2.2

# Build container
FROM node:${NODE_VERSION}-alpine AS build
ARG DUMB_INIT_VERSION

WORKDIR /home/node

RUN apk add --no-cache build-base python2 yarn && \
    wget -O dumb-init -q https://github.com/Yelp/dumb-init/releases/download/v${DUMB_INIT_VERSION}/dumb-init_${DUMB_INIT_VERSION}_amd64 && \
    chmod +x dumb-init
ADD ./package.json ./package.json
ADD ./yarn.lock ./yarn.lock

RUN yarn install

ADD . /home/node

RUN yarn build && yarn cache clean

# Runtime container
FROM node:${NODE_VERSION}-alpine

WORKDIR /home/node

COPY --from=build /home/node /home/node

EXPOSE 3000
CMD ["./dumb-init", "yarn", "start"]

错误:

[+] Building 50.6s (11/14)                                                                                                                                                                   
 => [internal] load build definition from Dockerfile                                                                                                                                    0.0s
 => => transferring dockerfile: 813B                                                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                                                       0.0s
 => => transferring context: 34B                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/node:16.13-alpine                                                                                                                    3.3s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                             0.0s
 => [internal] load build context                                                                                                                                                       1.2s
 => => transferring context: 635.00kB                                                                                                                                                   1.2s
 => [build 1/8] FROM docker.io/library/node:16.13-alpine@sha256:2f50f4a428f8b5280817c9d4d896dbee03f072e93f4e0c70b90cc84bd1fcfe0d                                                        0.0s
 => CACHED [build 2/8] WORKDIR /home/node                                                                                                                                               0.0s
 => CACHED [build 3/8] RUN apk add --no-cache build-base python2 yarn &&     wget -O dumb-init -q https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 &&   0.0s
 => CACHED [build 4/8] ADD ./package.json ./package.json                                                                                                                                0.0s
 => CACHED [build 5/8] ADD ./yarn.lock ./yarn.lock                                                                                                                                      0.0s
 => ERROR [build 6/8] RUN yarn install                                                                                                                                                 46.0s
------
 > [build 6/8] RUN yarn install:
#11 0.589 yarn install v1.22.15
#11 0.743 [1/5] Validating package.json...
#11 0.750 [2/5] Resolving packages...
#11 1.840 [3/5] Fetching packages...
#11 35.27 info fsevents@2.3.2: The platform "linux" is incompatible with this module.
#11 35.27 info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
#11 35.29 info fsevents@1.2.13: The platform "linux" is incompatible with this module.
#11 35.29 info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
#11 35.30 [4/5] Linking dependencies...
#11 35.30 warning " > babel-plugin-remove-graphql-queries@2.7.2" has unmet peer dependency "gatsby@^2.0.0".
#11 35.30 warning " > babel-plugin-remove-graphql-queries@2.7.2" has unmet peer dependency "graphql@^14.1.1".
#11 43.78 [5/5] Building fresh packages...
#11 44.28 success Saved lockfile.
#11 44.29 $ manypkg check && preconstruct dev && yarn run --silent contributing-guide && node scripts/generate-artifacts-for-projects
#11 44.58 ☔️ success workspaces valid!
#11 45.09  info project is valid!
#11 45.09  success created links!
#11 45.57  Contributing to KeystoneJS?
#11 45.75  Read the full Contributing Guide (​https://github.com/keystonejs/keystone/blob/main/CONTRIBUTING.md​)
#11 45.80 node:internal/modules/cjs/loader:936
#11 45.80   throw err;
#11 45.80   ^
#11 45.80 
#11 45.80 Error: Cannot find module '/home/node/scripts/generate-artifacts-for-projects'
#11 45.80     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
#11 45.80     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
#11 45.80     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
#11 45.80     at node:internal/main/run_main_module:17:47 {
#11 45.80   code: 'MODULE_NOT_FOUND',
#11 45.80   requireStack: []
#11 45.80 }
#11 45.81 error Command failed with exit code 1.
#11 45.81 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
executor failed running [/bin/sh -c yarn install]: exit code: 1


我想知道这个回购的意图。

4

2 回答 2

2

这是 Keystone JS 的 repo,一个无头内容管理系统。

Keystone 网站https://keystonejs.com有材料解释该项目以及如何使用它。

于 2022-01-28T00:43:11.707 回答
1

KeystoneJS 将自己描述为“开发人员的 CMS”。正如@rasterisk 在他们的回答中所说,官方网站提供了更多一般信息,可以帮助您确定自己的方向或查看Keystone 文档网站了解详细信息。

这个存储库代码 keystonejs 框架本身吗?

是的。根据package.json您发布的根目录中的描述,它是“所有 @keystone-6 包的 KeystoneJS monorepo”。

网上有很多关于什么是 monorepos 以及如何使用它们的好信息。Keystone 背后的团队甚至编写了一个公会,描述了他们的一些具体做法和工具。

我应该在本地 keystonejs 框架中使用它作为依赖项吗?

你的意思是你本地的 KeystoneJS 应用程序?嗯,是的,但是你应该需要@keystone-6/core来自 npm 的包,而不是直接声明对 git repo 的依赖。示例项目显示了这是如何完成的。

或者,入门指南将开始使用该create-keystone-app命令。该工具会询问您几个问题,然后自动创建初始项目文件(包括package.json具有正确依赖项的文件)。

我们可以在本地运行这个项目吗?

您可以直接从 Keystone 存储库运行 Keystone 应用程序(如示例),如下所示:

# Clone the repo and switch into the dir
git clone git@github.com:keystonejs/keystone.git
cd keystone

# Install Keystone's dependencies
yarn

# Start the "task-manager" example project in dev mode
# This will create a local SQLite DB with the DB schema for this project 
# and start a server at localhost:3000
yarn --cwd examples/task-manager dev

但是,除非您修改 Keystone 代码本身,否则这可能不是您想要做的。有关如何创建需要 Keystone 作为包的项目,请参阅上一个答案。

..或者我们可以创建这个的docker镜像吗?

如上所述,创建 Keystone 存储库本身的 docker 映像并没有什么意义。您可能希望首先使用Keystone 创建一个项目,然后从中创建一个图像。

于 2022-01-28T03:44:31.630 回答