Skip to content

Commit

Permalink
removed npm account management out of core and into the gui app
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Dec 30, 2024
1 parent 4a59498 commit 02be7cd
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 900 deletions.
7 changes: 0 additions & 7 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@
<version>4.4.14</version>
</dependency>


<dependency>
<groupId>com.github.javakeyring</groupId>
<artifactId>java-keyring</artifactId>
<version>1.0.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.vdurmont/semver4j -->
<dependency>
<groupId>com.vdurmont</groupId>
Expand Down
13 changes: 0 additions & 13 deletions cli/src/main/java/ca/weblite/jdeploy/cli/di/JDeployCliModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import ca.weblite.jdeploy.cli.util.CliChatThreadDispatcher;
import ca.weblite.jdeploy.cli.util.CliUiThreadDispatcher;
import ca.weblite.jdeploy.npm.NpmAccountServiceInterface;
import ca.weblite.jdeploy.npm.PreferencesNpmAccountService;
import ca.weblite.jdeploy.openai.interop.ChatThreadDispatcher;
import ca.weblite.jdeploy.openai.interop.UiThreadDispatcher;
import ca.weblite.jdeploy.project.service.DefaultProjectLoader;
import ca.weblite.jdeploy.project.service.ProjectLoader;
import ca.weblite.jdeploy.secure.JavaKeyringPasswordService;
import ca.weblite.jdeploy.secure.PasswordServiceInterface;
import org.codejargon.feather.Provides;

public class JDeployCliModule {
Expand All @@ -29,13 +25,4 @@ public ProjectLoader projectLoader(DefaultProjectLoader impl) {
return impl;
}

@Provides
public NpmAccountServiceInterface npmAccountServiceInterface(PreferencesNpmAccountService impl) {
return impl;
}
@Provides
public PasswordServiceInterface passwordServiceInterface(JavaKeyringPasswordService javaKeyringPasswordService) {
return javaKeyringPasswordService;
}

}
63 changes: 0 additions & 63 deletions cli/src/main/java/ca/weblite/jdeploy/gui/EditNpmAccountDialog.java

This file was deleted.

74 changes: 0 additions & 74 deletions cli/src/main/java/ca/weblite/jdeploy/gui/EditNpmAccountPanel.java

This file was deleted.

54 changes: 3 additions & 51 deletions cli/src/main/java/ca/weblite/jdeploy/gui/JDeployProjectEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import ca.weblite.jdeploy.JDeploy;
import ca.weblite.jdeploy.gui.controllers.EditGithubWorkflowController;
import ca.weblite.jdeploy.gui.controllers.GenerateGithubWorkflowController;
import ca.weblite.jdeploy.gui.controllers.NpmAccountChooserController;
import ca.weblite.jdeploy.gui.controllers.VerifyWebsiteController;
import ca.weblite.jdeploy.gui.tabs.CheerpJSettings;
import ca.weblite.jdeploy.gui.tabs.DetailsPanel;
import ca.weblite.jdeploy.helpers.NPMApplicationHelper;
import ca.weblite.jdeploy.models.NPMApplication;
import ca.weblite.jdeploy.npm.NPM;
import ca.weblite.jdeploy.npm.NpmAccountServiceInterface;
import ca.weblite.jdeploy.npm.TerminalLoginLauncher;
import ca.weblite.jdeploy.services.ExportIdentityService;
import ca.weblite.jdeploy.services.GithubService;
Expand All @@ -20,10 +18,8 @@
import ca.weblite.tools.io.FileUtil;
import ca.weblite.tools.io.MD5;
import com.sun.nio.file.SensitivityWatchEventModifier;
import io.codeworth.panelmatic.PanelBuilder;
import io.codeworth.panelmatic.PanelMatic;
import io.codeworth.panelmatic.util.Groupings;
import io.codeworth.panelmatic.util.PanelPostProcessors;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.io.FileUtils;
import org.json.JSONArray;
Expand All @@ -42,7 +38,6 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.*;
Expand Down Expand Up @@ -1844,52 +1839,9 @@ private void handleExportIdentity0() throws IOException {
}

private void handlePublish0() throws ValidationException {
handlePublish0(true);
}

private void handlePublish0(boolean promptForAccount) throws ValidationException {

if (promptForAccount) {
final boolean[] accountChosen = {false};
final boolean[] accountChosenResult = {false};
final Object lock = new Object();

Runnable runnablePublish = () -> {
NpmAccountChooserController accountChooserController = new NpmAccountChooserController(
frame, DIContext.getInstance().getInstance(NpmAccountServiceInterface.class)
);

accountChooserController.show().thenAccept(account -> {
if (account == null) {
accountChosen[0] = true;
synchronized (lock) {
lock.notify();
return;
}
}
context.setNpmToken(account.getNpmToken());
accountChosen[0] = true;
accountChosenResult[0] = true;
synchronized (lock) {
lock.notify();
}
});

};
SwingUtilities.invokeLater(runnablePublish);

while (!accountChosen[0]) {
try {
synchronized (lock) {
lock.wait(1000);
}
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
if (!accountChosenResult[0]) {
return;
}
if (!EventQueue.isDispatchThread()) {
// We don't prompt on the dispatch thread because promptForNpmToken blocks
context.promptForNpmToken(frame);
}

File absDirectory = packageJSONFile.getAbsoluteFile().getParentFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.weblite.jdeploy.DIContext;
import ca.weblite.jdeploy.interop.DesktopInterop;
import ca.weblite.jdeploy.interop.FileChooserInterop;
import ca.weblite.jdeploy.npm.NpmAccountChooserInterface;
import ca.weblite.tools.platform.Platform;

import javax.swing.*;
Expand Down Expand Up @@ -70,6 +69,10 @@ public boolean useManagedNode() {
return false;
}

public void promptForNpmToken(Object parent) {

}

public void setNpmToken(String npmToken) {
this.npmToken = npmToken;
}
Expand Down
Loading

0 comments on commit 02be7cd

Please sign in to comment.