this.me 2.7.9 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "2.7.9",
3
+ "version": "2.8.0",
4
4
  "description": "User-Centric OS.",
5
5
  "bin": {
6
6
  ".me": "./src/cli/main.js"
package/src/cli/main.js CHANGED
@@ -114,17 +114,17 @@ async function getNewProfileDetails() {
114
114
 
115
115
  /**
116
116
  * Writes the .me object to the filesystem.
117
- * @param {Me} meObject - The Me object to be saved.
117
+ * @param {Me} meProfile - The Me object to be saved.
118
118
  */
119
- function writeMeObjectToFile(meObject) {
120
- const meDirectory = path.join(os.homedir(), '.thisme');
119
+ function writeMeObjectToFile(meProfile) {
120
+ const meDirectory = path.join(os.homedir(), '.me');
121
121
  if (!fs.existsSync(meDirectory)) {
122
122
  fs.mkdirSync(meDirectory, { recursive: true });
123
123
  }
124
124
 
125
- const filePath = path.join(meDirectory, `${meObject.name}.me`);
125
+ const filePath = path.join(meDirectory, `${meProfile.name}.me`);
126
126
  // Consider encrypting the data here before writing to the filesystem
127
- fs.writeFileSync(filePath, JSON.stringify(meObject.getIdentityObject()));
127
+ fs.writeFileSync(filePath, JSON.stringify(meProfile.getIdentityObject()));
128
128
  console.log('Profile created successfully.');
129
129
  }
130
130
 
@@ -135,6 +135,47 @@ function displayOptionsAndCommands() {
135
135
  console.log(program.helpInformation());
136
136
  }
137
137
 
138
+ /**
139
+ * Lists all the .me profile file paths in the user's .me directory.
140
+ * @returns {string[]} An array of full file paths for each .me profile.
141
+ */
142
+ function listMeProfiles() {
143
+ const meDirectory = path.join(os.homedir(), '.me');
144
+ if (fs.existsSync(meDirectory)) {
145
+ const profileFiles = fs.readdirSync(meDirectory)
146
+ .filter(file => file.endsWith('.me'));
147
+ return profileFiles.map(file => path.join(meDirectory, file));
148
+ } else {
149
+ console.log('No profiles found.');
150
+ return [];
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Prompts the user to select a .me profile or go back to the main menu.
156
+ * @returns {Promise<string>} The file path of the selected profile or 'back' to go to the main menu.
157
+ */
158
+ async function selectProfile() {
159
+ const profiles = listMeProfiles();
160
+ if (profiles.length === 0) {
161
+ console.log('No profiles found.');
162
+ return 'back';
163
+ }
164
+
165
+ const choices = profiles.map(file => ({
166
+ name: path.basename(file, '.me'),
167
+ value: file
168
+ })).concat([{ name: 'Go Back to Main Menu', value: 'back' }]);
169
+
170
+ const answer = await inquirer.prompt([{
171
+ type: 'list',
172
+ name: 'selectedProfile',
173
+ message: 'Select a profile to view or go back:',
174
+ choices: choices
175
+ }]);
176
+ return answer.selectedProfile;
177
+ }
178
+
138
179
  /**
139
180
  * Main function to handle the CLI interactions.
140
181
  * Continuously prompts the user for actions until an exit command is given.
@@ -145,13 +186,19 @@ async function main() {
145
186
  while (!exit) {
146
187
  const choice = await getUserChoice();
147
188
  switch (choice) {
148
- case 'View Existing Profiles':
149
- console.log('Existing profiles will be displayed here.');
189
+ /**
190
+ * Handles the 'View Existing Profiles' choice.
191
+ * Lists and displays all existing .me profiles.
192
+ */
193
+ case 'View Existing Profiles':
194
+ const selectedProfile = await selectProfile();
195
+ if (selectedProfile === 'back') {
150
196
  break;
151
- case 'Create New Profile':
152
- const meObject = await getNewProfileDetails();
153
- writeMeObjectToFile(meObject);
154
- break;
197
+ }
198
+ // Read and display the selected profile details here
199
+ console.log(`Selected profile: ${selectedProfile}`);
200
+ // Add logic to handle the selected profile
201
+ break;
155
202
  case 'Exit':
156
203
  console.log('Exiting .me CLI.');
157
204
  exit = true;
@@ -175,3 +222,4 @@ process.on('uncaughtException', (err) => {
175
222
  });
176
223
 
177
224
 
225
+
package/src/me.html CHANGED
@@ -4,7 +4,6 @@
4
4
  </head>
5
5
  <body>
6
6
  Hello, me!
7
-
8
7
  <script>
9
8
  window.fbAsyncInit = function() {
10
9
  FB.init({
@@ -13,9 +12,7 @@
13
12
  xfbml : true,
14
13
  version : '{api-version}'
15
14
  });
16
-
17
15
  FB.AppEvents.logPageView();
18
-
19
16
  };
20
17
 
21
18
  (function(d, s, id){
@@ -27,5 +24,4 @@
27
24
  }(document, 'script', 'facebook-jssdk'));
28
25
  </script>
29
26
  </body>
30
-
31
27
  </html>