Salesforce, Python, SQL, & other ways to put your data where you need it

Need event music? 🎸

Live and recorded jazz, pop, and meditative music for your virtual conference / Zoom wedding / yoga class / private party with quality sound and a smooth technical experience

Configuring Sanity Studio without a local CLI

02 Aug 2020 🔖 tutorials web development
💬 EN

Table of Contents

Sanity.io is a great content management system (CMS), but configuring the user interface that a non-technical content author sees (“Sanity Studio”) requires installation and operation of several command-line tools.

This drastically increases the “lottery factor” risk of losing access to an experienced web developer and stranding a content author with no ability to edit Sanity’s data model (schema) of their content in an emergency.

While I can’t take away the pain of hand-writing JavaScript code and JSON-formatted text to describe data models for Sanity, some online IDEs like Repl.it eliminate the need to install special software to upload such code into Sanity’s cloud.

Let’s see how that would work.


Configuration file organization

Your long-term happiness configuring Sanity from different computers is going to depend upon having a carefully designed file-and-folder structure backed up as a Git repository in the cloud.

You can, of course, structure your project’s folders differently than I’ve done here. The most important consideration is to structure them in a way that makes it easy to write your .gitignore file so that any files and folders particular to your usage of an online IDE don’t end up as part of your Git repository.

For maximum compatibility with online IDEs such as Repl.it, I recommend choosing GitHub as your cloud repository storage provider.

Let’s say you plan to work with a Sanity project called project_01.

Make a Git repository out of a folder whose filestructure looks like this:

.
├── .gitignore
└── sanity_projects
    └── .gitkeep

Eventually, after using the Sanity CLI to create configuration files under /sanity_projects/project_01/, and after hand-editing some files, your repository needs to look like this:

.
├── .gitignore
└── sanity_projects
    ├── .gitkeep
    └── project_01
        ├── package.json
        ├── README.md
        ├── sanity.json
        ├── tsconfig.json
        ├── yaml.lock
        ├── config
        │   ├── .checksums
        │   └── @sanity
        │       ├── data-aspects.json
        │       ├── default-layout.json
        │       ├── default-login.json
        │       └── form-builder.json
        ├── plugins
        │   └── .gitkeep
        ├── schemas
        │   ├── schema.js
        │   ├── your-custom-work-1.js
        │   ├── your-custom-work-1.js
        │   └── (and so on and so forth)
        └── static
            ├── .gitkeep
            └── favicon.ico

This looks like a lot of files, but you’ll only hand-write /.gitignore and the *.js files inside /sanity_projects/project_01/schemas/.

The rest of the files are generated for you by the Sanity CLI tool the first time you set up a project.

You don’t need to touch them, except indirectly through update-type Sanity CLI commands

You do, however, need to keep copies of all of these files backed up in a Git repository.

Note: Technically, /sanity_projects/project_01/sanity.json is the file that lets the Sanity CLI tool know which Sanity project you’re working with. You don’t actually need to name the folder it lives in after the project. I just think it’s a good idea that helps you remember where you put everything.

Other than paranoia about GitHub being down, you don’t need to keep copies of this codebase on your computer or in Repl.it. When it’s time to alter a Sanity project’s configuration, you can set up a clean working environment by cloning this repository to the computer whose command line you’ll be working from.

(However, if you end up altering any of the files in this repository – whether by hand or by letting the Sanity CLI tool update them – be sure to commit and push the changes back to GitHub before deleting project files off the computer you’re using.)


My .gitignore

The contents of my .gitignore file are optimized to the folder structure I’m using with this tutorial.

# Ignore everything at the top level -- files and folders alike
*

# Except .gitignore, .replit, and .package.json -- wait actually do not track those last two
!/.gitignore

# And also except the existence of the folder "sanity_projects" and any ".gitkeep" within
!/sanity_projects/
!/sanity_projects/.gitkeep

# Explicitly except special files living in a subfolder of "sanity_projects"
!/sanity_projects/*/
!/sanity_projects/*/package.json
!/sanity_projects/*/README.md
!/sanity_projects/*/sanity.json
!/sanity_projects/*/tsconfig.json
!/sanity_projects/*/yarn.lock
!/sanity_projects/*/config/
!/sanity_projects/*/config/**
!/sanity_projects/*/plugins/
!/sanity_projects/*/plugins/**
!/sanity_projects/*/schemas/
!/sanity_projects/*/schemas/**
!/sanity_projects/*/static/
!/sanity_projects/*/static/**

# Ignore "dist" and "node_modules" folders that pop up at any level
# (Note:  Change from "/**/dist/**" to "/*/**/dist/**" if for some reason you want to
# track a "dist" folder at the top level of the repository.)
/**/dist/**
/**/node_modules/**

My .gitignore file is more of a “Git include” file in its structure. I use it to tell Git to “ignore” pretty much every file and folder in my project’s directory structure, “excepting” certain ones so that they end up tracked after all.

This helped me achieve my goal of ensuring I don’t commit or push any files or folders from my project that aren’t needed long-term.

  • For example, the Sanity CLI generates a huge node_modules folder, but once I’ve deployed a Studio to Sanity’s servers, I can throw the folder away and rebuild it again when I next need to edit the Studio.
  • In addition to Repl.it, I’ve been playing with using Glitch as an online IDE. I gave up on it because I think the free plan is a little too under-powered to build a Sanity Studio, but along the way I discovered that Glitch likes to add its own files and folders to projects. My takeaway is that it was easier to allow files & folders into Git tracking that I knew I would want to track than it would be to think of everything I might need to exclude when using a given online IDE.

Tutorial flow

Chronologically, I’ll jump around a bit through “project maturity” in this tutorial.

  1. First I’ll show you how to make slight alterations to a running Sanity Studio instance when all of these files are already in place at GitHub.com, and how incorporate these alterations into the backup at GitHub.com.
  2. Next I’ll jump backwards in time and show how I wrote such a file structure to GitHub.com and deployed Sanity Studio in the first place.
  3. As a bonus, I’ll cover some clean-up processes for developers who already deployed Sanity projects (e.g. following along in my first Sanity tutorial) and want to facilitate emergency Repl.it-based Sanity configuration.

Prerequisite: Create an empty Repl.it node project

Log in and create a new project

Set up an account at Repl.it, log in, and go to start a new Node.js project (you can find a full list at https://repl.it/languages).

Be careful to ensure you’re logged in when you do this. Repl.it is perfectly happy to let you create a new Node.js server and leave its entire codebase – including your Sanity passwords in the environment variables – out in the open where everyone can see it and you can’t delete/edit it the moment you close your browser.

In the upper left corner, if you see your Repl.it username before the project name, you’re in the clear.

Click the drop-down and set your project to private if you happen to have a paid Repl.it plan.

Screenshot

If you see Node.js Online Compiler or @Anonymous, you’re not logged in. Close the tab and try again.

Screenshot

Screenshot

Obtain a command line

The Repl.it project you created should come with 1 file in its top folder: index.js.

An editor for index.js should be open in the center panel. Right-click in the editor’s whitespace and select Command Palette or left-click in the whitespace and tap F1 on your keyboard.

Screenshot

In the search box that opens at the top of the editor, start typing “shell” and click “Open Shell.”

Screenshot

Ta-da – you are now borrowing someone else’s command line interface in the cloud.

Remove index.js

Click into the command line panel (bottom right) and type the following command, pressing enter to execute it:

rm index.js

At left, index.js will disappear out of the file list and the center panel should switch to say “Loading files…”

Screenshot

You can verify that your Repl.it project is truly empty by executing the following command in the command line panel:

dir

(It should do nothing of interest, simply showing you another command line prompt on the next line of the panel.)

Recovering the command line with no files

If you accidentally close your tab at this point and re-open your Repl.it project, you won’t be able to get the command line back without a bit of trickery.

In that case, at the top of the left-side file panel, click the “Add file” icon, add any old file with any old name, use the editor to get your command line back, and then click the 3 vertical dots next to your temporary file’s name at left in the files panel and click “Delete” to get back to where you are now.


Altering a running Sanity Studio from its Git cloud repository [[[TO DO:]]] WRITE #1 TITLE

[[[TO DO:]]] WRITE ME


[[[TO DO:]]] WRITE #2 TITLE

[[[TO DO:]]] WRITE ME


Starter files

Fill your /.gitignore file with the contents I shared up above.```

Create /sanity_projects/.gitkeep, but leave it as an empty file. Its only purpose is to take up space in the /sanity_projects/ folder so that Git will incorporate the folder into its tracking.


Altering a running Sanity Studio when you only backed up the schemas [[[TO DO:]]] WRITE #3 TITLE

I have a confession: after writing Sanity Minimum Viable Build, I threw away all the files Sanity generated.

I wrote a blog post about the schema files, so I can copy and paste them, but that’s my only trace left of that project.

Shame on me.

The hosted Studio that I deployed to Sanity’s servers has been yelling at me to upgrade, insisting “Upgrades available: This Studio is now outdated. Consider getting in touch with your developers and ask them to upgrade it for you.”

Screenshot

I’ll upgrade it, and in the process, I’ll build out a proper Git repository backup in the cloud.

Connect GitHub and Repl.it

First I’ll hop over to GitHub, log in with my username replitsanitydemo, and create a new private repository named sane-repl-fix.

Screenshot

(Don’t look too closely – the picture above is a screenshot of me creating a repository with a different name. Oops.)

Screenshot

Back at Repl.it, in the command line panel I opened in the prerequisites, I executed the following command, replacing MY_USERNAME and MY_REPOSITORY_NAME as appropriate and typing my GitHub password when prompted:

git clone https://[email protected]/MY_USERNAME/MY_REPOSITORY_NAME.git .

Screenshot

Recovering a missed connection

Note: The ` . at the end of git clone is important. If your Repl.it file panel at left shows a folder called YOUR_REPOSITORY_NAME, you left off the final space and period.

Start over and set yourself up to git clone again by deleting the YOUR_REPOSITORY_NAME from the file panel (using the vertical dots to the right of it) and running the following command line panel command to “un-git” the folder:

rm -rf .git

Add package.json

Reload the Repl.it in your browser.

~/ImpartialVainGlitch$ ls -la
total 12
drwxr-xr-x 1 runner runner   90 Aug 27 01:27 .
drwxr-xr-x 1 runner runner 4096 Aug 27 01:27 ..
drwxr-xr-x 1 runner runner  138 Aug 27 01:24 .git
-rw-r--r-- 1 runner runner 1056 Aug 27 01:24 .gitignore
drwxr-xr-x 1 runner runner   20 Aug 27 01:27 .upm
-rw-r--r-- 1 runner runner  284 Aug 27 01:27 package.json
drwxr-xr-x 1 runner runner   34 Aug 27 01:24 sanity_projects
As below, plus:
,
    "@sanity/default-layout": ">=1.150.3",
    "@sanity/default-login": ">=1.150.1",
    "@sanity/desk-tool": ">=1.150.4",
    "prop-types": ">=15.6",
    "react": ">=16.2",
    "react-dom": ">=16.2"

About 1 minute:

~/ImpartialVainGlitch$ npm i --package-lock-only
~/ImpartialVainGlitch$ ls -la
total 460
drwxr-xr-x 1 runner runner    124 Aug 27 01:31 .
drwxr-xr-x 1 runner runner   4096 Aug 27 01:31 ..
drwxr-xr-x 1 runner runner    138 Aug 27 01:24 .git
-rw-r--r-- 1 runner runner   1056 Aug 27 01:24 .gitignore
drwxr-xr-x 1 runner runner     20 Aug 27 01:27 .upm
-rw-r--r-- 1 runner runner 456712 Aug 27 01:31 package-lock.json
-rw-r--r-- 1 runner runner    285 Aug 27 01:31 package.json
drwxr-xr-x 1 runner runner     34 Aug 27 01:24 sanity_projects

Many minutes:

~/ImpartialVainGlitch$ npm install
~/ImpartialVainGlitch$ ls -la 
total 460
drwxr-xr-x 1 runner runner    148 Aug 27 01:32 .
drwxr-xr-x 1 runner runner   4096 Aug 27 01:31 ..
drwxr-xr-x 1 runner runner    138 Aug 27 01:24 .git
-rw-r--r-- 1 runner runner   1056 Aug 27 01:24 .gitignore
drwxr-xr-x 1 runner runner     20 Aug 27 01:31 .upm
drwxr-xr-x 1 runner runner  21632 Aug 27 01:34 node_modules
-rw-r--r-- 1 runner runner 456712 Aug 27 01:31 package-lock.json
-rw-r--r-- 1 runner runner    285 Aug 27 01:31 package.json
drwxr-xr-x 1 runner runner     34 Aug 27 01:24 sanity_projects
~/ImpartialVainGlitch$ npx sanity -v
@sanity/cli version 1.150.1
cd sanity_projects/Gatsby-02
~/.../sanity_projects/Gatsby-02$ node ../../node_modules/.bin/sanity build

Add starter files

Presuming you’re following along on a similar journey to mine, in the file panel at left, create a new file and call it .gitignore – with a period as the first character in the filename.

![Screenshot](https://katiekodes.com/images/screenshots/screenshot-sanity-studio-replit-2020-08/tut3/03-replit-add-gitignore.png

Fill your /.gitignore file with the contents I shared earlier in this tutorial – or something like them if you have your own folder structure in mind.

Screenshot

Create a new folder called sanity_projects.

Screenshot

Inside sanity_projects, create a new file called .gitkeep (with a leading period), but leave it as an empty file.

Its only purpose is to take up space in the /sanity_projects/ folder so that Git will incorporate the folder into its tracking.

Screenshot

Sync your starter files to GitHub

Run the following 2 commands to make Repl.it happy when connecting to GitHub, replacing EMAIL_NOT_REALLY_IMPORTANT and NAME_NOT_REALLY_IMPORTANT with something you’re okay storing in the cloud and can recognize as yourself.

git config user.email "EMAIL_NOT_REALLY_IMPORTANT"
git config user.name "NAME_NOT_REALLY_IMPORTANT"

Then run this command to set the primary “branch” of your Git repository to be called “main.”

git checkout -b main

Tell the copy of Git running on Repl.it’s server to make a note of changes to all non-ignored files in your Repl.it project.

(My screenshot is slightly wrong for this command. The command here in the tutorial is correct.)

git add --all

Tell the copy of Git running on Repl.it’s server why you’re checkpointing your changes thus far, replacing First commit as you see fit.

git commit -m "First commit"

Tell the copy of Git running on Repl.it’s server to sync up with your cloud-hosted Git repository.

git push -u origin main

Screenshot

When you visit your cloud-hosted Git repository, its file structure should look just like the one in Repl.it (minus any “ignored” files, of which we don’t have any yet).

Screenshot


Log into Sanity with its CLI

Back at Repl.it, in the command line panel, execute the following command:

npx @sanity/cli login

Arrow-key up and down until the authorization method you typically use for logging into the Sanity management panel is highlighted turquoise and press Enter.

Screenshot

Visit the URL displayed. If you wiggle your cursor over it enough, it should become a link you can Ctrl+click (or Cmd+click on a Mac?) to open in a new tab/window.

Be careful if you have to copy it to your clipboard not to use Ctrl+C, because that will be interpreted by the Repl.it command line as aborting the npx @sanity/cli login process.

You can close the extra tab when Sanity confirms you are logged in.

Screenshot

Screenshot


Create new Sanity scaffolding for your old project

In Repl.it’s command line panel, execute the following command:

cd sanity_projects

Followed by:

npx @sanity/cli init

project

18-replit-sanity-init.png

dataset

19-replit-sanity-init.png

path

/home/runner/ImpartialVainGlitch/sanity_projects/Gatsby-02

20-replit-sanity-init.png

21-replit-sanity-init.png

22-replit-sanity-init.png

23-replit-sanity-init-running.png

Now, using Repl.it’s file panel at left, click the sanity.json file in the folder you just let Sanity set up to see it in the editor. Note how it mentions your project ID and dataset name.

When using the Sanity CLI from the Gatsby-02 folder (or whatever you told npx @sanity/cli init to name this folder), it’s the contents of this file, not the name of the folder you’re in, that lets the Sanity CLI tool (@sanity/cli) know which project further commands are meant to interact with.

24-replit-sanity-json.png


Sync Sanity scaffolding to GitHub

git pull
git add --all

Tell the copy of Git running on Repl.it’s server why you’re checkpointing your changes thus far, replacing First commit as you see fit.

git commit -m "Sanity init"

Tell the copy of Git running on Repl.it’s server to sync up with your cloud-hosted Git repository.

git push -u origin main

Edit the schemas folder as appropriate

Using Repl.it’s file panel at left, I’ll find the schemas folder in my project and edit its contents exactly the way I did in my Sanity Minimum Viable Build tutorial.

25-replit-schemas.png

26-replit-schemas-add-file.png

27-replit-schemas-done.png


Sync Sanity schema edits to GitHub

I’d like to take a backup of my work with Git and sync the changes over to GitHub – I’ve done an awful lot so far.

git pull
git add --all
git commit -m "Sanity schema customizations"
git push -u origin main

Build Sanity

cd sanity_projects/Gatsby-02/

This next command will take about 1 minute to run.

npx @sanity/cli install

[[[TO DO:]]] WRITE ME


MISC NOTES TO SELF

git clone https://[email protected]/username/reponame . ? (In Glitch, had to do some rm -rf ... and had to exit & re-enter project to get Node back as a recognized command)

npx @sanity/cli -v ? (replit)

While npm install -g @sanity/cli doesn’t work from Replit’s CLI, npm install --package-lock-only works just fine. As did my typo --package-json-only start to work … so … Ah. As does npm install @sanity/cli … it was the -g flag Replit didn’t like.

Replit maybe instead:

node ./node_modules/.bin/sanity -v

Okay, so I think I finally got Glitch sorta working.

pnpx sanity login (but maybe pnpx wasn’t necessary – I forgot it in the init command and things were fine)

What I did before that worked & “sanity” worked was add more packages to my package.json – not just "@sanity/client": ">=1.149.18" but also:

{
  "name": "sanity_cli_package",
  "version": "0.0.1",
  "dependencies": {
    "@sanity/client": ">=1.149.18",
    "sanity": "^1.149.7",
    "@sanity/base": "^1.149.19",
    "@sanity/components": "^1.149.19",
    "@sanity/core": "^1.149.19",
    "@sanity/cli": "^1.149.19"
  }
}

Not sure exactly which one was responsible for the magic.

Anyway, plain old sanity -v and sanity init work in Glitch now.

Disk size too full, though.

du to see the culprit

rm -rf .cache to delete it.

rm shrinkwrap.yaml

.env Glitch env variables not showing up with printenv VARNAME. (Trying to force sanity init to not download its own stuff and use pnpm)

Okay, so pnpm i --package-lock-only took a while but seemed to make sanity deploy work from a folder that never really init‘ed properly


Started over in Glitch w/ the sanity-repl-fix that already has scaffolding & schema.

Put this package.json in at root level; not sure if it’s doing anything.

{
  "name": "sanity_cli_package",
  "version": "0.0.1",
  "dependencies": {
    "@sanity/client": ">=1.149.18",
    "sanity": ">=1.149.7",
    "@sanity/base": ">=1.149.19",
    "@sanity/components": ">=1.149.19",
    "@sanity/core": ">=1.149.19",
    "@sanity/cli": ">=1.149.19",
    "@sanity/default-layout": ">=1.150.3",
    "@sanity/default-login": ">=1.150.1",
    "@sanity/desk-tool": ">=1.150.4",
    "@sanity/vision": ">=1.150.1",
    "prop-types": ">=15.6",
    "react": ">=16.2",
    "react-dom": ">=16.2"
  }
}

Trying, at root level:

app@wary-honeysuckle-march:~ 13:59 
$ pnpm install sanity
A store server is running. All store manipulations are delegated to it.
Resolving: total 1, reused 1, downloaded 0, done
Already up-to-date

app@wary-honeysuckle-march:~ 14:00 
$ sanity -v
@sanity/cli version 1.150.1

app@wary-honeysuckle-march:~ 14:00 
$ cd sanity_projects/Gatsby-02/

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:01 
$ sanity -v
@sanity/cli version 1.150.1

Memory at 92% (of 512 MB – warning me “Large or inefficient processes, libraries or compilers that use too much RAM may get killed” since 75%), disk at 1%, CPU at 49% during step 2 of this …

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:02 
$ sanity build
Plugin "@sanity/default-layout" is missing local configuration file, creating config/@sanity/default-layout.json
Plugin "@sanity/default-login" is missing local configuration file, creating config/@sanity/default-login.json
Plugin "@sanity/form-builder" is missing local configuration file, creating config/@sanity/form-builder.json
Plugin "@sanity/data-aspects" is missing local configuration file, creating config/@sanity/data-aspects.json
✔ Clearing output folder (11ms)
⠴ Building Sanity

Looks like I got logged out of Glitch when it died.

Logging back in, this still works:

app@wary-honeysuckle-march:~ 14:07 
$ sanity -v
@sanity/cli version 1.150.1
app@wary-honeysuckle-march:~ 14:07 
$ cd sanity_projects/Gatsby-02/

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:07 
$ pnpm install
A store server is running. All store manipulations are delegated to it.
Resolving: total 10, reused 8, downloaded 0
Resolving: total 89, reused 10, downloaded 0
...
Resolving: total 551, reused 331, downloaded 0
...
Resolving: total 1265, reused 1231, downloaded 0
Resolving: total 1281, reused 1281, downloaded 0
 WARN  @sanity/core > @sanity/server: [email protected] requires a peer of @types/react@^15.0.0 || ^16.0.0 but none was installed.
 WARN  @sanity/desk-tool > @sanity/form-builder > @sanity/portable-text-editor: [email protected] requires a peer of typescript@^2.5.2 || ^3.0 but none was installed.
 WARN  @sanity/desk-tool: [email protected] requires a peer of react@^15.0.0 but version 16.13.1 was installed.
Resolving: total 1281, reused 1281, downloaded 0
Resolving: total 1281, reused 1281, downloaded 0
Resolving: total 1281, reused 1281, downloaded 0
Packages: +1351
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Resolving: total 1281, reused 1281, downloaded 0
Resolving: total 1281, reused 1281, downloaded 0
Resolving: total 1281, reused 1281, downloaded 0
...(seems stuck in a loop)...
Resolving: total 1281, reused 1281, downloaded 0
^C

I tried it again; failed again.

I tried running enable-pnpm and then running again; it failed with more warnings (this time a bunch of babel stuff, too) before hitting the same loop.

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:22 
$ sanity install
✖ Resolving dependenciesetching packages
✖ An unexpected error occurred: "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz: ESOCKETTIMEDOUT".
[              ....] - Fetching packages

Eventually turned into this … with disk usage at 90%

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:22 
$ sanity install
✖ Resolving dependenciesetching packages
✖ An unexpected error occurred: "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz: ESOCKETTIMEDOUT".
✖ Resolving dependenciesetching packages

Error: Command failed :(
    at D.catch.t (/rbd/pnpm-volume/576a3eac-c540-4264-a613-bf7f440ee7f7/node_modules/.registry.npmjs.org/@sanity/cli/1.150.1/node_modules/@sanity/cli/bin/sanity-cli.js:3680:2556)
app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:34

Okay, so tried sanity install, let it error out, deleted .cache folder from the root, ran suggested git pruning.

Then tried sanity build again.

Made it through this time with memory hitting 177% and CPU 92% during bundle minification, but I slipped through! I now have a 2.7MB dist folder in du for the project.

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:44 
$ sanity build
✔ Clearing output folder (10ms)
✔ Building Sanity (174266ms)
✔ Building index document (74ms)
✔ Minifying JavaScript bundles (100642ms)

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:48 

All right, what happens to deploy?

It, too, has a build step, so it could fail.

About a minute into building sanity, at 43% memory & 14% CPU.

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:52 
$ sanity login
app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:53 
$ sanity deploy
✔ Checking project info
✔ Clearing output folder (58ms)
⠴ Building Sanity

Yay, I got away with it! (And yes, it spiked over 100% again.)

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 14:53 
$ sanity deploy
✔ Checking project info
✔ Clearing output folder (58ms)
✔ Building Sanity (388297ms)
✔ Building index document (1467ms)
✔ Minifying JavaScript bundles (434393ms)
✔ Verifying local content
✔ Deploying to Sanity.Studio

Success! Studio deployed to https://gatsby-studio-002.sanity.studio/

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 15:07 

Interesting – Glitch committed to its copy of my git repo for me

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 15:07 
$ git pull
Password for 'https://[email protected]': 
Already up-to-date.

app@wary-honeysuckle-march:~/sanity_projects/Gatsby-02 15:24 
$ cd ../..

app@wary-honeysuckle-march:~ 15:24 
$ git add --all

app@wary-honeysuckle-march:~ 15:24 
$ git commit -m "Post-Sanity-deploy work in Glitch -- what's new?"
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean

app@wary-honeysuckle-march:~ 15:24 
$ git push -u origin main
Password for 'https://[email protected]': 
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.21 KiB | 0 bytes/s, done.
Total 11 (delta 1), reused 10 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://[email protected]/replitsanitydemo/sane-repl-fix.git
   966e9a1..112afed  main -> main
Branch main set up to track remote branch main from origin.

app@wary-honeysuckle-march:~ 15:25 
$ git log
commit 112afed4d769369797c5fa89242d28de9768888b
Author: Glitch (wary-honeysuckle-march) <none>
Date:   Thu Aug 27 14:12:21 2020 +0000

    👚🐀 Checkpoint

commit 966e9a1348a4b59989b4a561ebceffe2e0c4151f
Author: replitsanitydemo <[email protected]>
Date:   Wed Aug 26 20:24:03 2020 -0500

    GitIgnore stop tracking top package.json or top .replit

commit e39dd60b892e85696c0231a0e02e3486a411a4a6
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 01:08:39 2020 +0000

    Sanity schema edits

commit cc617c9673d0525d50422286f48113ab22e51dd5
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 01:04:01 2020 +0000

    Gitignore improve

commit ff5bf32f752d49f031cddd93f8f37ae1e5b9da5a
Merge: 964b39c 2863852
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 01:03:14 2020 +0000

    Gitignore improve

commit 964b39ce3715479d13e1fccd3592629f7df6d615
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 01:02:29 2020 +0000

    Gitignore improve

commit 286385292051988bfc6e6f0987badabced3ff203
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 00:58:55 2020 +0000

    Sanity init

commit e37c01039d73543b38213227cf0fa52be2f72253
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 00:54:16 2020 +0000

    Nevermind about package.json

commit f7498005a6937c29902ec626abcf46ddf757cc9c
Author: NAME_NOT_REALLY_IMPORTANT <EMAIL_NOT_REALLY_IMPORTANT>
Date:   Thu Aug 27 00:24:23 2020 +0000

    Added package.json

commit f721015446956ac4094ad4b6d503fbe1d903aee2
Author: Just me <[email protected]>
Date:   Wed Aug 26 21:30:55 2020 +0000

    Revert gitignore example change

commit 0787b936ee69db8186700b49d9d7ffc959a8e5e0
Author: X X <[email protected]>
Date:   Wed Aug 26 21:27:43 2020 +0000

    A little demo change to .gitignore

commit 9d3527036828e734762edff2cbf676cf7048ad82
Author: Just me <[email protected]>
Date:   Wed Aug 26 21:09:31 2020 +0000

    Oops did not track gitkeep

commit 16a320f5d284ef0fbe1a13f6c5f64a807e067049
Author: Just me <[email protected]>
Date:   Wed Aug 26 21:03:49 2020 +0000

    First commit


app@wary-honeysuckle-march:~ 15:27

It looks like maybe … the first failed build altered config/.checksums and the files in config/@sanity? (data-aspects.json, default-layout.json, default-login.json, form-builder.json)

https://github.com/replitsanitydemo/sane-repl-fix/commit/112afed4d769369797c5fa89242d28de9768888b


Also starting over on Repl.it

~/ImpartialVainGlitch$ rm index.js
~/ImpartialVainGlitch$ git clone https://[email protected]/replitsanitydemo/sane-repl-fix
Cloning into 'sane-repl-fix'...
Password for 'https://[email protected]': 
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 56 (delta 10), reused 49 (delta 6), pack-reused 0
Unpacking objects: 100% (56/56), done.
~/ImpartialVainGlitch$ rm sane-repl-fix -rf
~/ImpartialVainGlitch$ git clone https://[email protected]/replitsanitydemo/sane-repl-fix .
Cloning into '.'...
Password for 'https://[email protected]': 
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 56 (delta 10), reused 49 (delta 6), pack-reused 0
Unpacking objects: 100% (56/56), done.
~/ImpartialVainGlitch$ cd sanity_projects/Gatsby-02/
~/.../sanity_projects/Gatsby-02$ npm install -g sanity
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-08-27T13_45_48_683Z-debug.log
~/.../sanity_projects/Gatsby-02$ npm install sanity

> [email protected] postinstall /home/runner/ImpartialVainGlitch/sanity_projects/Gatsby-02/node_modules/sanity
> node placeholder.js

👋 This is an empty placeholder package

To install Sanity, run:
  npm i -g @sanity/cli

👉 Read more about getting started at https://sanity.io/docs/introduction/getting-started
npm notice created a lockfile as package-lock.json. You should commit this file.
+ [email protected]
added 1 package from 1 contributor and audited 1 package in 0.827s
found 0 vulnerabilities

~/.../sanity_projects/Gatsby-02$ npm i @sanity/cli
+ @sanity/[email protected]
added 1 package from 1 contributor and audited 2 packages in 1.807s
found 0 vulnerabilities

~/.../sanity_projects/Gatsby-02$ sanity
bash: sanity: command not found
~/.../sanity_projects/Gatsby-02$ ls -la
total 316
drwxr-xr-x 1 runner runner    218 Aug 27 13:46 .
drwxr-xr-x 1 runner runner     34 Aug 27 13:45 ..
-rw-r--r-- 1 runner runner    514 Aug 27 13:45 README.md
drwxr-xr-x 1 runner runner     20 Aug 27 13:45 config
drwxr-xr-x 1 runner runner     34 Aug 27 13:46 node_modules
-rw-r--r-- 1 runner runner    610 Aug 27 13:46 package-lock.json
-rw-r--r-- 1 runner runner    862 Aug 27 13:46 package.json
drwxr-xr-x 1 runner runner     16 Aug 27 13:45 plugins
-rw-r--r-- 1 runner runner    491 Aug 27 13:45 sanity.json
drwxr-xr-x 1 runner runner     34 Aug 27 13:45 schemas
drwxr-xr-x 1 runner runner     38 Aug 27 13:45 static
-rw-r--r-- 1 runner runner     90 Aug 27 13:45 tsconfig.json
-rw-r--r-- 1 runner runner 299330 Aug 27 13:45 yarn.lock
~/.../sanity_projects/Gatsby-02$ ls -la node_modules/
total 0
drwxr-xr-x 1 runner runner  34 Aug 27 13:46 .
drwxr-xr-x 1 runner runner 218 Aug 27 13:46 ..
drwxr-xr-x 1 runner runner  12 Aug 27 13:46 .bin
drwxr-xr-x 1 runner runner   6 Aug 27 13:46 @sanity
drwxr-xr-x 1 runner runner  84 Aug 27 13:45 sanity
~/.../sanity_projects/Gatsby-02$ npm install
^C[ .................] | fetchMetadata: sill pacote range manifest for @sanity/core@^1.150.3 fetched 
~/.../sanity_projects/Gatsby-02$ npm install
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: This package has been deprecated, please see migration guide at 'https://github.com/formatjs/formatjs/tree/master/packages/intl-relativeformat#migration-guide'
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated [email protected]: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated [email protected]: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
Killed       ......] | refresh-package-json:uuid: sill refresh-package-json /home/runner/ImpartialVa
~/.../sanity_projects/Gatsby-02$ sanity -v
bash: sanity: command not found
~/.../sanity_projects/Gatsby-02$ npx sanity -v
@sanity/cli version 1.150.1
~/.../sanity_projects/Gatsby-02$ npx sanity build
Plugin "@sanity/default-layout" is missing local configuration file, creating config/@sanity/default-layout.json
Plugin "@sanity/default-login" is missing local configuration file, creating config/@sanity/default-login.json
Plugin "@sanity/form-builder" is missing local configuration file, creating config/@sanity/form-builder.json
Plugin "@sanity/data-aspects" is missing local configuration file, creating config/@sanity/data-aspects.json
✔ Clearing output folder (97ms)
✔ Building Sanity (216912ms)
✔ Building index document (303ms)
⠦ Minifying JavaScript bundlesKilled
~/.../sanity_projects/Gatsby-02$

Looks like Repl.it isn’t happy w/ the memory usage, either.

Tried again w/ install, didn’t help.

~/.../sanity_projects/Gatsby-02$ sanity install
bash: sanity: command not found
~/.../sanity_projects/Gatsby-02$ npx sanity install

✔ Saved lockfile
~/.../sanity_projects/Gatsby-02$ sanity -v
bash: sanity: command not found
~/.../sanity_projects/Gatsby-02$ npx sanity build
✔ Clearing output folder (9ms)
✔ Building Sanity (339643ms)
✔ Building index document (676ms)
⠦ Minifying JavaScript bundlesKilled
~/.../sanity_projects/Gatsby-02$

Meh – just for fun, let’s see what happens if I jump straight to a npx sanity deploy.


Oh, interesting, looks like maybe I should’ve been using sanity install in the project folder, not pnpm install or npm install, to get the node_modules set up.

MINGW64 /c/example/sanityreplit (main)
$ cd sanity_projects/Gatsby-02/

MINGW64 /c/example/sanityreplit/sanity_projects/Gatsby-02 (main)
$ sanity build


   ╭──────────────────────────────────────────────╮
   │                                              │
   │     Update available 1.149.16 → 1.150.1      │
   │   Run npm install -g @sanity/cli to update   │
   │                                              │
   ╰──────────────────────────────────────────────╯

@sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`

Error: "build" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "@sanity/core"
is installed as a dependency.
    at O.runCommand (C:/Users/MY_USERNAME/AppData/Roaming/npm/node_modules/@sanity/cli/bin/sanity-cli.js:3488:2119)
    at t.exports (C:/Users/MY_USERNAME/AppData/Roaming/npm/node_modules/@sanity/cli/bin/sanity-cli.js:2106:2296)

MINGW64 /c/example/sanityreplit/sanity_projects/Gatsby-02 (main)
$ sanity -v
@sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`
@sanity/cli version 1.149.16

MINGW64 /c/example/sanityreplit/sanity_projects/Gatsby-02 (main)
$ sanity install

MINGW64 /c/example/sanityreplit/sanity_projects/Gatsby-02 (main)
$

Okay, sanity install went ridic fast on my PC but is taking forever on Glitch/Repl.it. Mem/CPU in the 30’s on Glitch just go get 1/6th of the “Fetching Packages” bar filled.

$ sanity build
Plugin "@sanity/default-layout" is missing local configuration file, creating config\@sanity\default-layout.json
Plugin "@sanity/default-login" is missing local configuration file, creating config\@sanity\default-login.json
Plugin "@sanity/form-builder" is missing local configuration file, creating config\@sanity\form-builder.json
Plugin "@sanity/data-aspects" is missing local configuration file, creating config\@sanity\data-aspects.json
√ Clearing output folder (5ms)
√ Building Sanity (23730ms)
√ Building index document (36ms)
√ Minifying JavaScript bundles (17302ms)

It looks like what build generates is a dist folder.

There’s not a lot in there. 2MB vs the 200 for the node_modules folder.

It must just be very compute-heavy to generate.

My computer must indeed be able to throw a lot more resources at this than free stuff. 1/10th the time, or less, than replit showing.


npm install -g @sanity/cli
sanity init --project a123bcd45ef
--- ---