Skip to content

Commit

Permalink
add: remove ceramic usage, only orbis
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpy committed Aug 29, 2024
1 parent 0e46bda commit 645927f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 45 deletions.
54 changes: 27 additions & 27 deletions src/plugins/ceramic-feed/cli/commands/client-settings.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
const { get, mapValues } = require('lodash')
// const { get, mapValues } = require('lodash')

const colors = require('chalk')
// const colors = require('chalk')
const logger = require('../utils/logger')

const dotenv = require('dotenv')
const env = require('@strapi/utils/lib/env-helper')
const getPluginsConfig = require('../../../../../config/plugins')
// const env = require('@strapi/utils/lib/env-helper')
// const getPluginsConfig = require('../../../../../config/plugins')

const { string } = require('../../server/utils')
const { Post } = require('../../server/services/ceramic/CeramicOrbisClient')
const bootstrapCeramicNetwork = require('../../server/bootstrap/ceramic-network')
// const { string } = require('../../server/utils')
// const { Post } = require('../../server/services/ceramic/CeramicOrbisClient')
// const bootstrapCeramicNetwork = require('../../server/bootstrap/ceramic-network')

;(async () => {
try {
const envTmpl = string.mustache(
`REACT_APP_CERAMIC_NODE_URL={ceramicNodeURL}\n` +
`REACT_APP_CERAMIC_INDEX={postsIndex}\n` +
`REACT_APP_CERAMIC_LIVE_INDEX={postsLiveIndex}`
)
// const envTmpl = string.mustache(
// `REACT_APP_CERAMIC_NODE_URL={ceramicNodeURL}\n` +
// `REACT_APP_CERAMIC_INDEX={postsIndex}\n` +
// `REACT_APP_CERAMIC_LIVE_INDEX={postsLiveIndex}`
// )

dotenv.config()

const config = getPluginsConfig({ env })
const { ceramicNodeURL, ceramicDIDSeed } = get(
config,
'ceramic-feed.config'
)
// const config = getPluginsConfig({ env })
// const { ceramicNodeURL, ceramicDIDSeed } = get(
// config,
// 'ceramic-feed.config'
// )

await bootstrapCeramicNetwork(ceramicNodeURL, ceramicDIDSeed)
// // await bootstrapCeramicNetwork(ceramicNodeURL, ceramicDIDSeed)

const { id: postsIndex } = await Post.getIndex()
const { id: postsLiveIndex } = await Post.getLiveIndex()
const settings = mapValues(
{ postsIndex, postsLiveIndex, ceramicNodeURL },
String
)
const reactEnv = envTmpl(settings)
// const { id: postsIndex } = await Post.getIndex()
// const { id: postsLiveIndex } = await Post.getLiveIndex()
// const settings = mapValues(
// { postsIndex, postsLiveIndex, ceramicNodeURL },
// String
// )
// const reactEnv = envTmpl(settings)

logger.info('Add the following lines to React App .env file:')
logger.info(`\n\n${colors.cyan(reactEnv)}\n`)
// logger.info('Add the following lines to React App .env file:')
// logger.info(`\n\n${colors.cyan(reactEnv)}\n`)
} catch (exception) {
logger.error(exception)
}
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/ceramic-feed/server/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';
'use strict'

const bootstrapStoreSettings = require('./bootstrap/store-settings')
const bootstrapCeramicNetwork = require('./bootstrap/ceramic-network')
// const bootstrapCeramicNetwork = require('./bootstrap/ceramic-network')

module.exports = async ({ strapi }) => {
const { db, config } = strapi
const { ceramicNodeURL, ceramicDIDSeed } = config.get('plugin.ceramic-feed')
const { db } = strapi
// const { ceramicNodeURL, ceramicDIDSeed } = config.get('plugin.ceramic-feed')

await bootstrapStoreSettings(db)
await bootstrapCeramicNetwork(ceramicNodeURL, ceramicDIDSeed)
};
// await bootstrapCeramicNetwork(ceramicNodeURL, ceramicDIDSeed)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const { basename } = require('path')
const { URL } = require('url')
const LocalStorage = require('localstorage-memory')

const CeramicModel = require('./CeramicModel')
// const CeramicModel = require('./CeramicModel')
const { metadata, filesystem } = require('../../utils')
const { withArray } = require('../../utils/async')

global.localStorage = LocalStorage //required for orbis

class Post extends CeramicModel {
static family = 'Post'
}
// class Post extends CeramicModel {
// static family = 'Post'
// }
/**
* handle saving posts to custom ceramic model(depracated) + newer orbis service
*/
Expand Down Expand Up @@ -79,22 +79,22 @@ class CeramicOrbisClient {

const orbisFormat = this._orbisFormatContent(content)
const { doc } = await this.orbisSdk.createPost(orbisFormat)
const { id } = await Post.createAndPublish(content)
const result = { cid: String(id), orbisId: String(doc) }
// const { id } = await Post.createAndPublish(content)
const result = { orbisId: String(doc) }
console.log('ceramic/orbis create result:', result)
return result
}

async updateAndPublish(id, orbisId, payload) {
await this.orbisReady
const content = await this._getContent(payload)
const document = await Post.load(id)
// const document = await Post.load(id)

const orbisFormat = this._orbisFormatContent(content)

const result = await Promise.all([
orbisId && this.orbisSdk.editPost(orbisId, orbisFormat),
Post.updateAndPublish(document, content)
orbisId && this.orbisSdk.editPost(orbisId, orbisFormat)
// Post.updateAndPublish(document, content)
])
console.log('ceramic/orbis update result:', result)
return result
Expand All @@ -103,8 +103,8 @@ class CeramicOrbisClient {
async unpublish(id, orbisId) {
await this.orbisReady
return Promise.all([
orbisId && this.orbisSdk.deletePost(orbisId),
Post.unpublish(id)
orbisId && this.orbisSdk.deletePost(orbisId)
// Post.unpublish(id)
])
}

Expand Down Expand Up @@ -186,4 +186,4 @@ class CeramicOrbisClient {
}
}

module.exports = { CeramicOrbisClient, Post }
module.exports = { CeramicOrbisClient }

0 comments on commit 645927f

Please sign in to comment.