Skip to content

Commit

Permalink
feat: create projects as initial project (#772)
Browse files Browse the repository at this point in the history
You can now create a project and set its "is initial project?" value,
like so:

    const projectId = manager.createProject({ isInitialProject: true })
  • Loading branch information
EvanHahn authored Aug 27, 2024
1 parent 0564480 commit 386af02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/mapeo-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,17 @@ export class MapeoManager extends TypedEmitter {
* Create a new project.
* @param {(
* import('type-fest').Simplify<(
* Partial<Pick<ProjectValue, 'name'>> &
* Partial<Pick<ProjectValue, 'name' | 'isInitialProject'>> &
* { configPath?: string }
* )>
* )} [options]
* @returns {Promise<string>} Project public id
*/
async createProject({ name, configPath = this.#defaultConfigPath } = {}) {
async createProject({
name,
configPath = this.#defaultConfigPath,
isInitialProject = false,
} = {}) {
// 1. Create project keypair
const projectKeypair = KeyManager.generateProjectKeypair()

Expand Down Expand Up @@ -401,7 +405,7 @@ export class MapeoManager extends TypedEmitter {
})

// 5. Write project settings to project instance
await project.$setProjectSettings({ name })
await project.$setProjectSettings({ name, isInitialProject })

// 6. Write device info into project
const deviceInfo = this.getDeviceInfo()
Expand Down
3 changes: 2 additions & 1 deletion test-e2e/manager-basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ test('Managing created projects', async (t) => {
const project1Id = await manager.createProject()
const project2Id = await manager.createProject({
name: 'project 2',
isInitialProject: true,
})

await t.test('initial information from listed projects', async () => {
Expand Down Expand Up @@ -79,7 +80,7 @@ test('Managing created projects', async (t) => {
name: 'project 2',
defaultPresets: undefined,
configMetadata: undefined,
isInitialProject: false,
isInitialProject: true,
},
'matched name for project2 with undefined default presets'
)
Expand Down

0 comments on commit 386af02

Please sign in to comment.