Skip to content

Commit

Permalink
feat: remove createEnvFile and updateEnvFile (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike authored Nov 8, 2024
1 parent 87b1c34 commit a2752d8
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 123 deletions.
29 changes: 1 addition & 28 deletions packages/core/installMachine/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createMachine, fromPromise, ActorLogic, AnyEventObject, PromiseSnapshot, createActor, and, not } from 'xstate';

import { createEnvFile } from './installSteps/env/createEnvFile';
import { initializeRepository } from './installSteps/github/install';
import { preparePayload } from './installSteps/payload/install';
import { prettify } from './installSteps/prettier/prettify';
Expand Down Expand Up @@ -59,25 +58,11 @@ const createInstallMachine = (initialContext: InstallMachineContext) => {
always: [
{
guard: isStepCompleted('initializeProject'),
target: 'createEnvFile',
},
],
invoke: {
src: 'initializeProjectActor',
input: ({ context }) => context,
onDone: 'createEnvFile',
onError: 'failed',
},
},
createEnvFile: {
always: [
{
guard: isStepCompleted('createEnvFile'),
target: 'installSupabase',
},
],
invoke: {
src: 'createEnvFileActor',
src: 'initializeProjectActor',
input: ({ context }) => context,
onDone: 'installSupabase',
onError: 'failed',
Expand Down Expand Up @@ -288,18 +273,6 @@ const createInstallMachine = (initialContext: InstallMachineContext) => {
}
}),
),
createEnvFileActor: createStepMachine(
fromPromise<void, InstallMachineContext, AnyEventObject>(async ({ input }) => {
try {
createEnvFile(input.projectDir);
input.stateData.stepsCompleted.createEnvFile = true;
saveStateToRcFile(input.stateData, input.projectDir);
} catch (error) {
console.error('Error in createEnvFileActor:', error);
throw error;
}
}),
),
installSupabaseActor: createStepMachine(
fromPromise<void, InstallMachineContext, AnyEventObject>(async ({ input }) => {
try {
Expand Down
29 changes: 0 additions & 29 deletions packages/core/installMachine/installSteps/env/createEnvFile.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import inquirer from 'inquirer';
import { promisify } from 'util';
import chalk from 'chalk';
import { continueOnAnyKeypress } from '../../../utils/continueOnKeypress';
import { updateEnvFile } from '../../../utils/updateEnvFile';
import { getSupabaseKeys, parseProjectsList } from './utils';
import { logWithColoredPrefix } from '../../../utils/logWithColoredPrefix';

Expand Down Expand Up @@ -33,18 +32,6 @@ export const connectSupabaseProject = async (projectName: string, currentDir: st
throw new Error('Failed to retrieve Supabase API keys. Please check your project configuration.');
}

const SUPABASE_URL = `https://${newProject.refId}.supabase.co/`;

logWithColoredPrefix('supabase', `Saving keys to .env...`);
await updateEnvFile({
currentDir,
pairs: [
['SUPABASE_ANON_KEY', anonKey],
['SUPABASE_SERVICE_ROLE_KEY', serviceRoleKey],
['SUPABASE_URL', SUPABASE_URL],
],
});

logWithColoredPrefix('supabase', 'Linking project...');
execSync(`npx supabase link --project-ref ${newProject.refId}`, { stdio: 'inherit' });

Expand Down
1 change: 0 additions & 1 deletion packages/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export interface ProjectOptions {

export interface StepsCompleted {
initializeProject: boolean;
createEnvFile: boolean;
installSupabase: boolean;
setupDatabaseWithDocker: boolean;
installPayload: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/utils/rcFileManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const initializeRcFile = (projectDir: string, name: string, usePayload: b
projectName: name,
stepsCompleted: {
initializeProject: false,
createEnvFile: false,
installPayload: false,
installSupabase: false,
setupDatabaseWithDocker: false,
prettifyCode: false,
createDocFiles: false,
createSupabaseProject: false,
Expand Down
51 changes: 0 additions & 51 deletions packages/core/utils/updateEnvFile.ts

This file was deleted.

0 comments on commit a2752d8

Please sign in to comment.