Skip to content

Commit 4ff8152

Browse files
committed
fix: Fixed sudo, reporters, os filtering, and others (mainly linux related)
1 parent 6ece30e commit 4ff8152

File tree

12 files changed

+235
-25
lines changed

12 files changed

+235
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"start:vm": "npm run build && npm run pack:macos && npm run start:vm",
144144
"deploy": "npm run pkg && npm run notarize && npm run upload"
145145
},
146-
"version": "1.0.0-beta2",
146+
"version": "1.0.0-beta4",
147147
"bugs": "https://github.com/codifycli/codify/issues",
148148
"keywords": [
149149
"oclif",

src/common/initialize-plugins.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class PluginInitOrchestrator {
4444
const resourceDefinitions = await pluginManager.initialize(project, args.secure, args.verbosityLevel);
4545
if (!args.noProgress) ctx.subprocessFinished(SubProcessName.INITIALIZE_PLUGINS)
4646

47+
project.removeResourcesUsingOsFilter();
48+
4749
return { resourceDefinitions, pluginManager, project };
4850
}
4951

src/entities/project.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { OS, PlanRequestData, ResourceOperation, ValidateResponseData } from 'codify-schemas';
2-
import * as os from 'os'
2+
import * as os from 'node:os'
33
import { validate } from 'uuid'
44

55
import {
@@ -14,11 +14,12 @@ import { SourceMapCache } from '../parser/source-maps.js';
1414
import { ResourceDefinitionMap } from '../plugins/plugin-manager.js';
1515
import { DependencyGraphResolver } from '../utils/dependency-graph-resolver.js';
1616
import { groupBy } from '../utils/index.js';
17+
import { OsUtils } from '../utils/os-utils.js';
18+
import { ShellUtils } from '../utils/shell.js';
1719
import { ConfigBlock, ConfigType } from './config.js';
1820
import { type Plan } from './plan.js';
1921
import { ProjectConfig } from './project-config.js';
2022
import { ResourceConfig } from './resource-config.js';
21-
import { ShellUtils } from '../utils/shell.js';
2223

2324
export class Project {
2425
projectConfig: ProjectConfig | null;
@@ -206,6 +207,16 @@ ${JSON.stringify(projectConfigs, null, 2)}`);
206207
}
207208
}
208209

210+
removeResourcesUsingOsFilter() {
211+
this.resourceConfigs = this.resourceConfigs.filter((r) => {
212+
if (!r.os) {
213+
return true;
214+
}
215+
216+
return r.os.includes(OsUtils.getOs());
217+
});
218+
}
219+
209220
resolveDependenciesAndCalculateEvalOrder(resourceDefinitions?: ResourceDefinitionMap) {
210221
this.resolveResourceDependencies(resourceDefinitions);
211222
this.calculateEvaluationOrder();

src/entities/resource-config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ResourceJson, ResourceConfig as SchemaResourceConfig } from 'codify-schemas';
1+
import { ResourceJson, ResourceOs, ResourceConfig as SchemaResourceConfig } from 'codify-schemas';
22

33
import { deepEqual } from '../utils/index.js';
44
import { ConfigBlock, ConfigType } from './config.js';
@@ -28,6 +28,7 @@ export class ResourceConfig implements ConfigBlock {
2828
type: string;
2929
name?: string;
3030
dependsOn: string[];
31+
os?: ResourceOs[];
3132
sourceMapKey?: string;
3233

3334
// Calculated
@@ -37,11 +38,12 @@ export class ResourceConfig implements ConfigBlock {
3738
resourceInfo?: ResourceInfo;
3839

3940
constructor(config: SchemaResourceConfig, sourceMapKey?: string) {
40-
const { dependsOn, name, type, ...parameters } = config;
41+
const { dependsOn, name, type, os, ...parameters } = config;
4142

4243
this.raw = config;
4344
this.type = type;
4445
this.name = name;
46+
this.os = os;
4547
this.parameters = parameters ?? {};
4648
this.dependsOn = dependsOn ?? []
4749
this.sourceMapKey = sourceMapKey;
@@ -62,16 +64,14 @@ export class ResourceConfig implements ConfigBlock {
6264
return {
6365
type: this.type,
6466
...(excludeName || !this.name ? {} : { name: this.name }),
65-
...(this.dependsOn.length > 0 ? { dependsOn: this.dependsOn } : {})
67+
...(this.dependsOn.length > 0 ? { dependsOn: this.dependsOn } : {}),
68+
...(this.os && this.os?.length > 0 ? { os: this.os } : {})
6669
};
6770
}
6871

6972
toJson(): ResourceJson {
7073
return {
71-
core: {
72-
type: this.type,
73-
name: this.name,
74-
},
74+
core: this.core(),
7575
parameters: this.parameters ?? {},
7676
}
7777
}

src/events/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export enum ProcessName {
3232
}
3333

3434
export enum SubProcessName {
35-
APPLYING_RESOURCE = 'apply_resource',
35+
APPLYING_RESOURCE = 'apply_resource_',
3636
GENERATE_PLAN = 'generate_plan',
3737
INITIALIZE_PLUGINS = 'initialize_plugins',
3838
PARSE = 'parse',

src/orchestrators/apply.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const ApplyOrchestrator = {
2929
const filteredPlan = plan.filterNoopResources()
3030

3131
if (!args.noProgress) ctx.processStarted(ProcessName.APPLY);
32+
if (!args.noProgress) await reporter.displayProgress();
33+
3234
await pluginManager.apply(project, filteredPlan);
3335
if (!args.noProgress) ctx.processFinished(ProcessName.APPLY);
3436

src/orchestrators/destroy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class DestroyOrchestrator {
5353

5454
const filteredPlan = plan.filterNoopResources()
5555

56+
await reporter.displayProgress();
5657
await ctx.process(ProcessName.DESTROY, () =>
5758
pluginManager.apply(destroyProject, filteredPlan)
5859
)

src/orchestrators/plan.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ProcessName, SubProcessName, ctx } from '../events/context.js';
77
import { PluginManager } from '../plugins/plugin-manager.js';
88
import { Reporter } from '../ui/reporters/reporter.js';
99
import { createStartupShellScriptsIfNotExists } from '../utils/file.js';
10+
import { OsUtils } from '../utils/os-utils.js';
1011
import { ValidateOrchestrator } from './validate.js';
1112

1213
export interface PlanArgs {
@@ -36,7 +37,9 @@ export class PlanOrchestrator {
3637

3738
await ValidateOrchestrator.run({ existing: initializationResult, noProgress: args.noProgress }, reporter);
3839
project.resolveDependenciesAndCalculateEvalOrder(resourceDefinitions);
39-
project.addXCodeToolsConfig(); // We have to add xcode-tools config always since almost every resource depends on it
40+
if (OsUtils.isMacOS()) {
41+
project.addXCodeToolsConfig(); // We have to add xcode-tools config always to MacOS since almost every resource depends on it
42+
}
4043

4144
const plan = await PlanOrchestrator.plan(project, pluginManager, args.noProgress);
4245
plan.sortByEvalOrder(project.evaluationOrder);

src/ui/components/progress/progress-display.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { StatusMessage, Spinner as AutomatedSpinner } from '@inkjs/ui';
1+
import { Spinner as AutomatedSpinner, StatusMessage } from '@inkjs/ui';
22
import { Box } from 'ink';
3-
import EventEmitter from 'node:events';
3+
import { useAtom } from 'jotai';
44
import React from 'react';
55

6-
import Spinner from './spinner.js';
76
import { store } from '../../store/index.js';
8-
import { useAtom } from 'jotai';
97

108
export enum ProgressStatus {
119
IN_PROGRESS,
@@ -16,7 +14,6 @@ export interface ProgressState {
1614
name: string,
1715
label: string;
1816
status: ProgressStatus;
19-
logTriggeredSpinner: boolean;
2017
subProgresses: Array<{
2118
name: string,
2219
label: string;

src/ui/reporters/default-reporter.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ export class DefaultReporter implements Reporter {
218218
this.updateRenderState(RenderStatus.NOTHING, null);
219219
await sleep(50);
220220

221-
if (result) {
222-
this.updateRenderState(RenderStatus.PROGRESS)
223-
}
224-
225221
return result;
226222
}
227223

@@ -262,7 +258,6 @@ export class DefaultReporter implements Reporter {
262258
name,
263259
status: ProgressStatus.IN_PROGRESS,
264260
subProgresses: [],
265-
logTriggeredSpinner: name === ProcessName.APPLY || name === ProcessName.DESTROY,
266261
};
267262

268263
this.log(`${label} started`)

0 commit comments

Comments
 (0)