Skip to content

Commit 6aa7423

Browse files
committed
fix the logic for importing
1 parent f0e19f5 commit 6aa7423

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

typescript/packages/common-cli/google-importer.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ function showHelp() {
1111
console.log("Usage: deno run main.ts [options]");
1212
console.log("");
1313
console.log("Options:");
14-
console.log(
15-
" --space=<space> Space to watch (default: common-knowledge)",
16-
);
14+
console.log(" --space=<space> Space to watch (default: common-knowledge)");
1715
console.log(" --charmId=<id> Specific charm ID to watch");
18-
console.log(
19-
" --interval=<seconds> Update interval in seconds (default: 30)",
20-
);
16+
console.log(" --interval=<seconds> Update interval in seconds (default: 30)");
2117
console.log(" --help Show this help message");
2218
console.log(" --version Show version information");
2319
Deno.exit(0);
@@ -35,8 +31,7 @@ const { space, charmId, interval } = flags;
3531

3632
// Configuration
3733
const CHECK_INTERVAL = parseInt(interval as string) * 1000;
38-
const toolshedUrl = Deno.env.get("TOOLSHED_API_URL") ??
39-
"https://toolshed.saga-castor.ts.net/";
34+
const toolshedUrl = Deno.env.get("TOOLSHED_API_URL") ?? "https://toolshed.saga-castor.ts.net/";
4035

4136
// Initialize storage and Bobby server
4237
storage.setRemoteStorage(new URL(toolshedUrl));
@@ -95,10 +90,7 @@ async function refreshAuthToken(auth: Cell<any>, charm: Cell<Charm>) {
9590
authCellId.space = space as string;
9691
log(charm, `token expired, refreshing: ${authCellId}`);
9792

98-
const refresh_url = new URL(
99-
"/api/integrations/google-oauth/refresh",
100-
toolshedUrl,
101-
);
93+
const refresh_url = new URL("/api/integrations/google-oauth/refresh", toolshedUrl);
10294
const refresh_response = await fetch(refresh_url, {
10395
method: "POST",
10496
body: JSON.stringify({ authCellId }),
@@ -114,15 +106,15 @@ async function refreshAuthToken(auth: Cell<any>, charm: Cell<Charm>) {
114106
log(charm, "refreshed token");
115107
}
116108

117-
const isGoogleUpdaterCharm = async (charmId: string): Promise<boolean> => {
109+
const notGoogleUpdaterCharm = async (charmId: string): Promise<boolean> => {
118110
const charm = await manager.get(charmId, false);
119111
if (!charm) {
120112
log(charmId, "charm not found");
121113
return true;
122114
}
123115
const googleUpdater = charm.key("googleUpdater");
124116
const auth = charm.key("auth");
125-
return !!(isStream(googleUpdater) && auth);
117+
return !(isStream(googleUpdater) && auth);
126118
};
127119

128120
/**
@@ -134,7 +126,7 @@ function isIgnoredCharm(charmId: string): Promise<boolean> {
134126
}
135127
checkedCharms.set(charmId, true);
136128

137-
return isGoogleUpdaterCharm(charmId);
129+
return notGoogleUpdaterCharm(charmId);
138130
}
139131

140132
async function watchCharm(charmId: string | undefined) {
@@ -157,9 +149,7 @@ async function watchCharm(charmId: string | undefined) {
157149
}
158150

159151
function getId(charmId: string | Cell<Charm> | undefined): string | undefined {
160-
const realCharmId = typeof charmId === "string"
161-
? charmId
162-
: getEntityId(charmId)?.["/"];
152+
const realCharmId = typeof charmId === "string" ? charmId : getEntityId(charmId)?.["/"];
163153
if (!realCharmId) {
164154
log(undefined, "charmId not found", JSON.stringify(charmId));
165155
return undefined;

0 commit comments

Comments
 (0)