Skip to content

Commit 919afb2

Browse files
committed
chore: make strict mode on by default
1 parent be91dd5 commit 919afb2

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

templates/cli/lib/commands/types.js.twig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const path = require("path");
44
const { LanguageMeta, detectLanguage } = require("../type-generation/languages/language");
55
const { Command, Option, Argument } = require("commander");
66
const { localConfig } = require("../config");
7-
const { success, log, actionRunner } = require("../parser");
7+
const { success, log, warn, actionRunner } = require("../parser");
88
const { PHP } = require("../type-generation/languages/php");
99
const { TypeScript } = require("../type-generation/languages/typescript");
1010
const { Kotlin } = require("../type-generation/languages/kotlin");
@@ -59,19 +59,23 @@ const typesLanguageOption = new Option(
5959
.default("auto");
6060

6161
const typesStrictOption = new Option(
62-
"-s, --strict",
63-
"Enable strict mode to automatically convert field names to follow language conventions"
62+
"-s, --strict <value>",
63+
"Disable strict mode to not automatically convert field names to follow language conventions"
6464
)
65-
.default(false);
65+
.choices(["true", "false"])
66+
.default("true");
6667

6768
const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict}) => {
6869
if (language === "auto") {
6970
language = detectLanguage();
7071
log(`Detected language: ${language}`);
7172
}
7273

74+
strict = strict === "true" || strict === true;
7375
if (strict) {
7476
log(`Strict mode enabled: Field names will be converted to follow ${language} conventions`);
77+
} else {
78+
warn(`Strict mode disabled: Field names will not be converted to follow ${language} conventions`);
7579
}
7680

7781
const meta = createLanguageMeta(language);

templates/cli/lib/type-generation/languages/dart.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ import '<%- toSnakeCase(collections.find(c => c.$id === attribute.relatedCollect
8787
<% } -%>
8888
<% } -%>
8989
/// This file is auto-generated by the Appwrite CLI.
90-
/// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>dart <%- path %>\`.
90+
/// You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>dart <%- path %>\`.
9191

9292
<% for (const attribute of collection.attributes) { -%>
9393
<% if (attribute.format === 'enum') { -%>

templates/cli/lib/type-generation/languages/java.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Java extends LanguageMeta {
4444

4545
/**
4646
* This file is auto-generated by the Appwrite CLI.
47-
* You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>java <%- path %>\`.
47+
* You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>java <%- path %>\`.
4848
*/
4949

5050
import java.util.Objects;

templates/cli/lib/type-generation/languages/javascript.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class JavaScript extends LanguageMeta {
6767
*/
6868

6969
// This file is auto-generated by the Appwrite CLI.
70-
// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>js <%- path %>\`.
70+
// You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>js <%- path %>\`.
7171

7272
<% for (const collection of collections) { -%>
7373
<% for (const attribute of collection.attributes) { -%>

templates/cli/lib/type-generation/languages/kotlin.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollect
5353
<% } -%>
5454
/**
5555
* This file is auto-generated by the Appwrite CLI.
56-
* You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>kotlin <%- path %>\`.
56+
* You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>kotlin <%- path %>\`.
5757
*/
5858

5959
<% for (const attribute of collection.attributes) { -%>

templates/cli/lib/type-generation/languages/php.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PHP extends LanguageMeta {
4747
namespace Appwrite\\Models;
4848
4949
// This file is auto-generated by the Appwrite CLI.
50-
// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>php <%- path %>\`.
50+
// You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>php <%- path %>\`.
5151
5252
<% for (const attribute of collection.attributes) { -%>
5353
<% if (attribute.type === 'relationship' && !(attribute.relationType === 'manyToMany') && !(attribute.relationType === 'oneToMany' && attribute.side === 'parent')) { -%>

templates/cli/lib/type-generation/languages/swift.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Swift extends LanguageMeta {
4646
return `import Foundation
4747

4848
/// This file is auto-generated by the Appwrite CLI.
49-
/// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>swift <%- path %>\`.
49+
/// You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>swift <%- path %>\`.
5050

5151
<% for (const attribute of collection.attributes) { -%>
5252
<% if (attribute.format === 'enum') { -%>

templates/cli/lib/type-generation/languages/typescript.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TypeScript extends LanguageMeta {
6969
return `import { type Models } from '${this._getAppwriteDependency()}';
7070

7171
// This file is auto-generated by the Appwrite CLI.
72-
// You can regenerate it by running \`appwrite types -l <%- strict ? '--strict ' : '' %>ts <%- path %>\`.
72+
// You can regenerate it by running \`appwrite types -l <%- strict ? '' : '--strict false' %>ts <%- path %>\`.
7373

7474
<% for (const collection of collections) { -%>
7575
<% for (const attribute of collection.attributes) { -%>

0 commit comments

Comments
 (0)