Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontend refactor: move everything to imports/ #3231

Merged
merged 19 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ tmp
node_modules
meteor-spk-*
.meteor-spk
shell/client/changelog.html
shell/imports/client/changelog.html
shell/client/styles/_icons.scss
shell/sandstorm-shell.config
shell/sandstorm-shell.creator
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ IMAGES= \
all: sandstorm-$(BUILD).tar.xz

clean: ci-clean
rm -rf shell/node_modules shell/.meteor/local $(IMAGES) shell/client/changelog.html shell/packages/*/.build* shell/packages/*/.npm/package/node_modules *.sig *.update-sig icons/node_modules shell/public/icons/icons-*.eot shell/public/icons/icons-*.ttf shell/public/icons/icons-*.svg shell/public/icons/icons-*.woff icons/package-lock.json tests/package-lock.json deps/llvm-build meteor-testapp/node_modules
rm -rf shell/node_modules shell/.meteor/local $(IMAGES) shell/imports/client/changelog.html *.sig *.update-sig icons/node_modules shell/public/icons/icons-*.eot shell/public/icons/icons-*.ttf shell/public/icons/icons-*.svg shell/public/icons/icons-*.woff icons/package-lock.json tests/package-lock.json deps/llvm-build meteor-testapp/node_modules
@# Note: capnproto, libseccomp, and node-capnp are integrated into the common build.
cd deps/ekam && make clean
rm -rf deps/libsodium/build
Expand Down Expand Up @@ -274,7 +274,7 @@ shell-env: tmp/.shell-env

# Note that we need Ekam to build node_modules before we can run Meteor, hence
# the dependency on tmp/.ekam-run.
tmp/.shell-env: tmp/.ekam-run $(IMAGES) shell/client/changelog.html shell/client/styles/_icons.scss shell/package.json shell/npm-shrinkwrap.json
tmp/.shell-env: tmp/.ekam-run $(IMAGES) shell/imports/client/changelog.html shell/client/styles/_icons.scss shell/package.json shell/npm-shrinkwrap.json
@$(call color,configuring meteor frontend)
@mkdir -p tmp
@mkdir -p node_modules/capnp
Expand All @@ -288,12 +288,12 @@ icons/node_modules: icons/package.json
shell/client/styles/_icons.scss: icons/node_modules icons/*svg icons/Gruntfile.js
cd icons && PATH=$(METEOR_DEV_BUNDLE)/bin:$$PATH ./node_modules/.bin/grunt

shell/client/changelog.html: CHANGELOG.md
shell/imports/client/changelog.html: CHANGELOG.md
@mkdir -p tmp
@echo '<template name="changelog">' > tmp/changelog.html
@markdown CHANGELOG.md >> tmp/changelog.html
@echo '</template>' >> tmp/changelog.html
@cp tmp/changelog.html shell/client/changelog.html
@cp tmp/changelog.html shell/imports/client/changelog.html

shell/public/close-FFFFFF.svg: icons/close.svg
@$(call color,custom color $<)
Expand Down Expand Up @@ -359,7 +359,7 @@ shell/public/%-m.svg: icons/%.svg
@# Make completely black.
@sed -e 's/#111111/#000000/g' < $< > $@

shell-build: shell/imports/* shell/imports/*/* shell/client/* shell/server/* shell/shared/* shell/public/* shell/packages/* shell/packages/*/* shell/i18n/* shell/.meteor/packages shell/.meteor/release shell/.meteor/versions tmp/.shell-env
shell-build: shell/imports/* shell/imports/*/* shell/imports/*/*/* shell/imports/*/*/*/* shell/client/main.js shell/server/main.js shell/public/* shell/i18n/* shell/.meteor/packages shell/.meteor/release shell/.meteor/versions tmp/.shell-env
@$(call color,building meteor frontend)
@test -z "$$(find -L shell/* -type l)" || (echo "error: broken symlinks in shell: $$(find -L shell/* -type l)" >&2 && exit 1)
@OLD=`pwd` && cd shell && meteor build --directory "$$OLD/shell-build"
Expand Down
12 changes: 3 additions & 9 deletions shell/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,20 @@ reload@1.3.0
random@1.1.0

iron:router
sandstorm-accounts-packages
accounts-base
accounts-oauth
http@1.4.2
browser-policy@1.1.0
routepolicy@1.1.0

reactive-var@1.0.11
reactive-dict@1.3.0
sandstorm-autoupdate-apps
sandstorm-capnp
sandstorm-db
sandstorm-identicons
sandstorm-permissions
sandstorm-ui-topbar
sandstorm-ui-powerbox
blackrock-payments
fourseven:scss
sha@1.0.9
standard-minifier-css@1.5.3
standard-minifier-js@2.4.1
shell-server@0.4.0
fongandrew:find-and-modify@0.2.2

oauth@1.2.8
service-configuration@1.0.11
Expand Down
9 changes: 0 additions & 9 deletions shell/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ babel-compiler@7.3.4
babel-runtime@1.3.0
base64@1.0.12
binary-heap@1.0.11
blackrock-payments@0.1.0
blaze@2.3.4
blaze-html-templates@1.1.2
blaze-tools@1.0.10
Expand Down Expand Up @@ -89,14 +88,6 @@ reactive-var@1.0.11
reload@1.3.0
retry@1.1.0
routepolicy@1.1.0
sandstorm-accounts-packages@0.1.0
sandstorm-autoupdate-apps@0.1.0
sandstorm-capnp@0.1.0
sandstorm-db@0.1.0
sandstorm-identicons@0.1.0
sandstorm-permissions@0.1.0
sandstorm-ui-powerbox@0.1.0
sandstorm-ui-topbar@0.1.0
service-configuration@1.0.11
session@1.2.0
sha@1.0.9
Expand Down
7 changes: 7 additions & 0 deletions shell/client/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<head>
<title>Sandstorm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
</body>
164 changes: 164 additions & 0 deletions shell/client/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
// Sandstorm - Personal Cloud Sandbox
// Copyright (c) 2020 Sandstorm Development Group, Inc. and contributors
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// =====
// NOTES
// =====
//
// This file exists to reify load order as we try to move everything to modern
// explicit imports. We'll start by moving files under /imports/ and then
// importing them in the same order that Meteor would have. This gives us the
// ability to start explicitly importing and exporting variables that we
// currently just rely on being present in the namespace at the right time.
//
// To allow incremental migration, this file's path is explicitly chosen to be
// the very first thing that is loaded out of the application client-side. We
// can shuffle things around and refactor a lot more easily once we've
// crashlanded everything in /imports/. Eventually, there will be a single file
// under client/ that imports everything in the order Meteor would have.
//
// Eventually, we'll also move packages in here, above the app's primary
// implementation, since packages are loaded first
//
// For more information on Meteor's load order, see
// https://guide.meteor.com/structure.html#load-order

import { Template } from "meteor/templating";

// Load packages that the sandstorm shell depends on before sandstorm itself.

// sandstorm-identicons.
import "../imports/sandstorm-identicons/identicon.js";
import "../imports/sandstorm-identicons/helpers.js";

// sandstorm-db. Depends on sandstorm-identicons.
import "../imports/sandstorm-db/db.js";
import "../imports/sandstorm-db/profile.js";

// sandstorm-accounts-packages
import "../imports/sandstorm-accounts-packages/accounts.js";

// sandstorm-ui-topbar. Depends on sandstorm-identicons.
import "../imports/sandstorm-ui-topbar/topbar.html";
import "../imports/sandstorm-ui-topbar/topbar.js";

// sandstorm-ui-powerbox. Depends on sandstorm-db and sandstorm-ui-topbar
import "../imports/sandstorm-ui-powerbox/powerbox.html";
import "../imports/sandstorm-ui-powerbox/powerbox-client.js";

// blackrock-payments
import "../imports/blackrock-payments/constants.js";
import "../imports/blackrock-payments/client/billingSettings.html";
import "../imports/blackrock-payments/client/billingPrompt.html";
import "../imports/blackrock-payments/client/payments-api.html";
import "../imports/blackrock-payments/client/billingSettings.js";
import "../imports/blackrock-payments/client/billingPrompt.js";
import "../imports/blackrock-payments/client/payments-client.js";
import "../imports/blackrock-payments/client/payments-api-client.js";

// Load sandstorm shell.
// Templates come first.
import "../imports/client/accounts/credentials/credentials.html";
import "../imports/client/accounts/email-token/token-templates.html";
import "../imports/client/accounts/account-settings.html";
import "../imports/client/accounts/login-buttons.html";
import "../imports/client/admin/admin.html";
import "../imports/client/admin/app-sources.html";
import "../imports/client/admin/email-config.html";
import "../imports/client/admin/hosting-management.html";
import "../imports/client/admin/login-providers.html";
import "../imports/client/admin/maintenance-message.html";
import "../imports/client/admin/network-capabilities.html";
import "../imports/client/admin/networking.html";
import "../imports/client/admin/organization.html";
import "../imports/client/admin/personalization.html";
import "../imports/client/admin/preinstalled-apps.html";
import "../imports/client/admin/stats.html";
import "../imports/client/admin/system-status.html";
import "../imports/client/admin/user-accounts.html";
import "../imports/client/admin/user-details.html";
import "../imports/client/admin/user-invite.html";
import "../imports/client/apps/app-details.html";
import "../imports/client/apps/applist.html";
import "../imports/client/apps/install.html";
import "../imports/client/billing/billingPromptLocal.html";
import "../imports/client/grain/contact-autocomplete.html";
import "../imports/client/grain/grainlist.html";
import "../imports/client/setup-wizard/wizard.html";
import "../imports/client/widgets/widgets.html";
import "../imports/client/changelog.html";
import "../imports/client/desktop-notifications.html";
import "../imports/client/grain.html";
import "../imports/client/notifications.html";
import "../imports/client/powerbox-builtins.html";
import "../imports/client/shell.html";
import "../imports/client/styleguide.html";
import "../imports/client/transfers.html";

// Things that came from client/lib.
import "../imports/client/globals.js";

// Everything else that came from client/
import "../imports/client/accounts/credentials/credentials-client.js";
import "../imports/client/accounts/email-token/token-client.js";
import "../imports/client/accounts/saml/saml-client-pt2.js";
import "../imports/client/accounts/account-settings.js";
import "../imports/client/accounts/accounts-testing.js";
import "../imports/client/accounts/login-buttons-session.js";
import "../imports/client/accounts/login-buttons.js";
import "../imports/client/admin/admin-new-client.js";
import "../imports/client/admin/app-sources-client.js";
import "../imports/client/admin/email-config-client.js";
import "../imports/client/admin/hosting-management-client.js";
import "../imports/client/admin/login-providers.js";
import "../imports/client/admin/maintenance-message-client.js";
import "../imports/client/admin/network-capabilities-client.js";
import "../imports/client/admin/networking-client.js";
import "../imports/client/admin/organization-client.js";
import "../imports/client/admin/personalization-client.js";
import "../imports/client/admin/preinstalled-apps-client.js";
import "../imports/client/admin/stats-client.js";
import "../imports/client/admin/system-status-client.js";
import "../imports/client/admin/user-accounts-client.js";
import "../imports/client/admin/user-details-client.js";
import "../imports/client/admin/user-invite-client.js";
import "../imports/client/apps/app-details-client.js";
import "../imports/client/apps/applist-client.js";
import "../imports/client/apps/install-client.js";
import "../imports/client/billing/billingPromptLocal-client.js";
import "../imports/client/grain/contact-autocomplete.js";
import "../imports/client/grain/grainlist-client.js";
import "../imports/client/setup-wizard/wizard.js";
import "../imports/client/vendor/ansi-up.js";
import "../imports/client/widgets/widgets-client.js";
import "../imports/client/00-startup.js";
import "../imports/client/admin-client.js";
import "../imports/client/demo-client.js";
import "../imports/client/desktop-notifications-client.js";
import "../imports/client/dev-accounts-client.js";
import "../imports/client/grain-client.js";
import "../imports/client/install-client.js";
import "../imports/client/notifications-client.js";
import "../imports/client/powerbox-builtins.js";
import "../imports/client/shell-client.js";
import "../imports/client/signup-client.js";
import "../imports/client/styleguide.js";
import "../imports/client/transfers-client.js";

import "../imports/shared/admin.js";
import "../imports/shared/dev-accounts.js";
import "../imports/shared/grain-shared.js";
import "../imports/shared/testing.js";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// limitations under the License.

import { allowDemo } from "/imports/demo.js";
import { isSafeDemoAppUrl } from "/imports/install.js";

Router.map(function () {
this.route("install", {
Expand Down
File renamed without changes.
8 changes: 0 additions & 8 deletions shell/client/shell.html → shell/imports/client/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
limitations under the License.
-->

<head>
<title>Sandstorm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
</body>

<template name="layout">
{{>sandstormTopbar globalTopbar}}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion shell/shared/install.js → shell/imports/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

isSafeDemoAppUrl = function isSafeDemoAppUrl(url) {
function isSafeDemoAppUrl(url) {
// For demo accounts, we allow using a bare hash with no URL (which will never upload a new app)
// and we allow specifying a sandstorm.io URL.
return !url ||
Expand All @@ -23,3 +23,5 @@ isSafeDemoAppUrl = function isSafeDemoAppUrl(url) {
url.lastIndexOf("https://alpha-j7uny7u376jnimcsx34c.sandstorm.io/", 0) === 0 ||
url.lastIndexOf("https://app-index.sandstorm.io/", 0) === 0;
};

export { isSafeDemoAppUrl };
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO(cleanup): These tests are no longer run in any automated fashion.
// Figure out a new strategy for making sure we run tests.

const Crypto = Npm.require("crypto");

const globalDb = new SandstormDb();
Expand Down Expand Up @@ -127,4 +130,3 @@ Tinytest.add("test update notifications", function (test) {
test.equal(appUpdate.name, "Mock App");
test.equal(appUpdate.marketingVersion, "0.2");
});

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// TODO(cleanup): These tests are no longer run in any automated fashion.
// Figure out a new strategy for making sure we run tests.

const Crypto = Npm.require("crypto");

const globalDb = new SandstormDb();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// limitations under the License.

import { allowDemo } from "/imports/demo.js";
import { isSafeDemoAppUrl } from "/imports/install.js"
import { promiseToFuture } from "/imports/server/async-helpers.js";

const TOKEN_CLEANUP_MINUTES = 120; // Give enough time for large uploads on slow connections.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const isTesting = Meteor.settings && Meteor.settings.public &&
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
if (isTesting) {
if (Meteor.isServer) {
import { runDueJobs } from '/server/scheduled-job.js';
import { runDueJobs } from '/imports/server/scheduled-job.js';

function clearUser(id) {
UserActions.remove({ userId: id });
Expand Down