Skip to content

Commit

Permalink
fix: use node: to prefix native nodejs module
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Jan 18, 2025
1 parent 93a1d65 commit 94eaa02
Show file tree
Hide file tree
Showing 35 changed files with 76 additions and 57 deletions.
2 changes: 1 addition & 1 deletion packages/cli-core/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Create a new file according to your project name (example: `name.ts`) and add th
```typescript
#!/usr/bin/env node
import {AddCmd, CliCore} from "@tsed/cli-core";
import {resolve} from "path";
import {resolve} from "node:path";

const pkg = require("../../package.json");
const TEMPLATE_DIR = resolve(__dirname, "..", "..", "templates");
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/CliCore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {join, resolve} from "node:path";

import {Type} from "@tsed/core";
import {inject, InjectorService, Module} from "@tsed/di";
import chalk from "chalk";
import {Command} from "commander";
import {join, resolve} from "path";
import semver from "semver";
import updateNotifier from "update-notifier";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {join} from "node:path";

import {inject, Injectable} from "@tsed/di";
import {join} from "path";
import {Observable} from "rxjs";

import {CliFs} from "../../services/CliFs.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/CliDockerComposeYaml.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {join} from "node:path";

import {setValue} from "@tsed/core";
import {inject, Injectable} from "@tsed/di";
import {snakeCase} from "change-case";
import {join} from "path";

import {CliFs} from "./CliFs.js";
import {CliYaml} from "./CliYaml.js";
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-core/src/services/CliFs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {PathLike, WriteFileOptions} from "node:fs";
import {join} from "node:path";

import {Injectable} from "@tsed/di";
import {normalizePath} from "@tsed/normalize-path";
import type {PathLike, WriteFileOptions} from "fs";
import Fs, {type EnsureDirOptions} from "fs-extra";
import {join} from "path";

@Injectable()
export class CliFs {
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-core/src/services/CliHttpClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {stringify} from "node:querystring";
import {URL} from "node:url";

import {cleanObject} from "@tsed/core";
import {inject, Injectable} from "@tsed/di";
import axios, {type AxiosRequestConfig, type Method} from "axios";
import {stringify} from "querystring";
import {URL} from "url";

import {CliHttpLogClient} from "./CliHttpLogClient.js";
import {CliProxyAgent} from "./CliProxyAgent.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/CliHttpLogClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import querystring from "node:querystring";

import {getValue} from "@tsed/core";
import {inject, Opts} from "@tsed/di";
import {Logger} from "@tsed/logger";
import querystring from "querystring";

import {logToCurl} from "../utils/logToCurl.js";

Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/CliLoadFile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {extname} from "node:path";

import {inject, Injectable} from "@tsed/di";
import {default as Ajv, type Schema} from "ajv";
import {extname} from "path";

import {CliFs} from "./CliFs.js";
import {CliYaml} from "./CliYaml.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/CliProxyAgent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {URL} from "node:url";

import {Configuration, Inject, inject, Injectable, refValue} from "@tsed/di";
import {camelCase} from "change-case";
import tunnel from "tunnel";
import {URL} from "url";

import {coerce} from "../utils/coerce.js";
import {CliExeca} from "./CliExeca.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/NpmRegistryClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import url from "node:url";

import {inject, Injectable} from "@tsed/di";
import registry_url from "registry-url";
import url from "url";

import type {PackageInfo} from "../interfaces/PackageJson.js";
import {CliHttpClient} from "./CliHttpClient.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/ProjectPackageJson.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {join, resolve} from "node:path";

// @ts-ignore
import {CliPlatformTest} from "@tsed/cli-testing";
import {join, resolve} from "path";

import {CliExeca} from "./CliExeca.js";
import {CliFs} from "./CliFs.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/ProjectPackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {dirname, join} from "node:path";

import {getValue, setValue} from "@tsed/core";
import {configuration, constant, inject, Injectable} from "@tsed/di";
import {dirname, join} from "path";
import {readPackageUpSync} from "read-pkg-up";

import type {PackageJson} from "../interfaces/PackageJson.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/services/Renderer.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import "../utils/hbs/index.js";

import {basename, dirname, join, relative} from "node:path";

import {isString} from "@tsed/core";
import {constant, inject, Injectable} from "@tsed/di";
import {normalizePath} from "@tsed/normalize-path";
import Consolidate from "consolidate";
import fs from "fs-extra";
import {globby} from "globby";
import handlebars from "handlebars";
import {basename, dirname, join, relative} from "path";
import {Observable} from "rxjs";

import {insertAfter} from "../utils/renderer/insertAfter.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/utils/getTemplateDirectory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {dirname, join} from "path";
import {dirname, join} from "node:path";

import {readPackageUpSync} from "read-pkg-up";

export function getTemplateDirectory(cwd: string) {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-core/src/utils/streamToObservable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {Stream} from "node:stream";

import {Observable} from "rxjs";
import type {Stream} from "stream";

function or(option: false | any, alternate: string, required?: boolean) {
const result = option === false ? false : option || alternate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import path, {join, resolve} from "node:path";

import {CliFs, Command, type CommandProvider, constant, inject, Type} from "@tsed/cli-core";
import {isString} from "@tsed/core";
import {InjectorService} from "@tsed/di";
import {camelCase} from "change-case";
import path, {join, resolve} from "path";
import {generateApi, type Hooks, type RawRouteInfo, type RouteNameInfo} from "swagger-typescript-api";

export interface GenerateHttpClientCtx {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path, {join, resolve} from "node:path";

import {CliFs, CliYaml, Command, type CommandProvider, Constant, constant, Inject, inject, InjectorService, Type} from "@tsed/cli-core";
import path, {join, resolve} from "path";

export interface GenerateSwaggerCtx {
output: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-plugin-mongoose/src/services/CliMongoose.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {basename, join} from "node:path";

import {inject, Injectable, ProjectPackageJson, SrcRendererService} from "@tsed/cli-core";
import {camelCase, constantCase, kebabCase} from "change-case";
import {basename, join} from "path";

import {TEMPLATE_DIR} from "../utils/templateDir.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports[`Init OIDC Provider project > should generate a project with oidc 1`] =
`;

exports[`Init OIDC Provider project > should generate a project with oidc 2`] = `
"import {join} from "path";
"import {join} from "node:path";
import {Configuration} from "@tsed/di";
import {application} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don't want log request
Expand Down Expand Up @@ -173,7 +173,7 @@ exports[`Init OIDC Provider project > should generate a project with oidc and sw
`;

exports[`Init OIDC Provider project > should generate a project with oidc and swagger 2`] = `
"import {join} from "path";
"import {join} from "node:path";
import {Configuration} from "@tsed/di";
import {application} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don't want log request
Expand Down
3 changes: 2 additions & 1 deletion packages/cli-plugin-prisma/src/services/CliPrisma.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {join} from "node:path";

import {CliFs, normalizePath} from "@tsed/cli-core";
// @ts-ignore
import {CliPlatformTest} from "@tsed/cli-testing";
import {join} from "path";

import {CliPrisma} from "./CliPrisma.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Init TypeGraphQL project > should generate a project with typegraphql 2`] = `
"import {join} from "path";
"import {join} from "node:path";
import {Configuration} from "@tsed/di";
import {application} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don't want log request
Expand Down Expand Up @@ -52,7 +52,7 @@ export class Server {
`;

exports[`Init TypeGraphQL project > should generate a project with typegraphql 3`] = `
"import {readFileSync} from "fs";
"import {readFileSync} from "node:fs";
import {envs} from "./envs/index.js";
import loggerConfig from "./logger/index.js";
const pkg = JSON.parse(readFileSync("./package.json", {encoding: "utf8"}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`TypeORM: Init cmd > should generate a project with the right options 2`] = `
"import {join} from "path";
"import {join} from "node:path";
import {Configuration} from "@tsed/di";
import {application} from "@tsed/platform-http";
import "@tsed/platform-log-request"; // remove this import if you don't want log request
Expand Down
5 changes: 3 additions & 2 deletions packages/cli-testing/src/FakeCliFs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {PathLike} from "node:fs";
import * as fs from "node:fs";

import {isString} from "@tsed/core";
import type {PathLike} from "fs";
import * as fs from "fs";
import type {EnsureDirOptions, WriteFileOptions} from "fs-extra";

import {normalizePath} from "./normalizePath.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/scripts/index.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 3 additions & 10 deletions packages/cli/src/commands/generate/GenerateCmd.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import {
type CliDefaultOptions,
Command,
type CommandProvider,
Inject,
inject,
ProjectPackageJson,
SrcRendererService
} from "@tsed/cli-core";
import {basename, dirname, join} from "node:path";

import {type CliDefaultOptions, Command, type CommandProvider, Inject, ProjectPackageJson, SrcRendererService} from "@tsed/cli-core";
import {normalizePath} from "@tsed/normalize-path";
import {kebabCase, pascalCase} from "change-case";
import {globbySync} from "globby";
import {basename, dirname, join} from "path";

import {ProjectConvention} from "../../interfaces/ProjectConvention.js";
import {ClassNamePipe} from "../../pipes/ClassNamePipe.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/init/InitCmd.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {basename, join} from "node:path";

import {
CliExeca,
CliFs,
Expand All @@ -19,7 +21,6 @@ import {
type Task
} from "@tsed/cli-core";
import {kebabCase, pascalCase} from "change-case";
import {basename, join} from "path";

import {DEFAULT_TSED_TAGS} from "../../constants/index.js";
import {ArchitectureConvention} from "../../interfaces/ArchitectureConvention.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {dirname, join} from "path";
import {dirname, join} from "node:path";

import {readPackageUpSync} from "read-pkg-up";

const {path, packageJson} = readPackageUpSync({
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/pipes/ClassNamePipe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {basename} from "node:path";

import {ProjectPackageJson} from "@tsed/cli-core";
import {inject, Injectable} from "@tsed/di";
import {kebabCase, pascalCase} from "change-case";
import {basename} from "path";

import {ProjectConvention} from "../interfaces/ProjectConvention.js";
import {ProvidersInfoService} from "../services/ProvidersInfoService.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/pipes/OutputFilePathPipe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {dirname, join} from "node:path";

import {inject, Injectable, ProjectPackageJson} from "@tsed/cli-core";
import {Inject} from "@tsed/di";
import {dirname, join} from "path";

import {ArchitectureConvention, ProjectConvention} from "../interfaces/index.js";
import {ProvidersInfoService} from "../services/ProvidersInfoService.js";
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/runtimes/supports/BabelRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {dirname} from "node:path";

import {Injectable} from "@tsed/di";
import {dirname} from "path";

import {NodeRuntime} from "./NodeRuntime.js";

Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/runtimes/supports/WebpackRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {dirname} from "node:path";

import {Injectable} from "@tsed/di";
import {dirname} from "path";

import {BabelRuntime} from "./BabelRuntime.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/generate/server.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {join} from "path";
import {join} from "node:path";
import {Configuration} from "@tsed/di";
import {application} from "@tsed/platform-http";
{{#forEach imports}}{{#if tsIngore}}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/templates/init/src/config/index.ts.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {readFileSync} from "fs";
import {readFileSync} from "node:fs";
import {envs} from "./envs/index.js";
import loggerConfig from "./logger/index.js";{{#if mongoose}}
import mongooseConfig from "./mongoose/index.js";
Expand Down
Loading

0 comments on commit 94eaa02

Please sign in to comment.