Skip to content

Commit ec1bdf7

Browse files
committed
feat: add --allow-node-modules flag
1 parent 33a8afc commit ec1bdf7

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

create.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export async function create(
1515
deployUrl: string,
1616
rootPath: string,
1717
configContent: Config | null,
18+
allowNodeModules: boolean,
1819
initOrg?: string,
1920
) {
2021
let verifier;
@@ -90,5 +91,14 @@ export async function create(
9091
`${green("✔")} App '${app}' created in the '${org}' organization.\n`,
9192
);
9293

93-
await publish(debug, deployUrl, rootPath, configContent, org, app, true);
94+
await publish(
95+
debug,
96+
deployUrl,
97+
rootPath,
98+
configContent,
99+
org,
100+
app,
101+
true,
102+
allowNodeModules,
103+
);
94104
}

main.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export type GlobalOptions = {
3939

4040
const createCommand = new Command<GlobalOptions>()
4141
.description("Create a new application")
42+
.option(
43+
"--allow-node-modules",
44+
"Allow node_modules directory to be included when uploading",
45+
)
4246
.option(
4347
"--org <name:string>",
4448
"The name of the organization to create the application for",
@@ -58,7 +62,14 @@ const createCommand = new Command<GlobalOptions>()
5862
Deno.exit(1);
5963
}
6064

61-
await create(debug, endpoint, rootPath, configContent, initOrg);
65+
await create(
66+
debug,
67+
endpoint,
68+
rootPath,
69+
configContent,
70+
options.allowNodeModules ?? false,
71+
initOrg,
72+
);
6273
},
6374
);
6475

@@ -273,6 +284,10 @@ deploy your local directory to the specified application.`)
273284
.option("--org <name:string>", "The name of the organization")
274285
.option("--app <name:string>", "The name of the application")
275286
.option("--prod", "Deploy directly to production")
287+
.option(
288+
"--allow-node-modules",
289+
"Allow node_modules directory to be included when uploading",
290+
)
276291
.arguments("[root-path:string]")
277292
.globalAction((options) => {
278293
const endpoint = Deno.env.get("DENO_DEPLOY_ENDPOINT");
@@ -314,6 +329,7 @@ deploy your local directory to the specified application.`)
314329
options.endpoint as string,
315330
rootPath,
316331
configContent,
332+
options.allowNodeModules ?? false,
317333
orgAndApp.org,
318334
);
319335
} else {
@@ -325,6 +341,7 @@ deploy your local directory to the specified application.`)
325341
orgAndApp.org,
326342
orgAndApp.app,
327343
options.prod ?? false,
344+
options.allowNodeModules ?? false,
328345
);
329346
}
330347
},

publish.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,38 @@ export async function publish(
3232
org: string,
3333
app: string,
3434
prod: boolean,
35+
allowNodeModules: boolean,
3536
) {
3637
let gitignore: { denies(input: string): boolean } = {
3738
denies: () => false,
3839
};
3940

41+
const gitignorePath = join(rootPath, ".gitignore");
4042
try {
41-
gitignore = gitignoreCompile(
42-
Deno.readTextFileSync(join(rootPath, ".gitignore")),
43-
);
43+
if (debug) {
44+
console.log(`Using .gitignore at '${gitignorePath}'`);
45+
}
46+
47+
gitignore = gitignoreCompile(Deno.readTextFileSync(gitignorePath));
4448
} catch (_) {
49+
if (debug) {
50+
console.log(`No .gitignore found at '${gitignorePath}'`);
51+
}
52+
4553
//
4654
}
4755

4856
const excludes = [
49-
new RegExp(`${SEPARATOR_PATTERN}node_modules(:?${SEPARATOR_PATTERN}|$)`),
5057
new RegExp(`${SEPARATOR_PATTERN}\.git(:?${SEPARATOR_PATTERN}|$)`),
5158
new RegExp(`${SEPARATOR_PATTERN}\.DS_Store`),
5259
];
5360

61+
if (!allowNodeModules) {
62+
excludes.push(
63+
new RegExp(`${SEPARATOR_PATTERN}node_modules(:?${SEPARATOR_PATTERN}|$)`),
64+
);
65+
}
66+
5467
console.log(`Publishing '${resolve(rootPath)}'`);
5568

5669
const stream: ReadableStream<Chunk> = ReadableStream.from(

0 commit comments

Comments
 (0)