Skip to content

Commit

Permalink
misc: better build structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeVanti committed Oct 31, 2023
1 parent d53b70b commit 3c32160
Show file tree
Hide file tree
Showing 34 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ typings/

# builds

/build
/lib
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
.gitattributes
.eslintrc.js
test/
.vscode/
.vscode/
src/
!lib/
3 changes: 0 additions & 3 deletions lib/index.ts

This file was deleted.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"engines": {
"node": ">=16"
},
"main": "lib/index.ts",
"scripts": {
"test": "cross-env NODE_ENV=test ts-mocha test/**/*.ts",
"build": "tsc -p tsconfig.json",
"build:watch": "tsc -w -p tsconfig.json",
"semantic-release": "semantic-release"
},
"bin": {
"openupm": "lib/index.ts",
"openupm-cli": "lib/index.ts",
"openupm-cn": "lib/index-cn.ts"
"openupm": "lib/index.js",
"openupm-cli": "lib/index.js",
"openupm-cn": "lib/index-cn.js"
},
"repository": {
"type": "git",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/index-cn.ts → src/index-cn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S node -r "ts-node/register"
#!/usr/bin/env node

if (!process.argv.includes("--cn")) process.argv.push("--cn");
import "./cli";
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

import "./cli";
File renamed without changes.
2 changes: 2 additions & 0 deletions src/types/allow-importing-package-json.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://stackoverflow.com/a/61426303
declare module "*.json";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/test-cmd-add.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "assert";
import nock from "nock";
import "should";
import { loadManifest } from "../lib/core";
import { loadManifest } from "../src/core";

import { add } from "../lib/cmd-add";
import { add } from "../src/cmd-add";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-cmd-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "assert";
import nock from "nock";
import "should";

import { deps } from "../lib/cmd-deps";
import { deps } from "../src/cmd-deps";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-cmd-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
generateNpmrcLines,
getNpmrcPath,
validateRegistry,
} from "../lib/cmd-login";
} from "../src/cmd-login";

describe("cmd-login.ts", function () {
describe("validateRegistry", function () {
Expand Down
4 changes: 2 additions & 2 deletions test/test-cmd-remove.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import "assert";
import "should";
import { loadManifest } from "../lib/core";
import { loadManifest } from "../src/core";

import { remove } from "../lib/cmd-remove";
import { remove } from "../src/cmd-remove";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-cmd-search.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "assert";
import nock from "nock";
import "should";
import { search } from "../lib/cmd-search";
import { search } from "../src/cmd-search";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-cmd-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "assert";
import nock from "nock";
import "should";

import { view } from "../lib/cmd-view";
import { view } from "../src/cmd-view";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
parseEditorVersion,
parseEnv,
saveManifest,
} from "../lib/core";
} from "../src/core";

import {
createWorkDir,
Expand Down
2 changes: 1 addition & 1 deletion test/test-pkg-name.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "assert";
import "should";
import { splitPkgName } from "../lib/utils/pkg-name";
import { splitPkgName } from "../src/utils/pkg-name";

describe("pkg-name.ts", function () {
describe("splitPkgName", function () {
Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import nock from "nock";
import path from "path";
import os from "os";
import testConsole from "test-console";
import { PkgManifest } from "../lib/types/global";
import { PkgManifest } from "../src/types/global";
import _ from "lodash";

export type ManifestCreationOptions = {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
"resolveJsonModule": true, /* Enable importing .json files. */
"resolveJsonModule": false, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

Expand All @@ -58,7 +58,7 @@
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
"outDir": "./build", /* Specify an output folder for all emitted files. */
"outDir": "./lib", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
// "noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
Expand Down Expand Up @@ -114,6 +114,6 @@
/* Skip type checking all .d.ts files. */
},
"include": [
"./lib/**/*"
"./src/**/*"
]
}

0 comments on commit 3c32160

Please sign in to comment.