@decohere/forge 0.0.1-dev.129 → 0.0.1-dev.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commonjs/src/actions/dependency-report.action.js +4 -0
- package/commonjs/src/actions/dependency-sync.action.js +6 -0
- package/commonjs/src/actions/paths.action.js +11 -0
- package/commonjs/src/actions/version.action.js +4 -2
- package/commonjs/src/create-workspace.js +1 -5
- package/es6/src/actions/dependency-report.action.js +4 -0
- package/es6/src/actions/dependency-sync.action.js +6 -0
- package/es6/src/actions/paths.action.js +11 -0
- package/es6/src/actions/version.action.js +4 -2
- package/es6/src/create-workspace.js +3 -7
- package/package.json +6 -6
- package/types/src/create-workspace.d.ts +1 -1
|
@@ -34,6 +34,10 @@ class ReportDependencies {
|
|
|
34
34
|
}
|
|
35
35
|
async run(options) {
|
|
36
36
|
const { configuration, file, failOnDrift } = options;
|
|
37
|
+
if (this.workspace.isStandalone) {
|
|
38
|
+
this.#logger.info("Standalone project: its package.json is the root's; nothing to report");
|
|
39
|
+
return _cli.ActionResponse.Success(ReportDependencies.name, []);
|
|
40
|
+
}
|
|
37
41
|
try {
|
|
38
42
|
const projectDeps = await this.analyzeWorkspace(this.workspace, configuration);
|
|
39
43
|
this.logReport(projectDeps);
|
|
@@ -33,6 +33,12 @@ class SyncDependencies {
|
|
|
33
33
|
}
|
|
34
34
|
async run(options) {
|
|
35
35
|
const { configuration, logDiff } = options;
|
|
36
|
+
if (this.workspace.isStandalone) {
|
|
37
|
+
// The project's package.json is the root's: syncing it from itself would drop every
|
|
38
|
+
// dependency nothing imports (typescript, vitest, linters).
|
|
39
|
+
this.#logger.info("Standalone project: its package.json is the root's; nothing to sync");
|
|
40
|
+
return _cli.ActionResponse.Success(SyncDependencies.name, []);
|
|
41
|
+
}
|
|
36
42
|
const projects = this.workspace.getProjects(configuration);
|
|
37
43
|
const workspacePackages = await this.resolver.getWorkspacePackages(this.workspace, projects);
|
|
38
44
|
const computed = await Promise.all(projects.map((project)=>this.computeDependenciesFor(project, workspacePackages)));
|
|
@@ -46,6 +46,17 @@ class Paths {
|
|
|
46
46
|
}
|
|
47
47
|
async run(options) {
|
|
48
48
|
const file = _nodepath.default.join(this.workspace.rootDir, PATHS_FILE);
|
|
49
|
+
if (this.workspace.isStandalone) {
|
|
50
|
+
// One project has no other projects to import from source.
|
|
51
|
+
this.#logger.info(`Standalone project: no ${PATHS_FILE} needed`);
|
|
52
|
+
return _cli.ActionResponse.Success(Paths.name, [
|
|
53
|
+
{
|
|
54
|
+
file,
|
|
55
|
+
changed: false,
|
|
56
|
+
succeeded: true
|
|
57
|
+
}
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
49
60
|
const content = Paths.render(this.workspace);
|
|
50
61
|
const current = (0, _nodefs.existsSync)(file) ? await (0, _promises.readFile)(file, "utf8") : null;
|
|
51
62
|
const changed = current !== content;
|
|
@@ -82,9 +82,11 @@ class Version {
|
|
|
82
82
|
]);
|
|
83
83
|
}
|
|
84
84
|
await workspace.persistPackageJson((await workspace.getPackageJson()).withVersion(nextVersion.toString()));
|
|
85
|
+
// Standalone, the project's package.json is the root's: write it once.
|
|
86
|
+
const projectsToWrite = workspace.isStandalone ? [] : projects;
|
|
85
87
|
const responses = await Promise.all([
|
|
86
88
|
this.updatePackageJson(workspace.name, workspace, nextVersion),
|
|
87
|
-
...
|
|
89
|
+
...projectsToWrite.map((project)=>this.updatePackageJson(project.name, project, nextVersion))
|
|
88
90
|
]);
|
|
89
91
|
const failed = responses.filter((r)=>!r.succeeded);
|
|
90
92
|
if (failed.length) {
|
|
@@ -93,7 +95,7 @@ class Version {
|
|
|
93
95
|
if (options.commit) {
|
|
94
96
|
const files = [
|
|
95
97
|
workspace.packageJsonPath,
|
|
96
|
-
...
|
|
98
|
+
...projectsToWrite.map((p)=>p.packageJsonPath)
|
|
97
99
|
];
|
|
98
100
|
const message = options.message ?? `chore: version packages ${nextVersion}`;
|
|
99
101
|
this.#logger.info(`Committing: ${message}`);
|
|
@@ -17,7 +17,7 @@ function _interop_require_default(obj) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
async function createWorkspace(options = {}) {
|
|
20
|
-
const rootDir = options.rootDir ??
|
|
20
|
+
const rootDir = options.rootDir ?? _workspaceconfig.WorkspaceDefaults.rootDir ?? "./";
|
|
21
21
|
const configFile = options.configFile ?? (rootDir === _workspaceconfig.WorkspaceDefaults.rootDir ? undefined : _nodepath.default.join(rootDir, _workspace.WORKSPACE_CONFIG));
|
|
22
22
|
// `projects` is dropped too: forge's defaults set it to undefined, which would override the
|
|
23
23
|
// user's per-project settings (docker, ui) in the merge.
|
|
@@ -36,7 +36,3 @@ async function createWorkspace(options = {}) {
|
|
|
36
36
|
rootDir
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
/** `./` when cwd is the root (keeps paths relative as before), else the root above it. */ function defaultRootDir() {
|
|
40
|
-
const root = (0, _workspace.findWorkspaceRoot)(process.cwd());
|
|
41
|
-
return root === process.cwd() ? _workspaceconfig.WorkspaceDefaults.rootDir ?? "./" : root;
|
|
42
|
-
}
|
|
@@ -24,6 +24,10 @@ export class ReportDependencies {
|
|
|
24
24
|
}
|
|
25
25
|
async run(options) {
|
|
26
26
|
const { configuration, file, failOnDrift } = options;
|
|
27
|
+
if (this.workspace.isStandalone) {
|
|
28
|
+
this.#logger.info("Standalone project: its package.json is the root's; nothing to report");
|
|
29
|
+
return ActionResponse.Success(ReportDependencies.name, []);
|
|
30
|
+
}
|
|
27
31
|
try {
|
|
28
32
|
const projectDeps = await this.analyzeWorkspace(this.workspace, configuration);
|
|
29
33
|
this.logReport(projectDeps);
|
|
@@ -23,6 +23,12 @@ export class SyncDependencies {
|
|
|
23
23
|
}
|
|
24
24
|
async run(options) {
|
|
25
25
|
const { configuration, logDiff } = options;
|
|
26
|
+
if (this.workspace.isStandalone) {
|
|
27
|
+
// The project's package.json is the root's: syncing it from itself would drop every
|
|
28
|
+
// dependency nothing imports (typescript, vitest, linters).
|
|
29
|
+
this.#logger.info("Standalone project: its package.json is the root's; nothing to sync");
|
|
30
|
+
return ActionResponse.Success(SyncDependencies.name, []);
|
|
31
|
+
}
|
|
26
32
|
const projects = this.workspace.getProjects(configuration);
|
|
27
33
|
const workspacePackages = await this.resolver.getWorkspacePackages(this.workspace, projects);
|
|
28
34
|
const computed = await Promise.all(projects.map((project)=>this.computeDependenciesFor(project, workspacePackages)));
|
|
@@ -23,6 +23,17 @@ export class Paths {
|
|
|
23
23
|
}
|
|
24
24
|
async run(options) {
|
|
25
25
|
const file = path.join(this.workspace.rootDir, PATHS_FILE);
|
|
26
|
+
if (this.workspace.isStandalone) {
|
|
27
|
+
// One project has no other projects to import from source.
|
|
28
|
+
this.#logger.info(`Standalone project: no ${PATHS_FILE} needed`);
|
|
29
|
+
return ActionResponse.Success(Paths.name, [
|
|
30
|
+
{
|
|
31
|
+
file,
|
|
32
|
+
changed: false,
|
|
33
|
+
succeeded: true
|
|
34
|
+
}
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
26
37
|
const content = Paths.render(this.workspace);
|
|
27
38
|
const current = existsSync(file) ? await readFile(file, "utf8") : null;
|
|
28
39
|
const changed = current !== content;
|
|
@@ -61,9 +61,11 @@ export class Version {
|
|
|
61
61
|
]);
|
|
62
62
|
}
|
|
63
63
|
await workspace.persistPackageJson((await workspace.getPackageJson()).withVersion(nextVersion.toString()));
|
|
64
|
+
// Standalone, the project's package.json is the root's: write it once.
|
|
65
|
+
const projectsToWrite = workspace.isStandalone ? [] : projects;
|
|
64
66
|
const responses = await Promise.all([
|
|
65
67
|
this.updatePackageJson(workspace.name, workspace, nextVersion),
|
|
66
|
-
...
|
|
68
|
+
...projectsToWrite.map((project)=>this.updatePackageJson(project.name, project, nextVersion))
|
|
67
69
|
]);
|
|
68
70
|
const failed = responses.filter((r)=>!r.succeeded);
|
|
69
71
|
if (failed.length) {
|
|
@@ -72,7 +74,7 @@ export class Version {
|
|
|
72
74
|
if (options.commit) {
|
|
73
75
|
const files = [
|
|
74
76
|
workspace.packageJsonPath,
|
|
75
|
-
...
|
|
77
|
+
...projectsToWrite.map((p)=>p.packageJsonPath)
|
|
76
78
|
];
|
|
77
79
|
const message = options.message ?? `chore: version packages ${nextVersion}`;
|
|
78
80
|
this.#logger.info(`Committing: ${message}`);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { UserConfigFactory, WORKSPACE_CONFIG, WorkspaceFactory } from "@decohere/workspace";
|
|
3
3
|
import { DefaultConfigurations, WorkspaceDefaults } from "./workspace.config.js";
|
|
4
4
|
/**
|
|
5
5
|
* The workspace every Decohere tool sees (forge, the flux CLI and `flux.run`): forge's
|
|
6
|
-
* defaults, the user's `.decohere.js`, and
|
|
6
|
+
* defaults, the user's `.decohere.js`, and the root: `--root-dir`, else the current folder.
|
|
7
7
|
*/ export async function createWorkspace(options = {}) {
|
|
8
|
-
const rootDir = options.rootDir ??
|
|
8
|
+
const rootDir = options.rootDir ?? WorkspaceDefaults.rootDir ?? "./";
|
|
9
9
|
const configFile = options.configFile ?? (rootDir === WorkspaceDefaults.rootDir ? undefined : path.join(rootDir, WORKSPACE_CONFIG));
|
|
10
10
|
// `projects` is dropped too: forge's defaults set it to undefined, which would override the
|
|
11
11
|
// user's per-project settings (docker, ui) in the merge.
|
|
@@ -24,7 +24,3 @@ import { DefaultConfigurations, WorkspaceDefaults } from "./workspace.config.js"
|
|
|
24
24
|
rootDir
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
/** `./` when cwd is the root (keeps paths relative as before), else the root above it. */ function defaultRootDir() {
|
|
28
|
-
const root = findWorkspaceRoot(process.cwd());
|
|
29
|
-
return root === process.cwd() ? WorkspaceDefaults.rootDir ?? "./" : root;
|
|
30
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/forge",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.130",
|
|
4
4
|
"description": "TypeScript monorepo build system — zero config, fast compilation, streamlined developer workflow",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@decohere/core": "0.0.1-dev.
|
|
42
|
-
"@decohere/crucible": "0.0.1-dev.
|
|
43
|
-
"@decohere/devkit": "0.0.1-dev.
|
|
44
|
-
"@decohere/scribe": "0.0.1-dev.
|
|
45
|
-
"@decohere/workspace": "0.0.1-dev.
|
|
41
|
+
"@decohere/core": "0.0.1-dev.130",
|
|
42
|
+
"@decohere/crucible": "0.0.1-dev.130",
|
|
43
|
+
"@decohere/devkit": "0.0.1-dev.130",
|
|
44
|
+
"@decohere/scribe": "0.0.1-dev.130",
|
|
45
|
+
"@decohere/workspace": "0.0.1-dev.130",
|
|
46
46
|
"@swc/core": "^1.11.11",
|
|
47
47
|
"async": "^3.2.6",
|
|
48
48
|
"parse-imports": "^2.2.1",
|
|
@@ -2,6 +2,6 @@ import { type Workspace } from "@decohere/workspace";
|
|
|
2
2
|
import type { WorkspaceFactoryOptions } from "@decohere/devkit/cli";
|
|
3
3
|
/**
|
|
4
4
|
* The workspace every Decohere tool sees (forge, the flux CLI and `flux.run`): forge's
|
|
5
|
-
* defaults, the user's `.decohere.js`, and
|
|
5
|
+
* defaults, the user's `.decohere.js`, and the root: `--root-dir`, else the current folder.
|
|
6
6
|
*/
|
|
7
7
|
export declare function createWorkspace(options?: WorkspaceFactoryOptions): Promise<Workspace>;
|