optikit 1.1.1 → 1.2.1
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/CHANGELOG.md +39 -2
- package/CLAUDE.md +239 -0
- package/CODE_QUALITY.md +398 -0
- package/ENHANCEMENTS.md +310 -0
- package/FEATURE_ENHANCEMENTS.md +435 -0
- package/README.md +46 -13
- package/SAFETY_FEATURES.md +396 -0
- package/USAGE.md +264 -41
- package/VERSION_MANAGEMENT.md +438 -0
- package/dist/cli.js +127 -8
- package/dist/commands/build/releases.js +57 -0
- package/dist/commands/buildReleases.js +48 -74
- package/dist/commands/clean/flutter.js +51 -0
- package/dist/commands/clean/ios.js +109 -0
- package/dist/commands/cleanProject.js +34 -4
- package/dist/commands/cleanProjectIos.js +17 -7
- package/dist/commands/config/init.js +54 -0
- package/dist/commands/config/rollback.js +161 -0
- package/dist/commands/generateModule.js +39 -11
- package/dist/commands/init.js +54 -0
- package/dist/commands/openProject.js +17 -0
- package/dist/commands/project/devices.js +188 -0
- package/dist/commands/project/generate.js +143 -0
- package/dist/commands/project/open.js +163 -0
- package/dist/commands/project/setup.js +46 -0
- package/dist/commands/rollback.js +161 -0
- package/dist/commands/setupVSCode.js +27 -21
- package/dist/commands/updateVersions.js +13 -1
- package/dist/commands/version/bump.js +161 -0
- package/dist/commands/version/update.js +91 -0
- package/dist/commands/version.js +161 -0
- package/dist/constants.js +131 -0
- package/dist/utils/backupHelpers.js +88 -0
- package/dist/utils/buildHelpers.js +55 -0
- package/dist/utils/commandHelpers.js +51 -0
- package/dist/utils/configHelpers.js +80 -0
- package/dist/utils/dryRunHelpers.js +103 -0
- package/dist/utils/fileHelpers.js +2 -1
- package/dist/utils/helpers/build.js +55 -0
- package/dist/utils/helpers/dryRun.js +103 -0
- package/dist/utils/helpers/file.js +24 -0
- package/dist/utils/helpers/string.js +3 -0
- package/dist/utils/helpers/version.js +80 -0
- package/dist/utils/services/backup.js +88 -0
- package/dist/utils/services/command.js +51 -0
- package/dist/utils/services/config.js +80 -0
- package/dist/utils/services/exec.js +132 -0
- package/dist/utils/services/logger.js +15 -0
- package/dist/utils/validationHelpers.js +101 -0
- package/dist/utils/validators/validation.js +101 -0
- package/dist/utils/versionHelpers.js +80 -0
- package/package.json +1 -1
- package/src/cli.ts +191 -8
- package/src/commands/build/releases.ts +79 -0
- package/src/commands/clean/flutter.ts +58 -0
- package/src/commands/{cleanProjectIos.ts → clean/ios.ts} +19 -10
- package/src/commands/config/init.ts +63 -0
- package/src/commands/config/rollback.ts +200 -0
- package/src/commands/project/devices.ts +246 -0
- package/src/commands/{generateModule.ts → project/generate.ts} +47 -17
- package/src/commands/project/open.ts +193 -0
- package/src/commands/project/setup.ts +50 -0
- package/src/commands/version/bump.ts +202 -0
- package/src/commands/{updateVersions.ts → version/update.ts} +22 -6
- package/src/constants.ts +144 -0
- package/src/utils/helpers/build.ts +80 -0
- package/src/utils/helpers/dryRun.ts +124 -0
- package/src/utils/{fileHelpers.ts → helpers/file.ts} +3 -2
- package/src/utils/helpers/version.ts +109 -0
- package/src/utils/services/backup.ts +109 -0
- package/src/utils/services/command.ts +76 -0
- package/src/utils/services/config.ts +106 -0
- package/src/utils/{execHelpers.ts → services/exec.ts} +1 -1
- package/src/utils/validators/validation.ts +122 -0
- package/src/commands/buildReleases.ts +0 -102
- package/src/commands/cleanProject.ts +0 -25
- package/src/commands/openProject.ts +0 -51
- package/src/commands/setupVSCode.ts +0 -44
- /package/src/utils/{stringHelpers.ts → helpers/string.ts} +0 -0
- /package/src/utils/{loggerHelpers.ts → services/logger.ts} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execCommand } from "../services/exec.js";
|
|
4
|
+
import { LoggerHelpers } from "../services/logger.js";
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
validateFlutterProject,
|
|
8
|
+
validateFlutterSdk,
|
|
9
|
+
validateIosProject,
|
|
10
|
+
validateAndroidProject,
|
|
11
|
+
checkFileExists,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Validates that the current directory is a Flutter project
|
|
16
|
+
* by checking for pubspec.yaml
|
|
17
|
+
*/
|
|
18
|
+
function validateFlutterProject(): boolean {
|
|
19
|
+
const pubspecPath = path.join(process.cwd(), "pubspec.yaml");
|
|
20
|
+
|
|
21
|
+
if (!fs.existsSync(pubspecPath)) {
|
|
22
|
+
LoggerHelpers.error("Not a Flutter project: pubspec.yaml not found.");
|
|
23
|
+
LoggerHelpers.info("Please run this command from the root of a Flutter project.");
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Check if pubspec.yaml contains Flutter SDK
|
|
28
|
+
const pubspecContent = fs.readFileSync(pubspecPath, "utf8");
|
|
29
|
+
if (!pubspecContent.includes("flutter:")) {
|
|
30
|
+
LoggerHelpers.error("Not a Flutter project: pubspec.yaml does not reference Flutter SDK.");
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Validates that Flutter SDK is available (either via FVM or globally)
|
|
39
|
+
*/
|
|
40
|
+
async function validateFlutterSdk(useFvm: boolean = false): Promise<boolean> {
|
|
41
|
+
try {
|
|
42
|
+
if (useFvm) {
|
|
43
|
+
// Check if FVM directory exists
|
|
44
|
+
const fvmPath = path.join(process.cwd(), ".fvm", "flutter_sdk");
|
|
45
|
+
if (!fs.existsSync(fvmPath)) {
|
|
46
|
+
LoggerHelpers.error("FVM Flutter SDK not found at .fvm/flutter_sdk");
|
|
47
|
+
LoggerHelpers.info("Run 'fvm install' or use --disable-fvm flag.");
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check if fvm command is available
|
|
52
|
+
await execCommand("fvm --version");
|
|
53
|
+
return true;
|
|
54
|
+
} else {
|
|
55
|
+
// Check if global Flutter is available
|
|
56
|
+
await execCommand("flutter --version");
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (useFvm) {
|
|
61
|
+
LoggerHelpers.error("FVM not found. Please install FVM or use --disable-fvm flag.");
|
|
62
|
+
LoggerHelpers.info("Install FVM: https://fvm.app/docs/getting_started/installation");
|
|
63
|
+
} else {
|
|
64
|
+
LoggerHelpers.error("Flutter SDK not found.");
|
|
65
|
+
LoggerHelpers.info("Install Flutter: https://flutter.dev/docs/get-started/install");
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Validates that the iOS project exists
|
|
73
|
+
*/
|
|
74
|
+
function validateIosProject(): boolean {
|
|
75
|
+
const iosPath = path.join(process.cwd(), "ios");
|
|
76
|
+
|
|
77
|
+
if (!fs.existsSync(iosPath)) {
|
|
78
|
+
LoggerHelpers.error("iOS project directory not found.");
|
|
79
|
+
LoggerHelpers.info("Run 'flutter create .' to add iOS support.");
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const xcodeProjPath = path.join(iosPath, "Runner.xcodeproj");
|
|
84
|
+
const xcworkspacePath = path.join(iosPath, "Runner.xcworkspace");
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(xcodeProjPath) && !fs.existsSync(xcworkspacePath)) {
|
|
87
|
+
LoggerHelpers.error("No Xcode project or workspace found in ios/ directory.");
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Validates that the Android project exists
|
|
96
|
+
*/
|
|
97
|
+
function validateAndroidProject(): boolean {
|
|
98
|
+
const androidPath = path.join(process.cwd(), "android");
|
|
99
|
+
|
|
100
|
+
if (!fs.existsSync(androidPath)) {
|
|
101
|
+
LoggerHelpers.error("Android project directory not found.");
|
|
102
|
+
LoggerHelpers.info("Run 'flutter create .' to add Android support.");
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const buildGradlePath = path.join(androidPath, "build.gradle");
|
|
107
|
+
const buildGradleKtsPath = path.join(androidPath, "build.gradle.kts");
|
|
108
|
+
|
|
109
|
+
if (!fs.existsSync(buildGradlePath) && !fs.existsSync(buildGradleKtsPath)) {
|
|
110
|
+
LoggerHelpers.error("No build.gradle found in android/ directory.");
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Checks if a file exists at the given path
|
|
119
|
+
*/
|
|
120
|
+
function checkFileExists(filePath: string): boolean {
|
|
121
|
+
return fs.existsSync(filePath);
|
|
122
|
+
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execCommand } from "../utils/execHelpers.js";
|
|
3
|
-
import { LoggerHelpers } from "../utils/loggerHelpers.js";
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
buildFlutterApk,
|
|
7
|
-
buildFlutterBundle,
|
|
8
|
-
buildFlutterIos,
|
|
9
|
-
buildFlutterIpa,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
async function buildFlutterApk(noFvm: boolean) {
|
|
13
|
-
LoggerHelpers.info(
|
|
14
|
-
noFvm
|
|
15
|
-
? "Building Flutter APK without FVM..."
|
|
16
|
-
: "Building Flutter APK with FVM..."
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const command = noFvm
|
|
20
|
-
? "flutter build apk --release --obfuscate --split-debug-info=build/app/outputs/symbols"
|
|
21
|
-
: "fvm flutter build apk --release --obfuscate --split-debug-info=build/app/outputs/symbols";
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
await execCommand(command);
|
|
25
|
-
LoggerHelpers.success("Flutter APK build successful.");
|
|
26
|
-
} catch (error) {
|
|
27
|
-
if (error instanceof Error) {
|
|
28
|
-
LoggerHelpers.error(`Error during APK build: ${error.message}`);
|
|
29
|
-
} else {
|
|
30
|
-
LoggerHelpers.error(`Error during APK build: ${error}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function buildFlutterBundle(noFvm: boolean) {
|
|
36
|
-
LoggerHelpers.info(
|
|
37
|
-
noFvm
|
|
38
|
-
? "Building Flutter Bundle without FVM..."
|
|
39
|
-
: "Building Flutter Bundle with FVM..."
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const command = noFvm
|
|
43
|
-
? "flutter build appbundle --release --obfuscate --split-debug-info=build/app/outputs/symbols"
|
|
44
|
-
: "fvm flutter build appbundle --release --obfuscate --split-debug-info=build/app/outputs/symbols";
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
await execCommand(command);
|
|
48
|
-
LoggerHelpers.success("Flutter Bundle build successful.");
|
|
49
|
-
} catch (error) {
|
|
50
|
-
if (error instanceof Error) {
|
|
51
|
-
LoggerHelpers.error(`Error during Bundle build: ${error.message}`);
|
|
52
|
-
} else {
|
|
53
|
-
LoggerHelpers.error(`Error during Bundle build: ${error}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async function buildFlutterIos(noFvm: boolean) {
|
|
59
|
-
LoggerHelpers.info(
|
|
60
|
-
noFvm
|
|
61
|
-
? "Building Flutter iOS app without FVM..."
|
|
62
|
-
: "Building Flutter iOS app with FVM..."
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const command = noFvm
|
|
66
|
-
? "flutter build ios --release"
|
|
67
|
-
: "fvm flutter build ios --release";
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
await execCommand(command);
|
|
71
|
-
LoggerHelpers.success("Flutter iOS app build successful.");
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (error instanceof Error) {
|
|
74
|
-
LoggerHelpers.error(`Error during iOS build: ${error.message}`);
|
|
75
|
-
} else {
|
|
76
|
-
LoggerHelpers.error(`Error during iOS build: ${error}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function buildFlutterIpa(noFvm: boolean) {
|
|
82
|
-
LoggerHelpers.info(
|
|
83
|
-
noFvm
|
|
84
|
-
? "Creating release IPA without FVM..."
|
|
85
|
-
: "Creating release IPA with FVM..."
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const command = noFvm
|
|
89
|
-
? "flutter build ipa --release"
|
|
90
|
-
: "fvm flutter build ipa --release";
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
await execCommand(command);
|
|
94
|
-
LoggerHelpers.success("Release IPA creation successful.");
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if (error instanceof Error) {
|
|
97
|
-
LoggerHelpers.error(`Error during IPA creation: ${error.message}`);
|
|
98
|
-
} else {
|
|
99
|
-
LoggerHelpers.error(`Error during IPA creation: ${error}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { execCommand } from "../utils/execHelpers.js";
|
|
2
|
-
import { LoggerHelpers } from "../utils/loggerHelpers.js";
|
|
3
|
-
|
|
4
|
-
export { cleanProject };
|
|
5
|
-
|
|
6
|
-
async function cleanProject(noFvm: boolean) {
|
|
7
|
-
LoggerHelpers.info(
|
|
8
|
-
noFvm ? "Running clean without FVM..." : "Running clean with FVM..."
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
const command = noFvm
|
|
12
|
-
? "flutter clean && rm -rf pubspec.lock && flutter pub get"
|
|
13
|
-
: "fvm flutter clean && rm -rf pubspec.lock && fvm flutter pub get";
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
await execCommand(command);
|
|
17
|
-
LoggerHelpers.success("Project cleaned successfully.");
|
|
18
|
-
} catch (error) {
|
|
19
|
-
if (error instanceof Error) {
|
|
20
|
-
LoggerHelpers.error(`Error during clean: ${error.message}`);
|
|
21
|
-
} else {
|
|
22
|
-
LoggerHelpers.error(`Error during clean: ${error}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { LoggerHelpers } from "../utils/loggerHelpers.js";
|
|
2
|
-
import { execCommand } from "../utils/execHelpers.js";
|
|
3
|
-
import { platform } from "os";
|
|
4
|
-
|
|
5
|
-
export { openIos, openAndroid };
|
|
6
|
-
|
|
7
|
-
async function openIos() {
|
|
8
|
-
LoggerHelpers.info("Opening the iOS project in Xcode...");
|
|
9
|
-
|
|
10
|
-
const command = "open ios/Runner.xcworkspace";
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
await execCommand(command);
|
|
14
|
-
LoggerHelpers.success("Xcode opened successfully.");
|
|
15
|
-
} catch (error) {
|
|
16
|
-
if (error instanceof Error) {
|
|
17
|
-
LoggerHelpers.error(`Error while opening Xcode: ${error.message}`);
|
|
18
|
-
} else {
|
|
19
|
-
LoggerHelpers.error(`Error while opening Xcode: ${error}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function openAndroid() {
|
|
25
|
-
LoggerHelpers.info("Opening the Android project in Android Studio...");
|
|
26
|
-
|
|
27
|
-
const osPlatform = platform();
|
|
28
|
-
let command;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (osPlatform === "win32") {
|
|
32
|
-
command = "start android";
|
|
33
|
-
} else if (osPlatform === "darwin") {
|
|
34
|
-
command = "open -a 'Android Studio' android";
|
|
35
|
-
} else {
|
|
36
|
-
command = "xdg-open android";
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
await execCommand(command);
|
|
41
|
-
LoggerHelpers.success("Android Studio opened successfully.");
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (error instanceof Error) {
|
|
44
|
-
LoggerHelpers.error(
|
|
45
|
-
`Error while opening Android Studio: ${error.message}`
|
|
46
|
-
);
|
|
47
|
-
} else {
|
|
48
|
-
LoggerHelpers.error(`Error while opening Android Studio: ${error}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { execCommand } from "../utils/execHelpers.js";
|
|
3
|
-
import { LoggerHelpers } from "../utils/loggerHelpers.js";
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
createVscodeSettings,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a .vscode directory (if it doesn't exist) and writes a settings.json file
|
|
11
|
-
* with recommended Flutter configuration. The Flutter SDK path is set to ".fvm/flutter_sdk".
|
|
12
|
-
*/
|
|
13
|
-
async function createVscodeSettings(): Promise<void> {
|
|
14
|
-
try {
|
|
15
|
-
// Create the .vscode folder (using -p ensures it won't error if it already exists)
|
|
16
|
-
await execCommand('mkdir -p .vscode');
|
|
17
|
-
LoggerHelpers.success("Created .vscode directory (if not already present).");
|
|
18
|
-
|
|
19
|
-
// Use a heredoc to write the settings.json file
|
|
20
|
-
const command = `
|
|
21
|
-
cat << 'EOF' > .vscode/settings.json
|
|
22
|
-
{
|
|
23
|
-
"dart.flutterSdkPath": ".fvm/flutter_sdk",
|
|
24
|
-
"editor.formatOnSave": true,
|
|
25
|
-
"dart.previewFlutterUiGuides": true,
|
|
26
|
-
"files.exclude": {
|
|
27
|
-
"**/.git": true,
|
|
28
|
-
"**/.DS_Store": true,
|
|
29
|
-
"**/node_modules": true,
|
|
30
|
-
"**/build": true
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
EOF
|
|
34
|
-
`;
|
|
35
|
-
await execCommand(command);
|
|
36
|
-
LoggerHelpers.success("Created .vscode/settings.json with Flutter configuration.");
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error instanceof Error) {
|
|
39
|
-
LoggerHelpers.error(`Error while creating VSCode settings: ${error.message}`);
|
|
40
|
-
} else {
|
|
41
|
-
LoggerHelpers.error(`Error while creating VSCode settings: ${error}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
File without changes
|
|
File without changes
|