我创建了一个 Github 存储库,该存储库具有构建 npm 包并将其发布到 npmjs.com 的操作。我采取行动的触发因素是在 Github 中创建一个新版本。创建新版本时,Github 要求我提供版本号。我很想在 Action 中使用这个版本号并将其提供给 yarn publish 命令。
我的 ci 文件看起来像这样(我去掉了一些在这里不重要的部分):
name: Deploy npm package
on:
release:
types: [created]
jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: yarn install
- run: yarn build
- run: yarn publish --new-version ${...}
env:a
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
Run Code Online (Sandbox Code Playgroud)
是否有包含发布版本号的环境变量?
我们有一个 node.js/typescript 项目,现在我应该为我们的声纳分析提供数据。
我们使用 docker 容器来运行我们的测试,在测试完成后,我们正在运行声纳分析,以便我们可以使用测试中的代码覆盖率报告。
唯一的问题是,缺少责备信息。这就是为什么我试图将 .git 文件夹复制到 docker 容器中,但到目前为止我没有成功。这是我的 Dockerfile 的内容。
FROM node:11.6-alpine
RUN apk --update add openjdk8-jre
WORKDIR /dist
COPY package*.json ./
RUN npm install
COPY src/ ./src/
COPY test/ ./test/
COPY ts*.json ./
COPY sonar-project.properties ./
COPY test.sh /
COPY .git/ ./
RUN chmod +x /test.sh
CMD ["sh", "/test.sh"]
Run Code Online (Sandbox Code Playgroud)
我读过,.dockerignore 文件可用于排除文件或文件夹,但我们没有使用这样的文件,我也尝试创建一个只包含 node_modules 的文件,但这也不起作用。
有没有人知道如何包含它或任何提示谷歌的内容?我只找到“如何从 docker 容器中排除 .git”,但到目前为止恢复这些提示并没有帮助。
编辑:为了使它更陌生,使用COPY . ./
将 .git 文件夹包含到图像中。
我有一个 NestJs 应用程序,它使用两种服务。连接到 Db 的 DbService 和执行速度相当慢并使用注入的 DbService 的 SlowService。
现在应用程序将提供 api 基本路径之外的健康路线,所以我需要一个不同的模块来为健康路线提供控制器。
我创建了一个基本模块。
import { Module } from '@nestjs/common'
import { SlowService } from './slow.service'
import { DbService } from './db.service'
@Module({
imports: [],
controllers: [],
providers: [DbService, SlowService],
exports: [DbService, SlowService]
})
export class BaseModule {
}
Run Code Online (Sandbox Code Playgroud)
ApiModule 和 HealthModule 现在都导入了基本模块以便能够使用这些服务。
imports: [BaseModule],
Run Code Online (Sandbox Code Playgroud)
只有一个小问题。两个模块似乎都构建了自己的服务实例,但我需要它是同一个实例。我假设是这样,因为在启动应用程序时,构造函数中的 console.log 出现了两次。我错过了设置还是什么?
更新
这是我的引导程序方法,因此您可以看到我如何初始化模块。
async function bootstrap (): Promise<void> {
const server = express()
const api = await NestFactory.create(AppModule, server.application, { cors: true }) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Azure Functions httpTrigger 调用从我的数据库中删除一个项目。
import { CosmosClient, } from '@azure/cosmos'
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
const client = new CosmosClient(process.env.cosmosDB)
const database = client.database('testDB');
const container = database.container('workers');
const item = container.item('28a31558-ff8c-40c3-a7e8-1e8904c5ff72', '/id')
console.log(await item.delete())
}
Run Code Online (Sandbox Code Playgroud)
我什至尝试将值硬编码到代码中(如您所见),但我总是会收到 404 not found 错误:
Executed 'Functions.worker-delete' (Failed, Id=81ab43cf-a223-48af-89e1-a15676346ef0)
System.Private.CoreLib: Exception while executing function: Functions.worker-delete. System.Private.CoreLib: Result: Failure
Exception: Error: Entity with the specified id does not exist in the system.,
RequestStartTime: 2020-05-11T12:30:44.4010890Z, RequestEndTime: 2020-05-11T12:30:44.4010890Z, Number …
Run Code Online (Sandbox Code Playgroud)